X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSystem%2FWin32%2FPath.cpp;h=88e20cd354f417fcc97b7fbb8daec5223afa5de0;hb=626e38e4813c357bd7161782286317ee42357313;hp=8201dd4ab22d66c7f6e972081cce6a1c563f9ec5;hpb=b0e1887014100939f8dfc334b077fee9ae5b47a1;p=oota-llvm.git diff --git a/lib/System/Win32/Path.cpp b/lib/System/Win32/Path.cpp index 8201dd4ab22..88e20cd354f 100644 --- a/lib/System/Win32/Path.cpp +++ b/lib/System/Win32/Path.cpp @@ -118,11 +118,6 @@ Path::GetRootDirectory() { return result; } -std::string -Path::GetDLLSuffix() { - return "dll"; -} - static void getPathList(const char*path, std::vector& Paths) { const char* at = path; const char* delim = strchr(at, ';'); @@ -292,6 +287,51 @@ Path::getLast() const { return path.substr(pos+1); } +void +Path::getStatusInfo(StatusInfo& info) const { + WIN32_FILE_ATTRIBUTE_DATA fi; + if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) + ThrowError(std::string(path) + ": Can't get status: "); + + info.fileSize = fi.nFileSizeHigh; + info.fileSize <<= 32; + info.fileSize += fi.nFileSizeLow; + + info.mode = 0777; // Not applicable to Windows, so... + info.user = 9999; // Not applicable to Windows, so... + info.group = 9999; // Not applicable to Windows, so... + + __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime); + info.modTime.fromWin32Time(ft); + + info.isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; + if (info.isDir && path[path.length() - 1] != '/') + path += '/'; + else if (!info.isDir && path[path.length() - 1] == '/') + path.erase(path.length() - 1); +} + +void Path::makeReadable() { + // All files are readable on Windows (ignoring security attributes). +} + +void Path::makeWriteable() { + DWORD attr = GetFileAttributes(path.c_str()); + + // If it doesn't exist, we're done. + if (attr == INVALID_FILE_ATTRIBUTES) + return; + + if (attr & FILE_ATTRIBUTE_READONLY) { + if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY)) + ThrowError(std::string(path) + ": Can't make file writable: "); + } +} + +void Path::makeExecutable() { + // All files are executable on Windows (ignoring security attributes). +} + bool Path::setDirectory(const std::string& a_path) { if (a_path.size() == 0)