diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/path.cpp | 33 |
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);
}
|