[llvm-commits] CVS: llvm/lib/System/Win32/MappedFile.inc Path.inc Program.inc Win32.h

Anton Korobeynikov asl at math.spbu.ru
Fri Sep 1 13:35:34 PDT 2006



Changes in directory llvm/lib/System/Win32:

MappedFile.inc updated: 1.7 -> 1.8
Path.inc updated: 1.57 -> 1.58
Program.inc updated: 1.17 -> 1.18
Win32.h updated: 1.9 -> 1.10
---
Log message:

- Fixed broken Win32 build
- Removed warning about clobbered parameter in Bytecode/Reader


---
Diffs of the changes:  (+24 -20)

 MappedFile.inc |    2 ++
 Path.inc       |   32 +++++++++++++++++++-------------
 Program.inc    |    4 ++--
 Win32.h        |    6 +-----
 4 files changed, 24 insertions(+), 20 deletions(-)


Index: llvm/lib/System/Win32/MappedFile.inc
diff -u llvm/lib/System/Win32/MappedFile.inc:1.7 llvm/lib/System/Win32/MappedFile.inc:1.8
--- llvm/lib/System/Win32/MappedFile.inc:1.7	Fri Aug 25 16:37:17 2006
+++ llvm/lib/System/Win32/MappedFile.inc	Fri Sep  1 15:35:17 2006
@@ -55,6 +55,8 @@
     return MakeErrMsg(ErrMsg, 
       std::string("Can't get size of file: ") + path_.toString());
   }
+
+  return false;
 }
 
 void MappedFile::terminate() {


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.57 llvm/lib/System/Win32/Path.inc:1.58
--- llvm/lib/System/Win32/Path.inc:1.57	Fri Aug 25 16:37:17 2006
+++ llvm/lib/System/Win32/Path.inc	Fri Sep  1 15:35:17 2006
@@ -315,12 +315,12 @@
   return false;
 }
 
-void Path::makeWriteableOnDisk(std::string* ErrMsg) {
+bool Path::makeWriteableOnDisk(std::string* ErrMsg) {
   DWORD attr = GetFileAttributes(path.c_str());
 
   // If it doesn't exist, we're done.
   if (attr == INVALID_FILE_ATTRIBUTES)
-    return;
+    return false;
 
   if (attr & FILE_ATTRIBUTE_READONLY) {
     if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY)) {
@@ -338,7 +338,11 @@
 
 bool
 Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const {
-  if (!isDirectory()) {
+  FileStatus Status;
+  if (getFileStatus(Status, ErrMsg))
+    return true;
+
+  if (!Status.isDir) {
     MakeErrMsg(ErrMsg, path + ": not a directory");
     return true;
   }
@@ -512,7 +516,7 @@
     // Drop trailing slash.
     pathname[len-1] = 0;
     if (!CreateDirectory(pathname, NULL)) {
-      return MakeErrMsg(, std::string(pathname) + ": Can't create directory: ");
+      return MakeErrMsg(ErrMsg, std::string(pathname) + ": Can't create directory: ");
     }
   }
   return false;
@@ -652,10 +656,12 @@
 }
 
 bool
-Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrStr) const {
+Path::setStatusInfoOnDisk(const FileStatus &si, std::string *ErrMsg) const {
   // FIXME: should work on directories also.
-  if (!isFile()) return true;
-
+  if (!si.isFile) {
+    return true;
+  }
+  
   HANDLE h = CreateFile(path.c_str(),
                         FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES,
                         FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
@@ -671,7 +677,7 @@
     DWORD err = GetLastError();
     CloseHandle(h);
     SetLastError(err);
-    return MakeErrMsg(ErrStr, path + ": GetFileInformationByHandle: ");
+    return MakeErrMsg(ErrMsg, path + ": GetFileInformationByHandle: ");
   }
 
   FILETIME ft;
@@ -681,7 +687,7 @@
   CloseHandle(h);
   if (!ret) {
     SetLastError(err);
-    return MakeErrMsg(path + ": SetFileTime: ");
+    return MakeErrMsg(ErrMsg, path + ": SetFileTime: ");
   }
 
   // Best we can do with Unix permission bits is to interpret the owner
@@ -690,13 +696,13 @@
     if (bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
       if (!SetFileAttributes(path.c_str(),
               bhfi.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY))
-        return MakeErrMsg(ErrStr, path + ": SetFileAttributes: ");
+        return MakeErrMsg(ErrMsg, path + ": SetFileAttributes: ");
     }
   } else {
     if (!(bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) {
       if (!SetFileAttributes(path.c_str(),
               bhfi.dwFileAttributes | FILE_ATTRIBUTE_READONLY))
-        return MakeErrMsg(ErrStr, path + ": SetFileAttributes: ");
+        return MakeErrMsg(ErrMsg, path + ": SetFileAttributes: ");
     }
   }
 
@@ -739,13 +745,13 @@
 bool
 Path::createTemporaryFileOnDisk(bool reuse_current, std::string* ErrMsg) {
   // Make this into a unique file name
-  makeUnique(reuse_current);
+  makeUnique(reuse_current, ErrMsg);
 
   // Now go and create it
   HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
                         FILE_ATTRIBUTE_NORMAL, NULL);
   if (h == INVALID_HANDLE_VALUE)
-    return MakeErrMsg(ErrMsg, path.toString() + ": can't create file");
+    return MakeErrMsg(ErrMsg, path + ": can't create file");
 
   CloseHandle(h);
   return false;


Index: llvm/lib/System/Win32/Program.inc
diff -u llvm/lib/System/Win32/Program.inc:1.17 llvm/lib/System/Win32/Program.inc:1.18
--- llvm/lib/System/Win32/Program.inc:1.17	Mon Aug 21 01:02:44 2006
+++ llvm/lib/System/Win32/Program.inc	Fri Sep  1 15:35:17 2006
@@ -158,14 +158,14 @@
       MakeErrMsg(ErrMsg, "can't redirect stdin");
       return -1;
     }
-    si.hStdOutput = RedirectIO(redirects[1], 1);
+    si.hStdOutput = RedirectIO(redirects[1], 1, ErrMsg);
     if (si.hStdOutput == INVALID_HANDLE_VALUE) {
       CloseHandle(si.hStdInput);
       MakeErrMsg(ErrMsg, "can't redirect stdout");
       return -1;
     }
     if (redirects[1] && redirects[2] && *(redirects[1]) != *(redirects[2])) {
-      si.hStdError = RedirectIO(redirects[2], 2);
+      si.hStdError = RedirectIO(redirects[2], 2, ErrMsg);
       if (si.hStdError == INVALID_HANDLE_VALUE) {
         CloseHandle(si.hStdInput);
         CloseHandle(si.hStdOutput);


Index: llvm/lib/System/Win32/Win32.h
diff -u llvm/lib/System/Win32/Win32.h:1.9 llvm/lib/System/Win32/Win32.h:1.10
--- llvm/lib/System/Win32/Win32.h:1.9	Fri Aug 25 16:37:17 2006
+++ llvm/lib/System/Win32/Win32.h	Fri Sep  1 15:35:17 2006
@@ -30,11 +30,7 @@
   char *buffer = NULL;
   FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
       NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
-  ErrMsg = prefix + buffer;
+  *ErrMsg = prefix + buffer;
   LocalFree(buffer);
   return true;
 }
-
-inline void MakeErrnoMsg(std::string* ErrMsg, const std::string & prefix) {
-  MakeErrorMsg(prefix + ": " + strerror(errno));
-}






More information about the llvm-commits mailing list