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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.65 - 1.66
---
Log message:

pull some win32 code into common code, add bitcode identification support.


---
Diffs of the changes:  (+0 -15)

 Path.inc |   15 ---
 1 files changed, 15 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.65 llvm/lib/System/Win32/Path.inc:1.66
--- llvm/lib/System/Win32/Path.inc:1.65 Sat Apr  7 15:47:27 2007
+++ llvm/lib/System/Win32/Path.inc  Sun May  6 00:32:21 2007
@@ -247,21 +247,6 @@
 return path.substr(slash, dot - slash);
 }
 
-bool Path::hasMagicNumber(const std::string Magic) const {
-  std::string actualMagic;
-  if (getMagicNumber(actualMagic, Magic.size()))
-return Magic == actualMagic;
-  return false;
-}
-
-bool
-Path::isBytecodeFile() const {
-  std::string actualMagic;
-  if (!getMagicNumber(actualMagic, 4))
-return false;
-  return actualMagic == llvc || actualMagic == llvm;
-}
-
 bool
 Path::exists() const {
   DWORD attr = GetFileAttributes(path.c_str());



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-07 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.63 - 1.64
---
Log message:

For PR1291: http://llvm.org/PR1291 :
Implement the PathWithStatus class and its use throughout lib/System.


---
Diffs of the changes:  (+15 -17)

 Path.inc |   32 +++-
 1 files changed, 15 insertions(+), 17 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.63 llvm/lib/System/Win32/Path.inc:1.64
--- llvm/lib/System/Win32/Path.inc:1.63 Thu Mar 29 14:05:44 2007
+++ llvm/lib/System/Win32/Path.inc  Sat Apr  7 13:52:17 2007
@@ -307,8 +307,8 @@
 }
 
 const FileStatus *
-Path::getFileStatus(bool update, std::string *ErrStr) const {
-  if (status == 0 || update) {
+PathWithStatus::getFileStatus(bool update, std::string *ErrStr) const {
+  if (!fsIsValid || update) {
 WIN32_FILE_ATTRIBUTE_DATA fi;
 if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi)) {
   MakeErrMsg(ErrStr, getStatusInfo(): + std::string(path) +
@@ -316,30 +316,28 @@
   return 0;
 }
 
-if (status == 0)
-  status = new FileStatus;
-
-status-fileSize = fi.nFileSizeHigh;
-status-fileSize = sizeof(fi.nFileSizeHigh)*8;
-status-fileSize += fi.nFileSizeLow;
-
-status-mode = fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
-status-user = ;// Not applicable to Windows, so...
-status-group = ;   // Not applicable to Windows, so...
+status.fileSize = fi.nFileSizeHigh;
+status.fileSize = sizeof(fi.nFileSizeHigh)*8;
+status.fileSize += fi.nFileSizeLow;
+
+status.mode = fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
+status.user = ;// Not applicable to Windows, so...
+status.group = ;   // Not applicable to Windows, so...
 
 // FIXME: this is only unique if the file is accessed by the same file 
path.
 // How do we do this for C:\dir\file and ..\dir\file ? Unix has inode
 // numbers, but the concept doesn't exist in Windows.
-status-uniqueID = 0;
+status.uniqueID = 0;
 for (unsigned i = 0; i  path.length(); ++i)
-  status-uniqueID += path[i];
+  status.uniqueID += path[i];
 
 __int64 ft = *reinterpret_cast__int64*(fi.ftLastWriteTime);
-status-modTime.fromWin32Time(ft);
+status.modTime.fromWin32Time(ft);
 
-status-isDir = fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
+status.isDir = fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
+fsIsValid = true;
   }
-  return status;
+  return status;
 }
 
 bool Path::makeReadableOnDisk(std::string* ErrMsg) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/System/Win32/Path.inc Signals.inc

2007-04-07 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.64 - 1.65
Signals.inc updated: 1.23 - 1.24
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+32 -32)

 Path.inc|   53 +
 Signals.inc |   11 +++
 2 files changed, 32 insertions(+), 32 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.64 llvm/lib/System/Win32/Path.inc:1.65
--- llvm/lib/System/Win32/Path.inc:1.64 Sat Apr  7 13:52:17 2007
+++ llvm/lib/System/Win32/Path.inc  Sat Apr  7 15:47:27 2007
@@ -368,11 +368,15 @@
 
 bool
 Path::getDirectoryContents(std::setPath result, std::string* ErrMsg) const {
-  const FileStatus *Status = getFileStatus(false, ErrMsg);
-  if (!Status)
+  WIN32_FILE_ATTRIBUTE_DATA fi;
+  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi)) {
+MakeErrMsg(ErrMsg, path + : can't get status of file);
 return true;
-  if (!Status-isDir) {
-MakeErrMsg(ErrMsg, path + : not a directory);
+  }
+
+  if (!(fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY)) {
+if (ErrMsg)
+  *ErrMsg = path + : not a directory;
 return true;
   }
 
@@ -565,28 +569,11 @@
 
 bool
 Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
-  const FileStatus *Status = getFileStatus(false, ErrStr);
-  if (!Status)
-return false;
+  WIN32_FILE_ATTRIBUTE_DATA fi;
+  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
+return true;
 
-  if (Status-isFile) {
-DWORD attr = GetFileAttributes(path.c_str());
-
-// If it doesn't exist, we're done.
-if (attr == INVALID_FILE_ATTRIBUTES)
-  return false;
-
-// Read-only files cannot be deleted on Windows.  Must remove the read-only
-// attribute first.
-if (attr  FILE_ATTRIBUTE_READONLY) {
-  if (!SetFileAttributes(path.c_str(), attr  ~FILE_ATTRIBUTE_READONLY))
-return MakeErrMsg(ErrStr, path + : Can't destroy file: );
-}
-
-if (!DeleteFile(path.c_str()))
-  return MakeErrMsg(ErrStr, path + : Can't destroy file: );
-return false;
-  } else if (Status-isDir) {
+  if (fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY) {
 // If it doesn't exist, we're done.
 if (!exists())
   return false;
@@ -645,9 +632,19 @@
   return MakeErrMsg(ErrStr, 
 std::string(pathname) + : Can't destroy directory: );
 return false;
-  } 
-  // It appears the path doesn't exist.
-  return true;
+  } else {
+// Read-only files cannot be deleted on Windows.  Must remove the read-only
+// attribute first.
+if (fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY) {
+  if (!SetFileAttributes(path.c_str(),
+ fi.dwFileAttributes  ~FILE_ATTRIBUTE_READONLY))
+return MakeErrMsg(ErrStr, path + : Can't destroy file: );
+}
+
+if (!DeleteFile(path.c_str()))
+  return MakeErrMsg(ErrStr, path + : Can't destroy file: );
+return false;
+  }
 }
 
 bool Path::getMagicNumber(std::string Magic, unsigned len) const {


Index: llvm/lib/System/Win32/Signals.inc
diff -u llvm/lib/System/Win32/Signals.inc:1.23 
llvm/lib/System/Win32/Signals.inc:1.24
--- llvm/lib/System/Win32/Signals.inc:1.23  Thu Mar 29 14:05:44 2007
+++ llvm/lib/System/Win32/Signals.inc   Sat Apr  7 15:47:27 2007
@@ -101,12 +101,15 @@
 // RemoveDirectoryOnSignal - The public API
 bool sys::RemoveDirectoryOnSignal(const sys::Path path, std::string* ErrMsg) {
   // Not a directory?
-  const sys::FileStatus *Status =  path.getFileStatus(false, ErrMsg);
-  if (!Status)
+  WIN32_FILE_ATTRIBUTE_DATA fi;
+  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi)) {
+MakeErrMsg(ErrMsg, path.toString() + : can't get status of file);
 return true;
-  if (!Status-isDir) {
+  }
+
+  if (!(fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY)) {
 if (ErrMsg)
-  *ErrMsg = path.toString() +  is not a directory;
+  *ErrMsg = path.toString() + : not a directory;
 return true;
   }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/System/Win32/Path.inc Signals.inc

2007-04-07 Thread Reid Spencer
On Sat, 2007-04-07 at 15:47 -0500, Jeff Cohen wrote:
 
 Changes in directory llvm/lib/System/Win32:
 
 Path.inc updated: 1.64 - 1.65
 Signals.inc updated: 1.23 - 1.24
 ---
 Log message:
 
 Unbreak VC++ build.

Thanks for cleaning up after me, Jeff. 

Reid.

 
 ---
 Diffs of the changes:  (+32 -32)
 
  Path.inc|   53 +
  Signals.inc |   11 +++
  2 files changed, 32 insertions(+), 32 deletions(-)
 
 
 Index: llvm/lib/System/Win32/Path.inc
 diff -u llvm/lib/System/Win32/Path.inc:1.64 
 llvm/lib/System/Win32/Path.inc:1.65
 --- llvm/lib/System/Win32/Path.inc:1.64   Sat Apr  7 13:52:17 2007
 +++ llvm/lib/System/Win32/Path.incSat Apr  7 15:47:27 2007
 @@ -368,11 +368,15 @@
  
  bool
  Path::getDirectoryContents(std::setPath result, std::string* ErrMsg) 
 const {
 -  const FileStatus *Status = getFileStatus(false, ErrMsg);
 -  if (!Status)
 +  WIN32_FILE_ATTRIBUTE_DATA fi;
 +  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi)) {
 +MakeErrMsg(ErrMsg, path + : can't get status of file);
  return true;
 -  if (!Status-isDir) {
 -MakeErrMsg(ErrMsg, path + : not a directory);
 +  }
 +
 +  if (!(fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY)) {
 +if (ErrMsg)
 +  *ErrMsg = path + : not a directory;
  return true;
}
  
 @@ -565,28 +569,11 @@
  
  bool
  Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
 -  const FileStatus *Status = getFileStatus(false, ErrStr);
 -  if (!Status)
 -return false;
 +  WIN32_FILE_ATTRIBUTE_DATA fi;
 +  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
 +return true;
  
 -  if (Status-isFile) {
 -DWORD attr = GetFileAttributes(path.c_str());
 -
 -// If it doesn't exist, we're done.
 -if (attr == INVALID_FILE_ATTRIBUTES)
 -  return false;
 -
 -// Read-only files cannot be deleted on Windows.  Must remove the 
 read-only
 -// attribute first.
 -if (attr  FILE_ATTRIBUTE_READONLY) {
 -  if (!SetFileAttributes(path.c_str(), attr  ~FILE_ATTRIBUTE_READONLY))
 -return MakeErrMsg(ErrStr, path + : Can't destroy file: );
 -}
 -
 -if (!DeleteFile(path.c_str()))
 -  return MakeErrMsg(ErrStr, path + : Can't destroy file: );
 -return false;
 -  } else if (Status-isDir) {
 +  if (fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY) {
  // If it doesn't exist, we're done.
  if (!exists())
return false;
 @@ -645,9 +632,19 @@
return MakeErrMsg(ErrStr, 
  std::string(pathname) + : Can't destroy directory: );
  return false;
 -  } 
 -  // It appears the path doesn't exist.
 -  return true;
 +  } else {
 +// Read-only files cannot be deleted on Windows.  Must remove the 
 read-only
 +// attribute first.
 +if (fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY) {
 +  if (!SetFileAttributes(path.c_str(),
 + fi.dwFileAttributes  ~FILE_ATTRIBUTE_READONLY))
 +return MakeErrMsg(ErrStr, path + : Can't destroy file: );
 +}
 +
 +if (!DeleteFile(path.c_str()))
 +  return MakeErrMsg(ErrStr, path + : Can't destroy file: );
 +return false;
 +  }
  }
  
  bool Path::getMagicNumber(std::string Magic, unsigned len) const {
 
 
 Index: llvm/lib/System/Win32/Signals.inc
 diff -u llvm/lib/System/Win32/Signals.inc:1.23 
 llvm/lib/System/Win32/Signals.inc:1.24
 --- llvm/lib/System/Win32/Signals.inc:1.23Thu Mar 29 14:05:44 2007
 +++ llvm/lib/System/Win32/Signals.inc Sat Apr  7 15:47:27 2007
 @@ -101,12 +101,15 @@
  // RemoveDirectoryOnSignal - The public API
  bool sys::RemoveDirectoryOnSignal(const sys::Path path, std::string* 
 ErrMsg) {
// Not a directory?
 -  const sys::FileStatus *Status =  path.getFileStatus(false, ErrMsg);
 -  if (!Status)
 +  WIN32_FILE_ATTRIBUTE_DATA fi;
 +  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi)) {
 +MakeErrMsg(ErrMsg, path.toString() + : can't get status of file);
  return true;
 -  if (!Status-isDir) {
 +  }
 +
 +  if (!(fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY)) {
  if (ErrMsg)
 -  *ErrMsg = path.toString() +  is not a directory;
 +  *ErrMsg = path.toString() + : not a directory;
  return true;
}
  
 
 
 
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-03-29 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.59 - 1.60
---
Log message:

For PR789: http://llvm.org/PR789 :
* Add a method: bool isAbsolute() const, which determines if the path name
  is absolute or not.
* Implement caching of file status information in the Path object. Allow it
  to be updated forcefully or lazily re-fetched from the cached value.


---
Diffs of the changes:  (+29 -16)

 Path.inc |   45 +
 1 files changed, 29 insertions(+), 16 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.59 llvm/lib/System/Win32/Path.inc:1.60
--- llvm/lib/System/Win32/Path.inc:1.59 Sun Nov  5 13:31:28 2006
+++ llvm/lib/System/Win32/Path.inc  Thu Mar 29 11:43:20 2007
@@ -105,6 +105,13 @@
   return true;
 }
 
+bool 
+Path::isAbsolute() const {
+  if (path.length()  3)
+return false;
+  return path[0] == 'C'  path[1] == ':'  path[2] == '\\';
+} 
+
 static Path *TempDirectory = NULL;
 
 Path
@@ -294,24 +301,30 @@
 }
 
 bool
-Path::getFileStatus(FileStatus info, std::string *ErrStr) const {
-  WIN32_FILE_ATTRIBUTE_DATA fi;
-  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
-return MakeErrMsg(ErrStr, getStatusInfo(): + std::string(path) +
-: Can't get status: );
-
-  info.fileSize = fi.nFileSizeHigh;
-  info.fileSize = sizeof(fi.nFileSizeHigh)*8;
-  info.fileSize += fi.nFileSizeLow;
-
-  info.mode = fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
-  info.user = ;// Not applicable to Windows, so...
-  info.group = ;   // Not applicable to Windows, so...
+Path::getFileStatus(FileStatus info, bool update, std::string *ErrStr) const {
+  if (status == 0 || update) {
+WIN32_FILE_ATTRIBUTE_DATA fi;
+if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
+  return MakeErrMsg(ErrStr, getStatusInfo(): + std::string(path) +
+  : Can't get status: );
+
+if (status == 0)
+  status = new FileStatus;
+
+status-fileSize = fi.nFileSizeHigh;
+status-fileSize = sizeof(fi.nFileSizeHigh)*8;
+status-fileSize += fi.nFileSizeLow;
+
+status-mode = fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
+status-user = ;// Not applicable to Windows, so...
+status-group = ;   // Not applicable to Windows, so...
 
-  __int64 ft = *reinterpret_cast__int64*(fi.ftLastWriteTime);
-  info.modTime.fromWin32Time(ft);
+__int64 ft = *reinterpret_cast__int64*(fi.ftLastWriteTime);
+status-modTime.fromWin32Time(ft);
 
-  info.isDir = fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
+status-isDir = fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
+  }
+  info = *status;
   return false;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-03-29 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.60 - 1.61
---
Log message:

Add a uniqueID field to the FileStatus structure for Paths. This will map
to the inode number on Unix and something far less unique on Windows. The
windows case needs to be improved.


---
Diffs of the changes:  (+7 -0)

 Path.inc |7 +++
 1 files changed, 7 insertions(+)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.60 llvm/lib/System/Win32/Path.inc:1.61
--- llvm/lib/System/Win32/Path.inc:1.60 Thu Mar 29 11:43:20 2007
+++ llvm/lib/System/Win32/Path.inc  Thu Mar 29 12:00:31 2007
@@ -319,6 +319,13 @@
 status-user = ;// Not applicable to Windows, so...
 status-group = ;   // Not applicable to Windows, so...
 
+// FIXME: this is only unique if the file is accessed by the same file 
path.
+// How do we do this for C:\dir\file and ..\dir\file ? Unix has inode
+// numbers, but the concept doesn't exist in Windows.
+status-uniqueID = 0;
+for (unsigned i = 0; i  path.length(); ++i)
+  status-uniqueID += path[i];
+
 __int64 ft = *reinterpret_cast__int64*(fi.ftLastWriteTime);
 status-modTime.fromWin32Time(ft);
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-03-29 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.61 - 1.62
---
Log message:

Determine absolute paths the correct way :)

---
Diffs of the changes:  (+9 -3)

 Path.inc |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.61 llvm/lib/System/Win32/Path.inc:1.62
--- llvm/lib/System/Win32/Path.inc:1.61 Thu Mar 29 12:00:31 2007
+++ llvm/lib/System/Win32/Path.inc  Thu Mar 29 12:27:38 2007
@@ -107,9 +107,15 @@
 
 bool 
 Path::isAbsolute() const {
-  if (path.length()  3)
-return false;
-  return path[0] == 'C'  path[1] == ':'  path[2] == '\\';
+  switch (path.length()) {
+case 0:
+  return false;
+case 1:
+case 2:
+  return path[0] == '/';
+default:
+  return path[0] == '/' || (path[1] == ':'  path[2] == '/');
+  }
 } 
 
 static Path *TempDirectory = NULL;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/System/Win32/Path.inc Signals.inc

2007-03-29 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.62 - 1.63
Signals.inc updated: 1.22 - 1.23
---
Log message:

For PR789: http://llvm.org/PR789 :
Make the sys::Path::getFileStatus function more efficient by having it
return a pointer to the FileStatus structure rather than copy it. Adjust
uses of the function accordingly. Also, fix some memory issues in sys::Path.


---
Diffs of the changes:  (+18 -16)

 Path.inc|   28 ++--
 Signals.inc |6 --
 2 files changed, 18 insertions(+), 16 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.62 llvm/lib/System/Win32/Path.inc:1.63
--- llvm/lib/System/Win32/Path.inc:1.62 Thu Mar 29 12:27:38 2007
+++ llvm/lib/System/Win32/Path.inc  Thu Mar 29 14:05:44 2007
@@ -306,13 +306,15 @@
   return path.substr(pos+1);
 }
 
-bool
-Path::getFileStatus(FileStatus info, bool update, std::string *ErrStr) const {
+const FileStatus *
+Path::getFileStatus(bool update, std::string *ErrStr) const {
   if (status == 0 || update) {
 WIN32_FILE_ATTRIBUTE_DATA fi;
-if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
-  return MakeErrMsg(ErrStr, getStatusInfo(): + std::string(path) +
+if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi)) {
+  MakeErrMsg(ErrStr, getStatusInfo(): + std::string(path) +
   : Can't get status: );
+  return 0;
+}
 
 if (status == 0)
   status = new FileStatus;
@@ -337,8 +339,7 @@
 
 status-isDir = fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
   }
-  info = *status;
-  return false;
+  return status;
 }
 
 bool Path::makeReadableOnDisk(std::string* ErrMsg) {
@@ -369,11 +370,10 @@
 
 bool
 Path::getDirectoryContents(std::setPath result, std::string* ErrMsg) const {
-  FileStatus Status;
-  if (getFileStatus(Status, ErrMsg))
+  const FileStatus *Status = getFileStatus(false, ErrMsg);
+  if (!Status)
 return true;
-
-  if (!Status.isDir) {
+  if (!Status-isDir) {
 MakeErrMsg(ErrMsg, path + : not a directory);
 return true;
   }
@@ -567,11 +567,11 @@
 
 bool
 Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
-  FileStatus Status;
-  if (getFileStatus(Status, ErrStr))
+  const FileStatus *Status = getFileStatus(false, ErrStr);
+  if (!Status)
 return false;
 
-  if (Status.isFile) {
+  if (Status-isFile) {
 DWORD attr = GetFileAttributes(path.c_str());
 
 // If it doesn't exist, we're done.
@@ -588,7 +588,7 @@
 if (!DeleteFile(path.c_str()))
   return MakeErrMsg(ErrStr, path + : Can't destroy file: );
 return false;
-  } else if (Status.isDir) {
+  } else if (Status-isDir) {
 // If it doesn't exist, we're done.
 if (!exists())
   return false;


Index: llvm/lib/System/Win32/Signals.inc
diff -u llvm/lib/System/Win32/Signals.inc:1.22 
llvm/lib/System/Win32/Signals.inc:1.23
--- llvm/lib/System/Win32/Signals.inc:1.22  Fri Aug 25 16:37:17 2006
+++ llvm/lib/System/Win32/Signals.inc   Thu Mar 29 14:05:44 2007
@@ -101,8 +101,10 @@
 // RemoveDirectoryOnSignal - The public API
 bool sys::RemoveDirectoryOnSignal(const sys::Path path, std::string* ErrMsg) {
   // Not a directory?
-  sys::FileStatus Status;
-  if (path.getFileStatus(Status) || !Status.isDir) {
+  const sys::FileStatus *Status =  path.getFileStatus(false, ErrMsg);
+  if (!Status)
+return true;
+  if (!Status-isDir) {
 if (ErrMsg)
   *ErrMsg = path.toString() +  is not a directory;
 return true;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-11-05 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.58 - 1.59
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+5 -0)

 Path.inc |5 +
 1 files changed, 5 insertions(+)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.58 llvm/lib/System/Win32/Path.inc:1.59
--- llvm/lib/System/Win32/Path.inc:1.58 Fri Sep  1 15:35:17 2006
+++ llvm/lib/System/Win32/Path.inc  Sun Nov  5 13:31:28 2006
@@ -124,7 +124,12 @@
 
   // Append a subdirectory passed on our process id so multiple LLVMs don't
   // step on each other's toes.
+#ifdef __MINGW32__
+  // Mingw's Win32 header files are broken.
   sprintf(pathname, LLVM_%u, unsigned(GetCurrentProcessId()));
+#else
+  sprintf(pathname, LLVM_%u, GetCurrentProcessId());
+#endif
   result.appendComponent(pathname);
 
   // If there's a directory left over from a previous LLVM execution that



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-24 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.55 - 1.56
---
Log message:

For PR797: http://llvm.org/PR797 :
Adjust implementation to match the new interface after exception handling
was removed in the Unix verison. NOTE: this hasn't been compiled yet!


---
Diffs of the changes:  (+37 -42)

 Path.inc |   79 +--
 1 files changed, 37 insertions(+), 42 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.55 llvm/lib/System/Win32/Path.inc:1.56
--- llvm/lib/System/Win32/Path.inc:1.55 Wed Aug 23 02:30:48 2006
+++ llvm/lib/System/Win32/Path.inc  Thu Aug 24 13:58:37 2006
@@ -310,22 +310,6 @@
   return false;
 }
 
-static bool AddPermissionBits(const std::string Filename, int bits) {
-  DWORD attr = GetFileAttributes(Filename.c_str());
-
-  // If it doesn't exist, we're done.
-  if (attr == INVALID_FILE_ATTRIBUTES)
-return false;
-
-  // The best we can do to interpret Unix permission bits is to use
-  // the owner writable bit.
-  if ((attr  FILE_ATTRIBUTE_READONLY)  (bits  0200)) {
-if (!SetFileAttributes(Filename.c_str(), attr  ~FILE_ATTRIBUTE_READONLY))
-  ThrowError(Filename + : SetFileAttributes: );
-  }
-  return true;
-}
-
 bool Path::makeReadableOnDisk(std::string* ErrMsg) {
   // All files are readable on Windows (ignoring security attributes).
   return false;
@@ -469,8 +453,14 @@
   return false;
 }
 
+inline bool PathMsg(std::string* ErrMsg, const char* pathname, const char*msg) 
{
+  if (ErrMsg)
+*ErrMsg = std::string(pathname) + :  + std::string(msg);
+  return true;
+}
+
 bool
-Path::createDirectoryOnDisk(bool create_parents) {
+Path::createDirectoryOnDisk(bool create_parents, std::string* ErrMsg) {
   // Get a writeable copy of the path name
   size_t len = path.length();
   char *pathname = reinterpret_castchar *(_alloca(len+2));
@@ -489,14 +479,17 @@
 // Skip host name.
 next = strchr(pathname+2, '/');
 if (next == NULL)
-  throw std::string(pathname) + : badly formed remote directory;
+  return PathMsg(ErrMsg, pathname, badly formed remote directory);
+
 // Skip share name.
 next = strchr(next+1, '/');
 if (next == NULL)
-  throw std::string(pathname) + : badly formed remote directory;
+  return PathMsg(ErrMsg, pathname,badly formed remote directory);
+
 next++;
 if (*next == 0)
-  throw std::string(pathname) + : badly formed remote directory;
+  return PathMsg(ErrMsg, pathname, badly formed remote directory);
+
   } else {
 if (pathname[1] == ':')
   next += 2;// skip drive letter
@@ -511,43 +504,44 @@
   next = strchr(next, '/');
   *next = 0;
   if (!CreateDirectory(pathname, NULL))
-  ThrowError(std::string(pathname) + : Can't create directory: );
+  return MakeErrMsg(ErrMsg, 
+std::string(pathname) + : Can't create directory: );
   *next++ = '/';
 }
   } else {
 // Drop trailing slash.
 pathname[len-1] = 0;
 if (!CreateDirectory(pathname, NULL)) {
-  ThrowError(std::string(pathname) + : Can't create directory: );
+  return MakeErrMsg(, std::string(pathname) + : Can't create directory: 
);
 }
   }
-  return true;
+  return false;
 }
 
 bool
-Path::createFileOnDisk() {
+Path::createFileOnDisk(std::string* ErrMsg) {
   // Create the file
   HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
 FILE_ATTRIBUTE_NORMAL, NULL);
   if (h == INVALID_HANDLE_VALUE)
-ThrowError(path + : Can't create file: );
+return MakeErrMsg(ErrMsg, path + : Can't create file: );
 
   CloseHandle(h);
-  return true;
+  return false;
 }
 
 bool
 Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
   FileStatus Status;
   if (getFileStatus(Status, ErrStr))
-return true;
+return false;
 
   if (Status.isFile) {
 DWORD attr = GetFileAttributes(path.c_str());
 
 // If it doesn't exist, we're done.
 if (attr == INVALID_FILE_ATTRIBUTES)
-  return true;
+  return false;
 
 // Read-only files cannot be deleted on Windows.  Must remove the read-only
 // attribute first.
@@ -557,7 +551,7 @@
 }
 
 if (!DeleteFile(path.c_str()))
-  ThrowError(path + : Can't destroy file: );
+  return MakeErrMsg(ErrStr, path + : Can't destroy file: );
 return false;
   } else if (Status.isDir) {
 // If it doesn't exist, we're done.
@@ -618,10 +612,9 @@
   return GetError(std::string(pathname) + : Can't destroy directory: ,
   ErrStr);
 return false;
-  } else {
-// It appears the path doesn't exist.
-return true;
-  }
+  } 
+  // It appears the path doesn't exist.
+  return true;
 }
 
 bool Path::getMagicNumber(std::string Magic, unsigned len) const {
@@ -710,19 +703,20 @@
   return false;
 }
 
-void
-CopyFile(const sys::Path Dest, const sys::Path Src) {
+bool
+CopyFile(const sys::Path Dest, const 

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

2006-08-23 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.53 - 1.54
---
Log message:

For PR797: http://llvm.org/PR797 :
Remove exception throwing from Path::getDirectoryContents and its users.


---
Diffs of the changes:  (+10 -6)

 Path.inc |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.53 llvm/lib/System/Win32/Path.inc:1.54
--- llvm/lib/System/Win32/Path.inc:1.53 Tue Aug 22 18:54:35 2006
+++ llvm/lib/System/Win32/Path.inc  Wed Aug 23 01:56:27 2006
@@ -353,9 +353,11 @@
 }
 
 bool
-Path::getDirectoryContents(std::setPath result) const {
-  if (!isDirectory())
-return false;
+Path::getDirectoryContents(std::setPath result, std::string* ErrMsg) const {
+  if (!isDirectory()) {
+MakeErrMsg(ErrMsg, path + : not a directory);
+return true;
+  }
 
   result.clear();
   WIN32_FIND_DATA fd;
@@ -369,7 +371,8 @@
   if (h == INVALID_HANDLE_VALUE) {
 if (GetLastError() == ERROR_FILE_NOT_FOUND)
   return true; // not really an error, now is it?
-ThrowError(path + : Can't read directory: );
+MakeErrMsg(ErrMsg, path + : Can't read directory: );
+return true;
   }
 
   do {
@@ -384,9 +387,10 @@
   FindClose(h);
   if (err != ERROR_NO_MORE_FILES) {
 SetLastError(err);
-ThrowError(path + : Can't read directory: );
+MakeErrMsg(ErrMsg, path + : Can't read directory: );
+return true;
   }
-  return true;
+  return false;
 }
 
 bool



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-23 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.54 - 1.55
Win32.h updated: 1.7 - 1.8
---
Log message:

For PR797: http://llvm.org/PR797 :
Eliminate exception throwing from Path::renamePathOnDisk and adjust its 
users correspondingly.


---
Diffs of the changes:  (+6 -5)

 Path.inc |6 +++---
 Win32.h  |5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.54 llvm/lib/System/Win32/Path.inc:1.55
--- llvm/lib/System/Win32/Path.inc:1.54 Wed Aug 23 01:56:27 2006
+++ llvm/lib/System/Win32/Path.inc  Wed Aug 23 02:30:48 2006
@@ -651,10 +651,10 @@
 }
 
 bool
-Path::renamePathOnDisk(const Path newName) {
+Path::renamePathOnDisk(const Path newName, std::string* ErrMsg) {
   if (!MoveFileEx(path.c_str(), newName.c_str(), MOVEFILE_REPLACE_EXISTING))
-ThrowError(Can't move ' + path +
-   ' to ' + newName.path + ': );
+return MakeErrMsg(ErrMsg, Can't move ' + path + ' to ' + newName.path 
++ ': );
   return true;
 }
 


Index: llvm/lib/System/Win32/Win32.h
diff -u llvm/lib/System/Win32/Win32.h:1.7 llvm/lib/System/Win32/Win32.h:1.8
--- llvm/lib/System/Win32/Win32.h:1.7   Mon Aug 21 01:02:44 2006
+++ llvm/lib/System/Win32/Win32.h   Wed Aug 23 02:30:48 2006
@@ -44,14 +44,15 @@
   throw s;
 }
 
-inline void MakeErrMsg(std::string* ErrMsg, const std::string prefix) {
+inline bool MakeErrMsg(std::string* ErrMsg, const std::string prefix) {
   if (!ErrMsg)
-return;
+return true;
   char *buffer = NULL;
   FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
   NULL, GetLastError(), 0, (LPSTR)buffer, 1, NULL);
   ErrMsg = prefix + buffer;
   LocalFree(buffer);
+  return true;
 }
 
 inline void ThrowErrno(const std::string prefix) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-22 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.51 - 1.52
---
Log message:

Update for changes in Path class interface for exception removal.


---
Diffs of the changes:  (+6 -16)

 Path.inc |   22 ++
 1 files changed, 6 insertions(+), 16 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.51 llvm/lib/System/Win32/Path.inc:1.52
--- llvm/lib/System/Win32/Path.inc:1.51 Tue Aug  1 13:16:02 2006
+++ llvm/lib/System/Win32/Path.inc  Tue Aug 22 17:46:39 2006
@@ -108,13 +108,16 @@
 static Path *TempDirectory = NULL;
 
 Path
-Path::GetTemporaryDirectory() {
+Path::GetTemporaryDirectory(std::string* ErrMsg) {
   if (TempDirectory)
 return *TempDirectory;
 
   char pathname[MAX_PATH];
-  if (!GetTempPath(MAX_PATH, pathname))
-throw std::string(Can't determine temporary directory);
+  if (!GetTempPath(MAX_PATH, pathname)) {
+if (ErrMsg)
+  *ErrMsg = Can't determine temporary directory;
+return Path();
+  }
 
   Path result;
   result.set(pathname);
@@ -134,19 +137,6 @@
   return *TempDirectory;
 }
 
-Path::Path(const std::string unverified_path)
-  : path(unverified_path)
-{
-  FlipBackSlashes(path);
-  if (unverified_path.empty())
-return;
-  if (this-isValid())
-return;
-  // oops, not valid.
-  path.clear();
-  throw std::string(unverified_path + : path is not valid);
-}
-
 // FIXME: the following set of functions don't map to Windows very well.
 Path
 Path::GetRootDirectory() {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-22 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.52 - 1.53
---
Log message:

For PR797: http://llvm.org/PR797 :
Adjust code to compensate for Path class interface change.


---
Diffs of the changes:  (+10 -5)

 Path.inc |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.52 llvm/lib/System/Win32/Path.inc:1.53
--- llvm/lib/System/Win32/Path.inc:1.52 Tue Aug 22 17:46:39 2006
+++ llvm/lib/System/Win32/Path.inc  Tue Aug 22 18:54:35 2006
@@ -326,11 +326,12 @@
   return true;
 }
 
-void Path::makeReadableOnDisk() {
+bool Path::makeReadableOnDisk(std::string* ErrMsg) {
   // All files are readable on Windows (ignoring security attributes).
+  return false;
 }
 
-void Path::makeWriteableOnDisk() {
+void Path::makeWriteableOnDisk(std::string* ErrMsg) {
   DWORD attr = GetFileAttributes(path.c_str());
 
   // If it doesn't exist, we're done.
@@ -338,13 +339,17 @@
 return;
 
   if (attr  FILE_ATTRIBUTE_READONLY) {
-if (!SetFileAttributes(path.c_str(), attr  ~FILE_ATTRIBUTE_READONLY))
-  ThrowError(std::string(path) + : Can't make file writable: );
+if (!SetFileAttributes(path.c_str(), attr  ~FILE_ATTRIBUTE_READONLY)) {
+  MakeErrMsg(ErrMsg, std::string(path) + : Can't make file writable: );
+  return true;
+}
   }
+  return false;
 }
 
-void Path::makeExecutableOnDisk() {
+bool Path::makeExecutableOnDisk(std::string* ErrMsg) {
   // All files are executable on Windows (ignoring security attributes).
+  return false;
 }
 
 bool



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-01 Thread Anton Korobeynikov


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.48 - 1.49
---
Log message:

Minor fix due to recent API changes


---
Diffs of the changes:  (+1 -1)

 Path.inc |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.48 llvm/lib/System/Win32/Path.inc:1.49
--- llvm/lib/System/Win32/Path.inc:1.48 Fri Jul 28 17:36:17 2006
+++ llvm/lib/System/Win32/Path.inc  Tue Aug  1 03:07:22 2006
@@ -334,7 +334,7 @@
 }
 
 bool
-Path::getStatusInfo(FileStatus info, std::string *ErrStr) const {
+Path::getFileStatus(FileStatus info, std::string *ErrStr) const {
   WIN32_FILE_ATTRIBUTE_DATA fi;
   if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
 return GetError(getStatusInfo(): + std::string(path) +



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-01 Thread Chris Lattner


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.49 - 1.50
---
Log message:

elimiante some syscalls


---
Diffs of the changes:  (+8 -8)

 Path.inc |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.49 llvm/lib/System/Win32/Path.inc:1.50
--- llvm/lib/System/Win32/Path.inc:1.49 Tue Aug  1 03:07:22 2006
+++ llvm/lib/System/Win32/Path.inc  Tue Aug  1 12:51:09 2006
@@ -281,8 +281,6 @@
 
 bool
 Path::isBytecodeFile() const {
-  if (!isFile())
-return false;
   std::string actualMagic;
   if (!getMagicNumber(actualMagic, 4))
 return false;
@@ -574,12 +572,16 @@
 
 bool
 Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
-  if (isFile()) {
+  FileStatus Status;
+  if (getFileStatus(Status, ErrStr))
+return true;
+
+  if (Status.isFile) {
 DWORD attr = GetFileAttributes(path.c_str());
 
 // If it doesn't exist, we're done.
 if (attr == INVALID_FILE_ATTRIBUTES)
-  return false;
+  return true;
 
 // Read-only files cannot be deleted on Windows.  Must remove the read-only
 // attribute first.
@@ -590,8 +592,8 @@
 
 if (!DeleteFile(path.c_str()))
   ThrowError(path + : Can't destroy file: );
-return true;
-  } else if (isDirectory()) {
+return false;
+  } else if (Status.isDir) {
 // If it doesn't exist, we're done.
 if (!exists())
   return false;
@@ -657,8 +659,6 @@
 }
 
 bool Path::getMagicNumber(std::string Magic, unsigned len) const {
-  if (!isFile())
-return false;
   assert(len  1024  Request for magic string too long);
   char* buf = (char*) alloca(1 + len);
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-08-01 Thread Chris Lattner


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.50 - 1.51
---
Log message:

Remove some now-dead methods.  Use getFileStatus instead.


---
Diffs of the changes:  (+0 -33)

 Path.inc |   33 -
 1 files changed, 33 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.50 llvm/lib/System/Win32/Path.inc:1.51
--- llvm/lib/System/Win32/Path.inc:1.50 Tue Aug  1 12:51:09 2006
+++ llvm/lib/System/Win32/Path.inc  Tue Aug  1 13:16:02 2006
@@ -216,39 +216,6 @@
 }
 // FIXME: the above set of functions don't map to Windows very well.
 
-bool
-Path::isFile() const {
-  WIN32_FILE_ATTRIBUTE_DATA fi;
-  BOOL rc = GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi);
-  if (rc)
-return !(fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY);
-  else if (GetLastError() != ERROR_FILE_NOT_FOUND) {
-ThrowError(isFile():  + std::string(path) + : Can't get status: );
-  }
-  return false;
-}
-
-bool
-Path::isDirectory() const {
-  WIN32_FILE_ATTRIBUTE_DATA fi;
-  BOOL rc = GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi);
-  if (rc)
-return fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
-  else if (GetLastError() != ERROR_FILE_NOT_FOUND)
-ThrowError(isDirectory():  + std::string(path) + : Can't get status: );
-  return false;
-}
-
-bool
-Path::isHidden() const {
-  WIN32_FILE_ATTRIBUTE_DATA fi;
-  BOOL rc = GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi);
-  if (rc)
-return fi.dwFileAttributes  FILE_ATTRIBUTE_HIDDEN;
-  else if (GetLastError() != ERROR_FILE_NOT_FOUND)
-ThrowError(isHidden():  + std::string(path) + : Can't get status: );
-  return false;
-}
 
 bool
 Path::isRootDirectory() const {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-07-28 Thread Chris Lattner


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.46 - 1.47
---
Log message:

Update win32 for Path::getStatusInfo


---
Diffs of the changes:  (+6 -4)

 Path.inc |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.46 llvm/lib/System/Win32/Path.inc:1.47
--- llvm/lib/System/Win32/Path.inc:1.46 Fri Jul 28 17:29:50 2006
+++ llvm/lib/System/Win32/Path.inc  Fri Jul 28 17:32:09 2006
@@ -333,11 +333,12 @@
   return path.substr(pos+1);
 }
 
-void
-Path::getStatusInfo(StatusInfo info) const {
+bool
+Path::getStatusInfo(FileStatus info, std::string *ErrStr) const {
   WIN32_FILE_ATTRIBUTE_DATA fi;
   if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi))
-ThrowError(getStatusInfo(): + std::string(path) + : Can't get status: 
);
+return GetError(getStatusInfo(): + std::string(path) +
+: Can't get status: , ErrStr);
 
   info.fileSize = fi.nFileSizeHigh;
   info.fileSize = sizeof(fi.nFileSizeHigh)*8;
@@ -351,6 +352,7 @@
   info.modTime.fromWin32Time(ft);
 
   info.isDir = fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
+  return false;
 }
 
 static bool AddPermissionBits(const std::string Filename, int bits) {
@@ -691,7 +693,7 @@
 }
 
 bool
-Path::setStatusInfoOnDisk(const StatusInfo si) const {
+Path::setStatusInfoOnDisk(const FileStatus si) const {
   // FIXME: should work on directories also.
   if (!isFile()) return false;
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-07-28 Thread Chris Lattner


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.47 - 1.48
---
Log message:

Modify setStatusInfoOnDisk to not throw an exception.


---
Diffs of the changes:  (+8 -8)

 Path.inc |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.47 llvm/lib/System/Win32/Path.inc:1.48
--- llvm/lib/System/Win32/Path.inc:1.47 Fri Jul 28 17:32:09 2006
+++ llvm/lib/System/Win32/Path.inc  Fri Jul 28 17:36:17 2006
@@ -693,9 +693,9 @@
 }
 
 bool
-Path::setStatusInfoOnDisk(const FileStatus si) const {
+Path::setStatusInfoOnDisk(const FileStatus si, std::string *ErrStr) const {
   // FIXME: should work on directories also.
-  if (!isFile()) return false;
+  if (!isFile()) return true;
 
   HANDLE h = CreateFile(path.c_str(),
 FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES,
@@ -705,14 +705,14 @@
 FILE_ATTRIBUTE_NORMAL,
 NULL);
   if (h == INVALID_HANDLE_VALUE)
-return false;
+return true;
 
   BY_HANDLE_FILE_INFORMATION bhfi;
   if (!GetFileInformationByHandle(h, bhfi)) {
 DWORD err = GetLastError();
 CloseHandle(h);
 SetLastError(err);
-ThrowError(path + : GetFileInformationByHandle: );
+return GetError(path + : GetFileInformationByHandle: , ErrStr);
   }
 
   FILETIME ft;
@@ -722,7 +722,7 @@
   CloseHandle(h);
   if (!ret) {
 SetLastError(err);
-ThrowError(path + : SetFileTime: );
+return GetError(path + : SetFileTime: , ErrStr);
   }
 
   // Best we can do with Unix permission bits is to interpret the owner
@@ -731,17 +731,17 @@
 if (bhfi.dwFileAttributes  FILE_ATTRIBUTE_READONLY) {
   if (!SetFileAttributes(path.c_str(),
   bhfi.dwFileAttributes  ~FILE_ATTRIBUTE_READONLY))
-ThrowError(path + : SetFileAttributes: );
+return GetError(path + : SetFileAttributes: , ErrStr);
 }
   } else {
 if (!(bhfi.dwFileAttributes  FILE_ATTRIBUTE_READONLY)) {
   if (!SetFileAttributes(path.c_str(),
   bhfi.dwFileAttributes | FILE_ATTRIBUTE_READONLY))
-ThrowError(path + : SetFileAttributes: );
+return GetError(path + : SetFileAttributes: , ErrStr);
 }
   }
 
-  return true;
+  return false;
 }
 
 void



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-06-08 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.43 - 1.44
---
Log message:

For PR804: http://llvm.org/PR804 :
Change the file size field of StatusInfo to be uint64_t instead of size_t
so that we know it is always 64 bits. This prevents some overflow on
systems where size_t is 32 bits when it ought to be 64.


---
Diffs of the changes:  (+1 -1)

 Path.inc |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.43 llvm/lib/System/Win32/Path.inc:1.44
--- llvm/lib/System/Win32/Path.inc:1.43 Mon Jun  5 10:44:46 2006
+++ llvm/lib/System/Win32/Path.inc  Thu Jun  8 12:00:08 2006
@@ -340,7 +340,7 @@
 ThrowError(getStatusInfo(): + std::string(path) + : Can't get status: 
);
 
   info.fileSize = fi.nFileSizeHigh;
-  info.fileSize = 32;
+  info.fileSize = sizeof(fi.nFileSizeHigh)*8;
   info.fileSize += fi.nFileSizeLow;
 
   info.mode = fi.dwFileAttributes  FILE_ATTRIBUTE_READONLY ? 0555 : 0777;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-06-05 Thread Reid Spencer


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.42 - 1.43
---
Log message:

For PR798: http://llvm.cs.uiuc.edu/PR798 :
Add support for Graphviz. Patch contributed by Anton Korobeynikov.


---
Diffs of the changes:  (+8 -7)

 Path.inc |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.42 llvm/lib/System/Win32/Path.inc:1.43
--- llvm/lib/System/Win32/Path.inc:1.42 Sat May  6 21:51:51 2006
+++ llvm/lib/System/Win32/Path.inc  Mon Jun  5 10:44:46 2006
@@ -222,8 +222,9 @@
   BOOL rc = GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi);
   if (rc)
 return !(fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY);
-  else if (GetLastError() != ERROR_NOT_FOUND)
-ThrowError(std::string(path) + : Can't get status: );
+  else if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ThrowError(isFile():  + std::string(path) + : Can't get status: );
+  }
   return false;
 }
 
@@ -233,8 +234,8 @@
   BOOL rc = GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi);
   if (rc)
 return fi.dwFileAttributes  FILE_ATTRIBUTE_DIRECTORY;
-  else if (GetLastError() != ERROR_NOT_FOUND)
-ThrowError(std::string(path) + : Can't get status: );
+  else if (GetLastError() != ERROR_FILE_NOT_FOUND)
+ThrowError(isDirectory():  + std::string(path) + : Can't get status: );
   return false;
 }
 
@@ -244,8 +245,8 @@
   BOOL rc = GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, fi);
   if (rc)
 return fi.dwFileAttributes  FILE_ATTRIBUTE_HIDDEN;
-  else if (GetLastError() != ERROR_NOT_FOUND)
-ThrowError(std::string(path) + : Can't get status: );
+  else if (GetLastError() != ERROR_FILE_NOT_FOUND)
+ThrowError(isHidden():  + std::string(path) + : Can't get status: );
   return false;
 }
 
@@ -336,7 +337,7 @@
 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: );
+ThrowError(getStatusInfo(): + std::string(path) + : Can't get status: 
);
 
   info.fileSize = fi.nFileSizeHigh;
   info.fileSize = 32;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-05-06 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.41 - 1.42
---
Log message:

Unlike Unix, Windows won't let a file be implicitly replaced via renaming 
without explicit permission.

---
Diffs of the changes:  (+1 -1)

 Path.inc |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.41 llvm/lib/System/Win32/Path.inc:1.42
--- llvm/lib/System/Win32/Path.inc:1.41 Sat Apr 29 13:41:44 2006
+++ llvm/lib/System/Win32/Path.inc  Sat May  6 21:51:51 2006
@@ -682,7 +682,7 @@
 
 bool
 Path::renamePathOnDisk(const Path newName) {
-  if (!MoveFile(path.c_str(), newName.c_str()))
+  if (!MoveFileEx(path.c_str(), newName.c_str(), MOVEFILE_REPLACE_EXISTING))
 ThrowError(Can't move ' + path +
' to ' + newName.path + ': );
   return true;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-04-29 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.40 - 1.41
---
Log message:

Mingw32 patches supplied by Anton Korobeynikov.

---
Diffs of the changes:  (+1 -1)

 Path.inc |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.40 llvm/lib/System/Win32/Path.inc:1.41
--- llvm/lib/System/Win32/Path.inc:1.40 Sat Jul  9 13:42:49 2005
+++ llvm/lib/System/Win32/Path.inc  Sat Apr 29 13:41:44 2006
@@ -741,7 +741,7 @@
 }
 
 void
-sys::CopyFile(const sys::Path Dest, const sys::Path Src) {
+CopyFile(const sys::Path Dest, const sys::Path Src) {
   // 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))



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits