| 138 | |
| 139 | |
| 140 | static Int8 Stat(const char* path, size_t size, Status& status) { |
| 141 | |
| 142 | bool isFolder; |
| 143 | if (size) { |
| 144 | char c(path[size-1]); |
| 145 | isFolder = (c=='/' || c=='\\'); |
| 146 | } else |
| 147 | isFolder = true; |
| 148 | |
| 149 | bool found; |
| 150 | |
| 151 | #if defined (_WIN32) |
| 152 | // windows doesn't accept blackslash in _wstat |
| 153 | wchar_t wFile[_MAX_PATH]; |
| 154 | size = MultiByteToWideChar(CP_UTF8, 0, path, size, wFile, _MAX_PATH); |
| 155 | if (isFolder) |
| 156 | wFile[size++] = '.'; |
| 157 | wFile[size] = 0; |
| 158 | found = _wstat(wFile, &status)==0; |
| 159 | #else |
| 160 | found = ::stat(size ? path : ".", &status)==0; |
| 161 | #endif |
| 162 | if (!found) |
| 163 | return 0; |
| 164 | return status.st_mode&S_IFDIR ? (isFolder ? 1 : -1) : (isFolder ? -1 : 1); |
| 165 | } |
| 166 | |
| 167 | |
| 168 | FileSystem::Attributes& FileSystem::GetAttributes(const char* path,size_t size, Attributes& attributes) { |
no test coverage detected