~ubuntu-branches/ubuntu/trusty/zipper.app/trusty

« back to all changes in this revision

Viewing changes to ArchiveService.m

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2004-11-10 23:40:33 UTC
  • Revision ID: james.westby@ubuntu.com-20041110234033-v32mldso2yf8i7v4
Tags: upstream-0.9
Import upstream version 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#import <Foundation/Foundation.h>
 
2
#import <AppKit/AppKit.h>
 
3
#import "ArchiveService.h"
 
4
#import "TarArchive.h"
 
5
 
 
6
@interface ArchiveService (PrivateAPI)
 
7
- (void)createArchiveForFiles:(NSArray *)filenames;
 
8
@end
 
9
 
 
10
@implementation ArchiveService : NSObject
 
11
 
 
12
- (void)createZippedTarArchive:(NSPasteboard *)pboard userData:(NSString *)userData
 
13
        error:(NSString **)error;
 
14
{
 
15
        NSArray *types;
 
16
        id filenames;
 
17
        
 
18
        types = [pboard types];
 
19
        if ([types containsObject:NSFilenamesPboardType] == NO)
 
20
        {
 
21
                *error = @"We expect Filenames on the pasteboard!";
 
22
                return;
 
23
        }
 
24
        
 
25
        filenames = [pboard propertyListForType:NSFilenamesPboardType];
 
26
        if (filenames == nil)
 
27
        {
 
28
                *error = @"could not read filename off the pasteboard!";
 
29
                return;
 
30
        }
 
31
        
 
32
        [self createArchiveForFiles:filenames];
 
33
}
 
34
 
 
35
- (void)createArchiveForFiles:(NSArray *)filenames;
 
36
{
 
37
        int rc;
 
38
        
 
39
        NSSavePanel *panel = [NSSavePanel savePanel];
 
40
        [panel setTitle:@"Archive destination"];
 
41
        rc = [panel runModalForDirectory:NSHomeDirectory() file:nil];
 
42
        if (rc == NSOKButton)
 
43
        {
 
44
                NSString *archiveFile = [panel filename];
 
45
                // create the archive
 
46
                [TarArchive createArchive:archiveFile withFiles:filenames];
 
47
        }
 
48
}
 
49
 
 
50
@end