Created
May 28, 2016 06:11
-
-
Save mlabbe/87bf3a068ad4816affd84222177a6b69 to your computer and use it in GitHub Desktop.
Cross platform path exists test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* returns true if the dir or file exists */ | |
| FTGDEF bool | |
| ftg_path_exists(const char *path) | |
| { | |
| #ifdef FTG_POSIX_LIKE | |
| return access(path, F_OK) != -1; | |
| #elif defined(_WIN32) | |
| ftg_wchar_t u8_path[MAX_PATH]; | |
| DWORD attrib; | |
| ftg_wchar_from_u8(path, u8_path, MAX_PATH); | |
| attrib = GetFileAttributesW(u8_path); | |
| return (attrib != INVALID_FILE_ATTRIBUTES); | |
| #endif | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment