Skip to content

Commit fa11179

Browse files
author
Johannes Ekberg
committed
Fixes some Compiler Warnings and issues with unzipping transferred documents. Also switched from GCC to LLVM.
1 parent 4651351 commit fa11179

File tree

5 files changed

+87
-59
lines changed

5 files changed

+87
-59
lines changed

Model/Collection.m

+61-57
Original file line numberDiff line numberDiff line change
@@ -34,77 +34,81 @@ - (void)loadCollectionWithDelegate:(id<CollectionDelegate>)delegate
3434
novels = [[NSMutableArray alloc] init];
3535

3636
NSFileManager *fileManager = [[NSFileManager alloc] init];
37-
#if TARGET_IPHONE_SIMULATOR
38-
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
39-
#else
40-
NSString *resourcePath = [[NSBundle mainBundle] documentsPath];
41-
#endif
42-
NSArray *contents = [fileManager contentsOfDirectoryAtPath:resourcePath error:nil];
43-
for(NSString *filename in contents)
37+
38+
NSArray *paths = [[NSArray alloc] initWithObjects:[[NSBundle mainBundle] resourcePath], [[NSBundle mainBundle] documentsPath], nil];
39+
for(NSString *resourcePath in paths)
4440
{
45-
NSString *path = [resourcePath stringByAppendingPathComponent:filename];
46-
BOOL isDir = NO;
47-
48-
[fileManager fileExistsAtPath:path isDirectory:&isDir];
49-
50-
if(!isDir && [[path pathExtension] isEqualToString:@"zip"])
41+
NSArray *contents = [fileManager contentsOfDirectoryAtPath:resourcePath error:nil];
42+
for(NSString *filename in contents)
5143
{
52-
NSString *outPath = [resourcePath stringByAppendingPathComponent:
53-
[filename substringToIndex:[filename length]-4]]; //4 = length of ".zip"
54-
MTLog(@"Unzipping %@ to %@", path, outPath);
55-
[delegate collection:self willUnzipFile:filename];
44+
NSString *path = [resourcePath stringByAppendingPathComponent:filename];
45+
BOOL isDir = NO;
5646

57-
NSError *error = nil;
58-
[SSZipArchive unzipFileAtPath:path toDestination:outPath overwrite:YES password:nil error:&error];
59-
if(error) MTLog(@"Novel Unzip Error: %@", error);
60-
[fileManager removeItemAtPath:path error:NULL];
61-
[fileManager removeItemAtPath:[outPath stringByAppendingPathComponent:@"__MACOSX"] error:nil];
47+
[fileManager fileExistsAtPath:path isDirectory:&isDir];
6248

63-
if(!error && [fileManager fileExistsAtPath:[outPath stringByAppendingPathComponent:@"sound.zip"]])
49+
if(!isDir && [[path pathExtension] isEqualToString:@"zip"])
6450
{
65-
NSString *soundPath = [outPath stringByAppendingPathComponent:@"sound.zip"];
66-
NSString *soundOut = [outPath stringByAppendingPathComponent:@"sound"];
51+
NSString *outPath = [resourcePath stringByAppendingPathComponent:
52+
[filename substringToIndex:[filename length]-4]]; //4 = length of ".zip"
53+
MTLog(@"Unzipping %@ to %@", path, outPath);
54+
[delegate collection:self willUnzipFile:filename];
6755

68-
[delegate collection:self willReadSoundFromNovel:[outPath lastPathComponent]];
69-
[SSZipArchive unzipFileAtPath:soundPath
70-
toDestination:soundOut
71-
overwrite:YES password:nil error:&error];
72-
[fileManager removeItemAtPath:[outPath stringByAppendingPathComponent:@"sound.zip"] error:NULL];
73-
if(error) MTLog(@"Sound Unzip Error: %@", error);
56+
NSError *error = nil;
57+
[SSZipArchive unzipFileAtPath:path toDestination:outPath overwrite:YES password:nil error:&error];
58+
if(error) MTLog(@"Novel Unzip Error: %@", error);
59+
[fileManager removeItemAtPath:path error:NULL];
60+
[fileManager removeItemAtPath:[outPath stringByAppendingPathComponent:@"__MACOSX"] error:nil];
7461

75-
NSString *sound2Path = [soundOut stringByAppendingPathComponent:@"sound"];
76-
BOOL sound2IsDir = NO;
77-
BOOL sound2Exists = [fileManager fileExistsAtPath:sound2Path isDirectory:&sound2IsDir];
78-
if(sound2Exists && sound2IsDir)
62+
if(!error && [fileManager fileExistsAtPath:[outPath stringByAppendingPathComponent:@"sound.zip"]])
7963
{
80-
NSArray *s2contents = [fileManager contentsOfDirectoryAtPath:sound2Path error:NULL];
81-
for(NSString *name in s2contents)
64+
NSString *soundPath = [outPath stringByAppendingPathComponent:@"sound.zip"];
65+
NSString *soundOut = [outPath stringByAppendingPathComponent:@"sound"];
66+
67+
[delegate collection:self willReadSoundFromNovel:[outPath lastPathComponent]];
68+
[SSZipArchive unzipFileAtPath:soundPath
69+
toDestination:soundOut
70+
overwrite:YES password:nil error:&error];
71+
[fileManager removeItemAtPath:[outPath stringByAppendingPathComponent:@"sound.zip"] error:NULL];
72+
if(error) MTLog(@"Sound Unzip Error: %@", error);
73+
74+
NSString *sound2Path = [soundOut stringByAppendingPathComponent:@"sound"];
75+
BOOL sound2IsDir = NO;
76+
BOOL sound2Exists = [fileManager fileExistsAtPath:sound2Path isDirectory:&sound2IsDir];
77+
if(sound2Exists && sound2IsDir)
8278
{
83-
[fileManager moveItemAtPath:[sound2Path stringByAppendingPathComponent:name]
84-
toPath:[soundOut stringByAppendingPathComponent:name]
85-
error:NULL];
79+
NSArray *s2contents = [fileManager contentsOfDirectoryAtPath:sound2Path error:NULL];
80+
for(NSString *name in s2contents)
81+
{
82+
[fileManager moveItemAtPath:[sound2Path stringByAppendingPathComponent:name]
83+
toPath:[soundOut stringByAppendingPathComponent:name]
84+
error:NULL];
85+
}
86+
87+
[fileManager removeItemAtPath:sound2Path error:NULL];
8688
}
87-
88-
[fileManager removeItemAtPath:sound2Path error:NULL];
8989
}
90+
91+
path = outPath;
92+
filename = [path lastPathComponent];
93+
isDir = YES;
9094
}
9195

92-
path = outPath;
93-
filename = [path lastPathComponent];
94-
isDir = YES;
95-
}
96-
97-
MTLog(@"%d: %@", isDir, path);
98-
99-
if(isDir)
100-
{
101-
//Skip folders that are not novels
102-
if(![fileManager fileExistsAtPath:[path stringByAppendingPathComponent:@"info.txt"]]) continue;
96+
MTLog(@"%d: %@", isDir, path);
10397

104-
MTLog(@"%@", filename);
105-
Novel *novel = [[Novel alloc] initWithDirectory:filename];
106-
[novels addObject:novel];
107-
[novel release];
98+
if(isDir)
99+
{
100+
//Skip folders that are not novels
101+
if(![fileManager fileExistsAtPath:[path stringByAppendingPathComponent:@"info.txt"]])
102+
{
103+
MTLog(@"Couldn't find info.txt in %@", path);
104+
continue;
105+
}
106+
107+
MTLog(@"%@", filename);
108+
Novel *novel = [[Novel alloc] initWithDirectory:filename];
109+
[novels addObject:novel];
110+
[novel release];
111+
}
108112
}
109113
}
110114

README.markdown

+15-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,18 @@ A 'Version 2.0' is currently in very early stages of development. This version w
3232
## Help out!
3333
Feel free to branch the repo and add your own changes for me to pull back - this is a work in progress and there are always things that can be done better.
3434

35-
If you have ideas, questions, bugs or words of encouragement, please tell me! You can contact me at [*@uppfinnarn*](http://twitter.com/uppfinnarn) on Twitter or by email at *uppfinnarn (at) gmail (dot) com*.
35+
If you have ideas, questions, bugs or words of encouragement, please tell me! You can contact me at [*@uppfinnarn*](http://twitter.com/uppfinnarn) on Twitter or by email at *uppfinnarn (at) gmail (dot) com*.
36+
37+
## External Dependencies
38+
Building the iVN Source requires these libraries to be present in the correct locations:
39+
40+
* [MacaroniTools](https://github.com/uppfinnarn/MacaroniTools)
41+
A toolkit containing useful macros and utility categories.
42+
43+
* [TouchXML](https://github.com/TouchCode/TouchXML)
44+
A Lightweight XML Processing library used for reading XML Save Files
45+
*(Note: iVN Uses a not yet merged [branch](https://github.com/uppfinnarn/TouchXML), that mutes a Compiler Warning)*
46+
47+
* [SSZipArchive](https://github.com/samsoffes/ssziparchive)
48+
Objective-C Wrapper around the C-Based MiniZip utility to compress and decompress ZIP archives.
49+
*(Note: iVN Uses a not yet merged [branch](https://github.com/uppfinnarn/ssziparchive), that adds support for a Progress Delegate)*

SynthesizeSingleton.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
// appreciated but not required.
1313
//
1414

15+
#if __llvm__
16+
#define __SYNSIN_RELEASE_TYPE oneway void
17+
#else
18+
#define __SYNSIN_RELEASE_TYPE void
19+
#endif
20+
1521
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) SYNTHESIZE_SINGLETON_FOR_CLASS_SHORTNAME(classname, classname)
1622

1723
#define SYNTHESIZE_SINGLETON_FOR_CLASS_SHORTNAME(classname, shortname) \
@@ -60,7 +66,7 @@ static classname *shared##classname = nil; \
6066
return NSUIntegerMax; \
6167
} \
6268
\
63-
- (void)release \
69+
- (__SYNSIN_RELEASE_TYPE)release \
6470
{ \
6571
} \
6672
\

iVN.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
22098A3C149D2F2300ED6131 /* Archive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Archive.h; path = Model/Archive.h; sourceTree = "<group>"; };
131131
22098A3D149D2F2300ED6131 /* Archive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Archive.m; path = Model/Archive.m; sourceTree = "<group>"; };
132132
2212A59314B9A5B6004529C5 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = "<group>"; };
133+
2223D71414C20A0700500DB1 /* SSZipArchiveDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSZipArchiveDelegate.h; sourceTree = "<group>"; };
133134
2223F45614C0AC7E00C9E469 /* Osaka.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Osaka.ttf; sourceTree = "<group>"; };
134135
2223F45A14C0AD0900C9E469 /* OsakaMono.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = OsakaMono.ttf; sourceTree = "<group>"; };
135136
224BA2C614B1D25F009E9BF4 /* LoadingViewController~iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "LoadingViewController~iPad.xib"; path = "Controller/LoadingViewController~iPad.xib"; sourceTree = "<group>"; };
@@ -707,6 +708,7 @@
707708
8FC7C0A113DD68A500A5E60C /* Readme.markdown */,
708709
8FC7C0A213DD68A500A5E60C /* SSZipArchive.h */,
709710
8FC7C0A313DD68A500A5E60C /* SSZipArchive.m */,
711+
2223D71414C20A0700500DB1 /* SSZipArchiveDelegate.h */,
710712
);
711713
name = SSZipArchive;
712714
path = ../SSZipArchive;
@@ -984,6 +986,7 @@
984986
GCC_INPUT_FILETYPE = sourcecode.c.objc;
985987
GCC_PRECOMPILE_PREFIX_HEADER = YES;
986988
GCC_PREFIX_HEADER = "iVN/iVN-Prefix.pch";
989+
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
987990
HEADER_SEARCH_PATHS = /usr/include/libxml2;
988991
INFOPLIST_FILE = "iVN/iVN-Info.plist";
989992
IPHONEOS_DEPLOYMENT_TARGET = 4.2;
@@ -1012,6 +1015,7 @@
10121015
GCC_INPUT_FILETYPE = sourcecode.c.objc;
10131016
GCC_PRECOMPILE_PREFIX_HEADER = YES;
10141017
GCC_PREFIX_HEADER = "iVN/iVN-Prefix.pch";
1018+
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
10151019
HEADER_SEARCH_PATHS = /usr/include/libxml2;
10161020
INFOPLIST_FILE = "iVN/iVN-Info.plist";
10171021
IPHONEOS_DEPLOYMENT_TARGET = 4.2;

0 commit comments

Comments
 (0)