| 289 | } |
| 290 | |
| 291 | bool CScriptFileSystem::IsDir(const string &path) const |
| 292 | { |
| 293 | string search; |
| 294 | if( path.find(":") != string::npos || path.find("/") == 0 || path.find("\\") == 0 ) |
| 295 | search = path; |
| 296 | else |
| 297 | search = currentPath + "/" + path; |
| 298 | |
| 299 | #if defined(_WIN32) |
| 300 | // Windows uses UTF16 so it is necessary to convert the string |
| 301 | wchar_t bufUTF16[10000]; |
| 302 | MultiByteToWideChar(CP_UTF8, 0, search.c_str(), -1, bufUTF16, 10000); |
| 303 | |
| 304 | // Check if the path exists and is a directory |
| 305 | DWORD attrib = GetFileAttributesW(bufUTF16); |
| 306 | if( attrib == INVALID_FILE_ATTRIBUTES || |
| 307 | !(attrib & FILE_ATTRIBUTE_DIRECTORY) ) |
| 308 | return false; |
| 309 | #else |
| 310 | // Check if the path exists and is a directory |
| 311 | struct stat st; |
| 312 | if( stat(search.c_str(), &st) == -1 ) |
| 313 | return false; |
| 314 | if( (st.st_mode & S_IFDIR) == 0 ) |
| 315 | return false; |
| 316 | #endif |
| 317 | |
| 318 | return true; |
| 319 | } |
| 320 | |
| 321 | bool CScriptFileSystem::IsLink(const string &path) const |
| 322 | { |