diff options
Diffstat (limited to 'lib/System/Win32/Path.inc')
-rw-r--r-- | lib/System/Win32/Path.inc | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index 683c94b..46b965f 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -125,9 +125,30 @@ Path::isValid() const { return true; } +void Path::makeAbsolute() { + TCHAR FullPath[MAX_PATH + 1] = {0}; + LPTSTR FilePart = NULL; + + DWORD RetLength = ::GetFullPathNameA(path.c_str(), + sizeof(FullPath)/sizeof(FullPath[0]), + FullPath, &FilePart); + + if (0 == RetLength) { + // FIXME: Report the error GetLastError() + assert(0 && "Unable to make absolute path!"); + } else if (RetLength > MAX_PATH) { + // FIXME: Report too small buffer (needed RetLength bytes). + assert(0 && "Unable to make absolute path!"); + } else { + path = FullPath; + } +} + bool Path::isAbsolute(const char *NameStart, unsigned NameLen) { assert(NameStart); + // FIXME: This does not handle correctly an absolute path starting from + // a drive letter or in UNC format. switch (NameLen) { case 0: return false; @@ -135,12 +156,15 @@ Path::isAbsolute(const char *NameStart, unsigned NameLen) { case 2: return NameStart[0] == '/'; default: - return NameStart[0] == '/' || (NameStart[1] == ':' && NameStart[2] == '/'); + return (NameStart[0] == '/' || (NameStart[1] == ':' && NameStart[2] == '/')) || + (NameStart[0] == '\\' || (NameStart[1] == ':' && NameStart[2] == '\\')); } } bool Path::isAbsolute() const { + // FIXME: This does not handle correctly an absolute path starting from + // a drive letter or in UNC format. switch (path.length()) { case 0: return false; @@ -784,8 +808,8 @@ CopyFile(const sys::Path &Dest, const sys::Path &Src, std::string* ErrMsg) { // Can't use CopyFile macro defined in Windows.h because it would mess up the // above line. We use the expansion it would have in a non-UNICODE build. if (!::CopyFileA(Src.c_str(), Dest.c_str(), false)) - return MakeErrMsg(ErrMsg, "Can't copy '" + Src.toString() + - "' to '" + Dest.toString() + "': "); + return MakeErrMsg(ErrMsg, "Can't copy '" + Src.str() + + "' to '" + Dest.str() + "': "); return false; } |