As I reported a while ago, GJ's manifest tools don't handle symbolic
links correctly.

I got a bit bored today, so I grabbed the source and tried to figure
out why.  It appears that the problem is the overzealous use of
getCanonicalPath(), which converts symlinks with relative pathnames
into absolute filenames pointing to wherever the symlink points.  (In
my case, "./blah.ogg" becomes "/mp3/blah/blah-blah.ogg".)

Here's a patch that seems to correct this.  I'm still testing it, but I
figured I'd expose this to public scrutiny so that you can all laugh at
me and get it over with.  In particular, I don't know whether my patch
breaks on Win32 systems (it leaves "foo/./bar" syntax in path names).
The patch is made against version 0.16b.

-- 
Greg Wooledge                  |   "Truth belongs to everybody."
[EMAIL PROTECTED]              |    - The Red Hot Chili Peppers
http://wooledge.org/~greg/     |
--- src/relentless/gj/cli/ManifestFile.java.orig        Sun May 20 16:09:30 2001
+++ src/relentless/gj/cli/ManifestFile.java     Sun May 20 20:33:05 2001
@@ -270,7 +270,7 @@
            }
            
            java.io.File file = new java.io.File(dir, records[i].getFileName());
-           String filePath = file.getCanonicalPath();
+           String filePath = file.getPath();
            int p = filePath.indexOf(dirPath);
            
            // 3) Resolved file name must be in root directory hierarchy.
@@ -718,7 +718,7 @@
                // Create manifest file entry.
                // REDFLAG: test.  suspect....
                String relativePath 
-                   = 
currentSegment.getCanonicalPath().substring(rootDirAsDir.getCanonicalPath().length() 
+                   = 
+currentSegment.getPath().substring(rootDirAsDir.getPath().length() 
                                                                  + 1);
                records[i] = new ManifestFileRecord("freenet:CHK@", relativePath, 
mimeType);
            }
@@ -927,8 +927,8 @@
      */
     public final static String getRelativeName(java.io.File dir, java.io.File file) 
        throws java.io.IOException {
-       String dirPath = dir.getCanonicalPath();
-       String filePath = file.getCanonicalPath();
+       String dirPath = dir.getPath();
+       String filePath = dirPath + "/" + file.getPath();
        int p = filePath.indexOf(dirPath);
        if ((p != 0) || (dirPath.length() >= filePath.length())) {
            System.err.println("dirPath: " + dirPath); 

PGP signature

Reply via email to