Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

gh-2147 - eclcc regression reading plugins path

There are some inconsistencies in how makeAbsolutePath treats trailing pathsep
chars, which led to the refactoring of eclcc's file handling not always behaving
correctly.

For consistency with the realpath() function, makeAbsolutePath will now ALWAYS
return strings WITHOUT a trailing directory path.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
  • Loading branch information...
commit 074b393951c13c99411982eedc58cca8074cee27 1 parent 4ec2962
Richard Chapman authored April 23, 2012
2  ecl/hql/hqlcollect.cpp
@@ -456,7 +456,7 @@ void FileSystemEclCollection::processFilePath(IErrorReceiver * errs, const char
456 456
         makeAbsolutePath(dirPath.str(), absolutePath);
457 457
         if (!containsFileWildcard(dirTail))
458 458
         {
459  
-            absolutePath.append(dirTail);
  459
+            addPathSepChar(absolutePath).append(dirTail);
460 460
             Owned<IFile> file = createIFile(absolutePath);
461 461
             if (file->isDirectory() == foundYes)
462 462
             {
12  system/jlib/jfile.cpp
@@ -4900,10 +4900,9 @@ StringBuffer &makeAbsolutePath(const char *relpath,StringBuffer &out, bool mustE
4900 4900
     else
4901 4901
     {
4902 4902
         // no error, will attempt to resolve(realpath) as much of relpath as possible and append rest
4903  
-        const char *end = relpath+strlen(relpath);
4904  
-        if ('/' == *end) --end;
4905  
-        if (end != relpath)
  4903
+        if (strlen(relpath))
4906 4904
         {
  4905
+            const char *end = relpath+strlen(relpath);
4907 4906
             const char *path = relpath;
4908 4907
             const char *tail = end;
4909 4908
             StringBuffer head;
@@ -4914,7 +4913,7 @@ StringBuffer &makeAbsolutePath(const char *relpath,StringBuffer &out, bool mustE
4914 4913
                     out.append(rPath);
4915 4914
                     if (tail != end)
4916 4915
                         out.append(tail);
4917  
-                    return out;
  4916
+                    return removeTrailingPathSepChar(out);
4918 4917
                 }
4919 4918
                 // mark next tail
4920 4919
                 loop
@@ -4936,11 +4935,12 @@ StringBuffer &makeAbsolutePath(const char *relpath,StringBuffer &out, bool mustE
4936 4935
         else
4937 4936
         {
4938 4937
             appendCurrentDirectory(out, true);
4939  
-            addPathSepChar(out).append(relpath);
  4938
+            if (strlen(relpath))
  4939
+                addPathSepChar(out).append(relpath);
4940 4940
         }
4941 4941
     }
4942 4942
 #endif
4943  
-    return out;
  4943
+    return removeTrailingPathSepChar(out);
4944 4944
 }
4945 4945
 
4946 4946
 StringBuffer &makeAbsolutePath(StringBuffer &relpath,bool mustExist)
14  system/jlib/jfile.hpp
@@ -492,6 +492,20 @@ inline StringBuffer &addPathSepChar(StringBuffer &path,char sepchar=0)
492 492
     return path;
493 493
 }
494 494
 
  495
+inline StringBuffer &removeTrailingPathSepChar(StringBuffer &path)
  496
+{
  497
+    if (path.length()>1 && isPathSepChar(path.charAt(path.length()-1)))
  498
+    {
  499
+#ifdef _WIN32
  500
+    // In addition to not removing \ if it's the only char in the path, you should not remove it the path
  501
+    // is of the form c:\
  502
+        if (path.length()>3 || path.charAt(1) != ':')
  503
+#endif
  504
+            path.remove(path.length()-1, 1);
  505
+    }
  506
+    return path;
  507
+}
  508
+
495 509
 inline StringBuffer &addNonEmptyPathSepChar(StringBuffer &path,char sepchar=0)
496 510
 {
497 511
     size32_t len = path.length();

0 notes on commit 074b393

Please sign in to comment.
Something went wrong with that request. Please try again.