Git fork
at reftables-rust 37 lines 1.2 kB view raw
1#ifndef WIN32_PATH_UTILS_H 2#define WIN32_PATH_UTILS_H 3 4int win32_has_dos_drive_prefix(const char *path); 5#define has_dos_drive_prefix win32_has_dos_drive_prefix 6 7int win32_skip_dos_drive_prefix(char **path); 8#define skip_dos_drive_prefix win32_skip_dos_drive_prefix 9#define is_dir_sep is_xplatform_dir_sep 10static inline char *win32_find_last_dir_sep(const char *path) 11{ 12 char *ret = NULL; 13 for (; *path; ++path) 14 if (is_dir_sep(*path)) 15 ret = (char *)path; 16 return ret; 17} 18#define find_last_dir_sep win32_find_last_dir_sep 19static inline int win32_has_dir_sep(const char *path) 20{ 21 /* 22 * See how long the non-separator part of the given path is, and 23 * if and only if it covers the whole path (i.e. path[len] is NUL), 24 * there is no separator in the path---otherwise there is a separator. 25 */ 26 size_t len = strcspn(path, "/\\"); 27 return !!path[len]; 28} 29#define has_dir_sep(path) win32_has_dir_sep(path) 30int win32_offset_1st_component(const char *path); 31#define offset_1st_component win32_offset_1st_component 32int win32_fspathcmp(const char *a, const char *b); 33#define fspathcmp win32_fspathcmp 34int win32_fspathncmp(const char *a, const char *b, size_t count); 35#define fspathncmp win32_fspathncmp 36 37#endif