Forum Navigation
You need to log in to create posts and topics.

De-Archiving (continued, XCode)

Posted by: artlythere <artlythere@...>

Below is the gist from some open source (Zip further on down, 115k)
Now in the case of the one archive, it processes it just fine. But in the case of the one with SubFrameArchives inside...it does not.
So I added the check for it, and it shows the correct number, 1 subFrame, but I am lost how to iterate further.
-(void) loadWebArchive:(NSString*) pathToWebArchive
{
if (m_resources)
{
[m_resources removeAllObjects];
[m_resourceLookupTable removeAllObjects];
}
else
{
m_resources = [[NSMutableSet set] retain];
m_resourceLookupTable = [[NSMutableDictionary dictionary] retain];
}


NSData * webArchiveContent = [NSData dataWithContentsOfFile:pathToWebArchive];
WebArchive * archive = [[WebArchive alloc] initWithData:webArchiveContent];



m_mainResource = [[archive mainResource] retain] ;
[self addResource:m_mainResource];


NSArray * subFrames = [archive  subframeArchives];
if (subFrames) // There's one here...
{

/* What Here Now? Seems one would iterate that and get any subresources inside

           I am not sure what the leap is. The below finds -no- subresources in this instance.

       */ 

}


NSArray * subresources = [archive  subresources];
if (subresources)
{
WebResource* resource;
int i;
for (i=0; i<[subresources count]; i++)
{
resource = (WebResource*) [subresources objectAtIndex:i];
[self addResource:resource];
}
}


[archive release];
}
-(void) addResource:(WebResource *)resource
{
[m_resources addObject:resource];


//url of resource
NSURL* url = [resource URL];
NSString* absoluteString = [url absoluteString];
NSString* path = [url path];


//NSLog(@"resource url absoluteString = %s ", [absoluteString cString] );
    [m_resourceLookupTable setObject:resource forKey:absoluteString];


//NSLog(@"resource url path = %s ", [path cString] );
[m_resourceLookupTable setObject:resource forKey:path];


BOOL isFile = [url isFileURL];
if (isFile)
{
//todo
}



}


To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]