I am trying to use objective zip (v1.01e) in an IOS4 application as I want the ability to send password protected zip files via email.
I have got the objective zip source code files in my application, but am experiencing some problems following this getting started guide. http://code.google.com/p/objective-zip/wiki/GettingStarted
I use the following command
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:@"yourFiles.zip" mode:ZipFileModeCreate];
But this always fails returning null via the code shown below from method zipOpen2 (line 507). Here:
if (ziinit.filestream == NULL)
return NULL;
Following the stack trace it passes though the following methods:
//First
- (id) initWithFileName:(NSString *)fileName mode:(ZipFileMode)mode
//Second
extern zipFile ZEXPORT zipOpen (pathname, append)
//Third
extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def)
However, I notice the second method has this code.
extern zipFile ZEXPORT zipOpen (pathname, append)
const char *pathname;
int append;
{
return zipOpen2(pathname,append,NULL,NULL);
}
When I query the value of the string pathname (in GDB) from this method on I get:
0x1b7f30 does not appear to point to a valid object.
So my questions:
- What is
const char *pathname, what does it do and is it messing up the pathname? AFAIK char is a single character which cant possibly represent a file name?? - The code shown comes from source code of the objective zip project and not my own so I assume its working. It may be my misunderstanding of it. So what other possible reasons could be causing this problem?
For some more info initWithFileName: takes the parameter, filename and passes it on to zipOpen() by creating a pointer to file name as follows.
_fileName = [fileName retain];
Eventually I managed to solve this problem. The issue was because I was not appending the application’s documents directory location to the beginning of the file name.
Once I did this all was well.