add a new static method to portably determine whether a patch is
authorChris Lattner <sabre@nondot.org>
Mon, 15 Jun 2009 04:17:07 +0000 (04:17 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Jun 2009 04:17:07 +0000 (04:17 +0000)
absolute or not, based on a patch by Gregory Curfman!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73368 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Path.h
lib/System/Unix/Path.inc
lib/System/Win32/Path.inc

index de2f173ae41751f4b6a6b6f600169cf2b92d219a..05be2212758b482917cbfba26d55b0d9610a308b 100644 (file)
@@ -309,6 +309,11 @@ namespace sys {
       /// @brief Determine if the path is absolute.
       bool isAbsolute() const;
 
+      /// This function determines if the path name is absolute, as opposed to
+      /// relative.
+      /// @brief Determine if the path is absolute.
+      static bool isAbsolute(const char *NameStart, unsigned NameLen);
+
       /// This function opens the file associated with the path name provided by
       /// the Path object and reads its magic number. If the magic number at the
       /// start of the file matches \p magic, true is returned. In all other
index d5edee1b03b3ec29a78a4857806b9bacb288aa34..1f73571cf140ba350d6efd80735d6169f774b6eb 100644 (file)
@@ -103,6 +103,14 @@ Path::isValid() const {
   return i >= len;
 }
 
+bool
+Path::isAbsolute(const char *NameStart, unsigned NameLen) {
+  assert(NameStart);
+  if (NameLen == 0)
+    return false;
+  return NameStart[0] == '/';
+}
+
 bool
 Path::isAbsolute() const {
   if (path.empty())
index fbf8f6688a57e413124255c05f562bf3110ff217..62da3a34c4501aba9078f48123914d71798fcce1 100644 (file)
@@ -125,6 +125,20 @@ Path::isValid() const {
   return true;
 }
 
+bool
+Path::isAbsolute(const char *NameStart, unsigned NameLen) {
+  assert(NameStart);
+  switch (NameLen) {
+  case 0:
+    return false;
+  case 1:
+  case 2:
+    return NameStart[0] == '/';
+  default:
+    return NameStart[0] == '/' || (NameStart[1] == ':' && NameStart[2] == '/');
+  }
+}
+
 bool 
 Path::isAbsolute() const {
   switch (path.length()) {