| 214 | } |
| 215 | |
| 216 | bool |
| 217 | Exists(std::string const& path) |
| 218 | { |
| 219 | #ifdef US_PLATFORM_POSIX |
| 220 | US_STAT s; |
| 221 | errno = 0; |
| 222 | if (us_stat(path.c_str(), &s)) |
| 223 | { |
| 224 | if (not_found_c_error(errno)) |
| 225 | { |
| 226 | return false; |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | throw std::invalid_argument(GetLastCErrorStr()); |
| 231 | } |
| 232 | } |
| 233 | #else |
| 234 | std::wstring wpath(ToWString(path)); |
| 235 | DWORD attr(::GetFileAttributesW(wpath.c_str())); |
| 236 | if (attr == INVALID_FILE_ATTRIBUTES) |
| 237 | { |
| 238 | if (not_found_win32_error(::GetLastError())) |
| 239 | { |
| 240 | return false; |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | throw std::invalid_argument(GetLastWin32ErrorStr()); |
| 245 | } |
| 246 | } |
| 247 | #endif |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | bool |
| 252 | IsDirectory(std::string const& path) |