gap-dev-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gap-dev-discuss] Zipper and 7zip


From: Sebastian Reitenbach
Subject: Re: [Gap-dev-discuss] Zipper and 7zip
Date: Tue, 10 Jul 2012 17:33:27 +0200
User-agent: SOGoMail 1.3.16

 
On Monday, July 9, 2012 17:36 CEST, "Sebastian Reitenbach" <address@hidden> 
wrote: 
 
>  
> On Thursday, July 5, 2012 20:49 CEST, Riccardo Mottola <address@hidden> 
> wrote: 
>  
> > Hi,
> > 
> > does extracting 7zip archives work for you? Today I tried the first time.
> > 
> > I use p7zip and use the excutable "7z".
> > 
> > All files show in the Zipper window correctly.
> > 
> > I have a (fairly big, so i can't share it with you) archive which has 
> > two directories full of files. If I extract it using "Extract" I get 
> > "Skipped" for most files and then I end up with only one directory 
> > containing only one file....
> > 
> > if I use "7z X filename.7z" I get everything perfect, so the archive is 
> > fine.
> 
> I can reproduce that. And I think I found a reason for it. When opening
> the 7z file, then the last file in the archive is marked. 
> So its only extracting files that are marked. So far, I think that is fine.
> When going to extract,
> it will skip all files but the last file. I added a NSLog statement to figure 
> that out:
> 
> 
> 2012-07-09 17:23:19.714 Zipper[24180] run 7z: (x, "-y", "-o/tmp", 
> "/tmp/yay.7z", "ModelRailroad/Rocrail/rocview/icons/zoomout.png")
> 
> The zoomout.png file is the last one in the archive.
> When you mark a couple of files, then it will extract all of the marked files.
> 
> But I found a different, or more exactly, two bugs in it:
> 
> I have a file in the archive called:
> 'ModelRailroad/Rocrail/rocview/svg/themes/DB/signaldistant -2.svg'
> This one shows up in the list as just:
> -2.svg
> 
> so the first bug is that the output parser of the 7zip doesn't quite well 
> handle spaces in file names.
> 
> the second bug then shows up when trying to extract that, I get:
> 
> 
> 2012-07-09 17:32:18.371 Zipper[24180] run 7z: (x, "-y", "-o/tmp", 
> "/tmp/yay.7z", "-2.svg")
> 
> 
> Error:
> Incorrect command line
> 
> So, it just hands over the -2.svg to the7z binary, which thinks it might be 
> an option, which it isnt.
> So it should somehow escape the file names.

For the second part, see below the diff. All archive types seem to suffer from 
the problem. So far, 
I tested with .tar.gz, .lha, .7z archives, having names starting with a -, and 
containing files starting with a -.
I'd apprechiate more tests and feedback, especially with archive types I have 
not yet tested.

Sebastian

$OpenBSD$
--- GzipArchive.m.orig  Tue Jul 10 16:49:26 2012
+++ GzipArchive.m       Tue Jul 10 16:51:36 2012
@@ -59,7 +59,7 @@
        [[NSFileManager defaultManager] copyPath:[self path] toPath:destPath 
handler:nil];
        
        // extract it
-       arguments = [NSArray arrayWithObjects:@"-d", destPath, nil];
+       arguments = [NSArray arrayWithObjects:@"-d", destPath, @"--", nil];
        
        return [self runUnarchiverWithArguments:arguments];
 }
$OpenBSD$
--- LhaArchive.m.orig   Tue Jan 22 01:38:07 2008
+++ LhaArchive.m        Tue Jul 10 17:04:38 2012
@@ -57,6 +57,10 @@
 
        args = [NSMutableArray array];
        [args addObject:argString];
+
+       // protect against archives and files starting with -
+       [args addObject:@"--"];
+
        [args addObject:[self path]];
        
        if (files != nil)
@@ -128,9 +132,8 @@
 - (NSData *)dataByRunningLha
 {
        NSData *data;
-       NSArray *args = [NSArray arrayWithObjects:@"v", [self path], nil];
+       NSArray *args = [NSArray arrayWithObjects:@"v", @"--", [self path], 
nil];
        data = [self dataByRunningUnachiverWithArguments:args];
-       NSLog(@"dataByRunningLha: %@", data);
        return data;
 }
 
$OpenBSD$
--- LzxArchive.m.orig   Tue Jul 10 16:52:39 2012
+++ LzxArchive.m        Tue Jul 10 16:53:21 2012
@@ -56,7 +56,7 @@
 {
        NSArray *args;
                
-       args = [NSArray arrayWithObjects:@"-x", [self path], nil];
+       args = [NSArray arrayWithObjects:@"-x", @"--", [self path], nil];
        return [[self class] runUnarchiverWithArguments:args inDirectory:path];
 }
 
@@ -123,7 +123,7 @@
 {
        NSData *data;
        
-       NSArray *args = [NSArray arrayWithObjects:@"-v", [self path], nil];
+       NSArray *args = [NSArray arrayWithObjects:@"-v", @"--", [self path], 
nil];
        data = [self dataByRunningUnachiverWithArguments:args];
        return data;
 }
$OpenBSD$
--- RarArchive.m.orig   Tue Jul 10 16:36:37 2012
+++ RarArchive.m        Tue Jul 10 16:47:56 2012
@@ -65,6 +65,10 @@ static NSData *_magicBytes;
        {
                [args addObject:@"e"];
        }
+
+       // protect against archives and files starting with -
+       [args addObject:@"--"];
+
        [args addObject:[self path]];
        
        if (files != nil)
@@ -144,7 +148,7 @@ static NSData *_magicBytes;
        // v    view contents of archive
        // -c-  suppress archive comment
 
-       NSArray *args = [NSArray arrayWithObjects:@"v", @"-c-", [self path], 
nil];
+       NSArray *args = [NSArray arrayWithObjects:@"v", @"-c-", @"--", [self 
path], nil];
        return [self dataByRunningUnachiverWithArguments:args];
 }
 
$OpenBSD$
--- SevenZipArchive.m.orig      Mon Feb 20 09:27:39 2012
+++ SevenZipArchive.m   Tue Jul 10 16:46:36 2012
@@ -62,6 +62,9 @@
        // destination dir, path must not be separated with blank from the 'o' 
option
        [args addObject:[@"-o" stringByAppendingString:path]];
 
+       // protect for archives and files starting with -
+       [args addObject:@"--"]; 
+
        // add archive filename 
        [args addObject:[self path]];   
 
@@ -144,7 +147,7 @@
 - (NSData *)dataByRunningSevenZip
 {
        // l = list
-       NSArray *args = [NSArray arrayWithObjects:@"l", [self path], nil];
+       NSArray *args = [NSArray arrayWithObjects:@"l", @"--", [self path], 
nil];
        return [self dataByRunningUnachiverWithArguments:args];
 }
 
$OpenBSD$
--- TarArchive.m.orig   Fri Apr 20 17:41:34 2012
+++ TarArchive.m        Tue Jul 10 17:22:44 2012
@@ -70,6 +70,9 @@
        [args addObject:@"-C"];
        [args addObject:path];
        
+       // protect against files starting with -
+       [args addObject:@"--"];
+       
        if (files != nil)
        {
                NSEnumerator *cursor = [files objectEnumerator];
$OpenBSD$
--- ZipArchive.m.orig   Tue Jul 10 16:41:58 2012
+++ ZipArchive.m        Tue Jul 10 16:44:17 2012
@@ -92,6 +92,14 @@ static NSData *_magicBytes = nil;
                // junk paths
                [args addObject:@"-j"];
        }
+
+       // destination dir
+       [args addObject:@"-d"];
+       [args addObject:path];
+       
+       // protect against archives and files starting with -
+       [args addObject:@"--"];
+
        [args addObject:[self path]];   
        
        if (files != nil)
@@ -103,10 +111,6 @@ static NSData *_magicBytes = nil;
                }
        }
        
-       // destination dir
-       [args addObject:@"-d"];
-       [args addObject:path];
-       
        return [self runUnarchiverWithArguments:args];
 }
 
@@ -185,7 +189,7 @@ static NSData *_magicBytes = nil;
        // v = display all zip infos (Ratio etc.)
        // qq = quiet, this is important for skipping comments in archives and 
for skipping
        //      the nice headers for readable output
-       NSArray *args = [NSArray arrayWithObjects:@"-lvqq", [self path], nil];
+       NSArray *args = [NSArray arrayWithObjects:@"-lvqq", @"--", [self path], 
nil];
        return [self dataByRunningUnachiverWithArguments:args];
 }
 




> 
> Then, I was unable to use Alt-A or Ctrl-A to mark all files in the archive.
> This I think is not really a bug, but a usability annoyance.
> 
> Looking into it now.
> 
> Sebastian
> 
> > 
> > Perhaps there is an engine problem I already fixed for tar when 
> > extracting files which passed the archives name wrong? But before I want 
> > to know how you guys fare.
> > 
> > Riccardo
> > 
>  
>  
>  
>  
> 
 
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]