| 3052 | } |
| 3053 | |
| 3054 | bool SystemTools::FileIsDirectory(std::string const& inName) |
| 3055 | { |
| 3056 | if (inName.empty()) { |
| 3057 | return false; |
| 3058 | } |
| 3059 | |
| 3060 | char local_buffer[KWSYS_SYSTEMTOOLS_MAXPATH]; |
| 3061 | std::string string_buffer; |
| 3062 | auto const name = RemoveTrailingSlashes(inName, local_buffer, string_buffer); |
| 3063 | |
| 3064 | // Now check the file node type. |
| 3065 | #if defined(_WIN32) |
| 3066 | DWORD attr = |
| 3067 | GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str()); |
| 3068 | return (attr != INVALID_FILE_ATTRIBUTES) && |
| 3069 | (attr & FILE_ATTRIBUTE_DIRECTORY); |
| 3070 | #else |
| 3071 | struct stat fs; |
| 3072 | |
| 3073 | return (stat(name, &fs) == 0) && S_ISDIR(fs.st_mode); |
| 3074 | #endif |
| 3075 | } |
| 3076 | |
| 3077 | bool SystemTools::FileIsExecutable(std::string const& inName) |
| 3078 | { |