From: Toni Wilen Date: Sat, 5 Jan 2019 13:54:08 +0000 (+0200) Subject: x:\, x:\. and x:\.. are identical paths. X-Git-Tag: 4200~88 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=894f0601b8985963064eb0268a08dc9808ebe9b9;p=francis%2Fwinuae.git x:\, x:\. and x:\.. are identical paths. --- diff --git a/filesys.cpp b/filesys.cpp index e42433fe..28ddc167 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -705,7 +705,7 @@ static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci, bool custo for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (nr == i || !mountinfo.ui[i].open || mountinfo.ui[i].rootdir == NULL || is_hardfile (i) == FILESYS_CD) continue; - if (_tcslen (c.rootdir) > 0 && !_tcsicmp (mountinfo.ui[i].rootdir, c.rootdir)) { + if (_tcslen(c.rootdir) > 0 && samepath(mountinfo.ui[i].rootdir, c.rootdir)) { error_log (_T("directory/hardfile '%s' already added."), c.rootdir); return -1; } diff --git a/include/uae.h b/include/uae.h index 9fa23022..cfdb8ff1 100644 --- a/include/uae.h +++ b/include/uae.h @@ -45,6 +45,7 @@ extern void fullpath(TCHAR *path, int size); extern void fullpath(TCHAR *path, int size, bool userelative); extern void getpathpart (TCHAR *outpath, int size, const TCHAR *inpath); extern void getfilepart (TCHAR *out, int size, const TCHAR *path); +extern bool samepath(const TCHAR *p1, const TCHAR *p2); extern bool target_isrelativemode(void); extern uae_u32 getlocaltime (void); extern bool isguiactive(void); diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 718e4d0f..72dd68b3 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -3554,6 +3554,13 @@ void fixtrailing (TCHAR *p) return; _tcscat(p, _T("\\")); } +static void fixdriveletter(TCHAR *path) +{ + if (_istalpha(path[0]) && path[1] == ':' && path[2] == '\\' && path[3] == '.' && path[4] == 0) + path[3] = 0; + if (_istalpha(path[0]) && path[1] == ':' && path[2] == '\\' && path[3] == '.' && path[4] == '.' && path[5] == 0) + path[3] = 0; +} // convert path to absolute or relative void fullpath(TCHAR *path, int size, bool userelative) { @@ -3610,10 +3617,24 @@ done:; DWORD err = GetFullPathName (tmp, size, path, NULL); } } + void fullpath(TCHAR *path, int size) { fullpath(path, size, relativepaths); } +bool samepath(const TCHAR *p1, const TCHAR *p2) +{ + if (!_tcsicmp(p1, p2)) + return true; + TCHAR path1[MAX_DPATH], path2[MAX_DPATH]; + _tcscpy(path1, p1); + _tcscpy(path2, p2); + fixdriveletter(path1); + fixdriveletter(path2); + if (!_tcsicmp(path1, path2)) + return true; + return false; +} bool target_isrelativemode(void) {