summaryrefslogtreecommitdiff
path: root/src/mir_core/path.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-09 09:40:04 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-09 09:40:04 +0000
commit68e5eb0709241968a1b91fb53e4c4cba27581a4a (patch)
treefd25980bef799f9cea7e5b40d7e719efdedbb926 /src/mir_core/path.cpp
parent7dc1d90c50b342dbc92b9ef416ceb947434f8cb1 (diff)
fix: PathToAbsolute doesn't clear the output string on error
git-svn-id: http://svn.miranda-ng.org/main/trunk@3930 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core/path.cpp')
-rw-r--r--src/mir_core/path.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mir_core/path.cpp b/src/mir_core/path.cpp
index 8c9dd6bacf..9e96c4348b 100644
--- a/src/mir_core/path.cpp
+++ b/src/mir_core/path.cpp
@@ -59,18 +59,22 @@ MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut)
MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base)
{
- if ( !pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH)
+ if ( !pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH) {
+ *pOut = 0;
return 0;
-
- if (base == NULL)
- base = szMirandaPath;
+ }
char buf[MAX_PATH];
if (pSrc[0] < ' ')
return mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
- else if (pathIsAbsolute(pSrc))
+
+ if (pathIsAbsolute(pSrc))
return GetFullPathNameA(pSrc, MAX_PATH, pOut, NULL);
- else if (pSrc[0] != '\\')
+
+ if (base == NULL)
+ base = szMirandaPath;
+
+ if (pSrc[0] != '\\')
mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc);
else
mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc+1);
@@ -141,22 +145,25 @@ MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut)
MIR_CORE_DLL(int) PathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base)
{
- if ( !pSrc || !wcslen(pSrc) || wcslen(pSrc) > MAX_PATH)
+ if ( !pSrc || !wcslen(pSrc) || wcslen(pSrc) > MAX_PATH) {
+ *pOut = 0;
return 0;
-
- if (base == NULL)
- base = szMirandaPathW;
+ }
TCHAR buf[MAX_PATH];
if (pSrc[0] < ' ')
return mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- else if (pathIsAbsoluteW(pSrc))
+
+ if (pathIsAbsoluteW(pSrc))
return GetFullPathName(pSrc, MAX_PATH, pOut, NULL);
- else if (pSrc[0] != '\\')
+
+ if (base == NULL)
+ base = szMirandaPathW;
+
+ if (pSrc[0] != '\\')
mir_sntprintf(buf, MAX_PATH, _T("%s%s"), base, pSrc);
else
mir_sntprintf(buf, MAX_PATH, _T("%s%s"), base, pSrc+1);
-
return GetFullPathName(buf, MAX_PATH, pOut, NULL);
}