From 36acae9a00100d2f58505c09eeeb27875c754062 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 29 Mar 2019 14:19:41 +0100 Subject: [PATCH] gdi: treat slash as path separator on windows --- core/imgread/gdi.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/core/imgread/gdi.cpp b/core/imgread/gdi.cpp index 3f59ea5bf..92c896519 100644 --- a/core/imgread/gdi.cpp +++ b/core/imgread/gdi.cpp @@ -3,10 +3,22 @@ #include #include +// On windows, transform / to \\ + +string normalize_path_separator(string path) +{ +#if HOST_OS == OS_WINDOWS + std::replace(path.begin(), path.end(), '/', '\\'); +#endif + + return path; +} + // given file/name.ext or file\name.ext returns file/ or file\, depending on the platform // given name.ext returns ./ or .\, depending on the platform string OS_dirname(string file) { + file = normalize_path_separator(file); #if HOST_OS == OS_WINDOWS const char sep = '\\'; #else @@ -25,19 +37,6 @@ string OS_dirname(string file) return file.substr(0, last_slash + 1); } -// On windows, transform / to \\ -// On linux, transform \\ to / -string normalize_path_separator(string path) -{ - #if HOST_OS == OS_WINDOWS - std::replace( path.begin(), path.end(), '/', '\\'); - #else - std::replace( path.begin(), path.end(), '\\', '/'); - #endif - - return path; -} - #if 0 // TODO: Move this to some tests, make it platform agnostic namespace { struct OS_dirname_Test {