diff options
Diffstat (limited to 'compat/mingw.h')
-rw-r--r-- | compat/mingw.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/compat/mingw.h b/compat/mingw.h index 9ad204c57c..714bc1d591 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -453,6 +453,27 @@ char *mingw_query_user_email(void); #endif /** + * Verifies that the given path is a valid one on Windows. + * + * In particular, path segments are disallowed which + * + * - end in a period or a space (except the special directories `.` and `..`). + * + * - contain any of the reserved characters, e.g. `:`, `;`, `*`, etc + * + * - correspond to reserved names (such as `AUX`, `PRN`, etc) + * + * The `allow_literal_nul` parameter controls whether the path `NUL` should + * be considered valid (this makes sense e.g. before opening files, as it is + * perfectly legitimate to open `NUL` on Windows, just as it is to open + * `/dev/null` on Unix/Linux). + * + * Returns 1 upon success, otherwise 0. + */ +int is_valid_win32_path(const char *path, int allow_literal_nul); +#define is_valid_path(path) is_valid_win32_path(path, 0) + +/** * Converts UTF-8 encoded string to UTF-16LE. * * To support repositories with legacy-encoded file names, invalid UTF-8 bytes @@ -558,7 +579,7 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen); /* * A critical section used in the implementation of the spawn - * functions (mingw_spawnv[p]e()) and waitpid(). Intialised in + * functions (mingw_spawnv[p]e()) and waitpid(). Initialised in * the replacement main() macro below. */ extern CRITICAL_SECTION pinfo_cs; |