forked from murci/Simple-Comic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDTQuickComicCommon.m
54 lines (44 loc) · 1.47 KB
/
DTQuickComicCommon.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// DTQuickComicCommon.m
// QuickComic
//
// Created by Alexander Rauchfuss on 11/10/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import "DTQuickComicCommon.h"
#import "TSSTSortDescriptor.h"
#import <XADMaster/XADArchive.h>
static NSArray * fileNameSort = nil;
NSMutableArray * fileListForArchive(XADArchive * archive)
{
NSMutableArray * fileDescriptions = [NSMutableArray array];
NSDictionary * fileDescription;
int count = [archive numberOfEntries];
int index = 0;
NSString * fileName;
NSString * rawName;
for ( ; index < count; ++index)
{
fileName = [archive nameOfEntry: index];
XADString * dataString = [archive rawNameOfEntry: index];
rawName = [dataString stringWithEncoding: NSNonLossyASCIIStringEncoding];
if([[NSImage imageFileTypes] containsObject: [fileName pathExtension]])
{
fileDescription = [NSDictionary dictionaryWithObjectsAndKeys: fileName, @"name",
[NSNumber numberWithInt: index], @"index",
rawName, @"rawName", nil];
[fileDescriptions addObject: fileDescription];
}
}
return [[fileDescriptions retain] autorelease];
}
NSArray * fileSort(void)
{
if(!fileNameSort)
{
TSSTSortDescriptor * sort = [[TSSTSortDescriptor alloc] initWithKey: @"name" ascending: YES];
fileNameSort = [[NSArray alloc] initWithObjects: sort, nil];
[sort release];
}
return fileNameSort;
}