diff options
author | Chris Robinson <[email protected]> | 2014-04-13 21:44:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-13 21:44:13 -0700 |
commit | e0d24f9da4789bb48ff3920bbd2667d98db9f7c6 (patch) | |
tree | cbf5df7e46ee275f1f9910508f92d64dda80638c /Alc | |
parent | e615ea3cf951849e9ff5e1812492b418b02de409 (diff) |
Use a helper to detect a path slash on Windows
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/helpers.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 1ad5abe9..e9ef72d1 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -549,6 +549,9 @@ void al_print(const char *type, const char *func, const char *fmt, ...) } #ifdef _WIN32 +static inline int is_slash(int c) +{ return (c == '\\' || c == '/'); } + FILE *OpenDataFile(const char *fname, const char *subdir) { static const int ids[2] = { CSIDL_APPDATA, CSIDL_COMMON_APPDATA }; @@ -556,7 +559,7 @@ FILE *OpenDataFile(const char *fname, const char *subdir) int i; /* If the path is absolute, open it directly. */ - if(fname[0] != '\0' && fname[1] == ':' && (fname[2] == '\\' || fname[2] == '/')) + if(fname[0] != '\0' && fname[1] == ':' && is_slash(fname[2])) { FILE *f; if((f=al_fopen(fname, "rb")) != NULL) @@ -584,7 +587,7 @@ FILE *OpenDataFile(const char *fname, const char *subdir) continue; len = lstrlenW(buffer); - if(len > 0 && (buffer[len-1] == '\\' || buffer[len-1] == '/')) + if(len > 0 && is_slash(buffer[len-1])) buffer[--len] = '\0'; _snwprintf(buffer+len, PATH_MAX-len, L"/%ls/%ls", wsubdir, wname); len = lstrlenW(buffer); |