Skip to content

Instantly share code, notes, and snippets.

@mlabbe
Created May 28, 2016 06:11
Show Gist options
  • Select an option

  • Save mlabbe/87bf3a068ad4816affd84222177a6b69 to your computer and use it in GitHub Desktop.

Select an option

Save mlabbe/87bf3a068ad4816affd84222177a6b69 to your computer and use it in GitHub Desktop.
Cross platform path exists test
/* 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