debug problem
debug problem
- Subject: debug problem
- From: Eric Ocean <email@hidden>
- Date: Sat, 9 Oct 2004 11:43:35 -0700
I have a plist that I load at -applicationWillFinishLaunching, deserialize, and then retrieve a key from. I then compare this key (a copy of a previous file modification date) with the current modification date of a file.
The problem is this: after a certain number of uses, the date in the plist is being updated with the current state of the filesystem, behind my back, when I start up the application. I don't know how this is possible, but that's what appears to be happening. I only write the plist in one method in my code, and I have put break marks on it, added log messages, done a project-wide search to make sure that's the only place I create the plist, etc. I've set breakpoints on every init method of every class in my project and walked through the debugger step by step. Eventually, when I hit the code that compares the two modifications dates, both reflect the current modification date and the plist text "magically" updates in BBEdit.
What more can I do to debug this? I've cleaned the project (multiple times) already.
Regards,
Eric Ocean
P.s. Here's the code that discovers the error: (code to generate the plist is below)
- (void)
rescanLayerLinkFolder;
{
// for each layerlink folder, begin monitoring the original file (if it exists)
NSArray *layerLinkDirectories = [[NSFileManager defaultManager]
directoryContentsAtPath:@"/Library/Application Support/LayerLink/"];
NSEnumerator *e = [layerLinkDirectories objectEnumerator];
id anObject;
while ( anObject = [e nextObject] )
{
if ( [[anObject pathExtension] isEqualToString:@"link"] )
{
NSString *path = [NSString stringWithFormat:@"/Library/Application Support/LayerLink/%@/layerlink.info", anObject];
NSData *plistData = [NSData dataWithContentsOfFile:path];
NSString *error;
NSPropertyListFormat format;
NSDictionary *info = [NSPropertyListSerialization propertyListFromData:plistData
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&error];
if (error)
{
NSLog(@"LayerLink: %@", error);
[error release];
continue;
}
BDAlias *alias = [BDAlias aliasWithData:[info objectForKey:@"aliasData"]];
NSString *aliasPath = [alias fullPath];
[kqueue removePathFromQueue:aliasPath]; // to be safe; we don't want to monitor more than once
[kqueue addPathToQueue:aliasPath];
// for each file monitored, make sure that the layers are current for that file
NSDate *oldDate = [[info objectForKey:@"fileAttributes"] objectForKey:NSFileModificationDate];
NSDate *currentDate = [[[NSFileManager defaultManager] fileAttributesAtPath:aliasPath traverseLink:YES]
objectForKey:NSFileModificationDate];
if ( ![oldDate isEqualToDate:currentDate] )
{
// if the layers aren't current, regenerate them
NSData *fileData = [NSData dataWithContentsOfFile:aliasPath];
if ( fileData == nil ) continue; // safety precaution
AIDocument *doc = [[AIDocument alloc] init];
[doc reloadDataRepresentation:fileData
ofType:@"Adobe Illustrator"
withFileName:aliasPath
folderPath:[NSString stringWithFormat:@"/Library/Application Support/LayerLink/%@", anObject]
folderName:[info objectForKey:@"baseName"]];
[doc release];
}
}
}
}
And here's the code that writes the plist file:
- (void)
generateLayerLinkInfo;
{
BDAlias *alias = [BDAlias aliasWithPath:[self fileName]];
NSData *aliasData = [alias aliasData];
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:aliasData forKey:@"aliasData"];
[info setObject:[[NSFileManager defaultManager] fileAttributesAtPath:[self fileName] traverseLink:YES]
forKey:@"fileAttributes"];
[info setObject:folderName forKey:@"baseName"];
NSString *error;
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:info
format:NSPropertyListXMLFormat_v1_0
errorDescription:&error];
if (error) NSLog(@"LayerLink: %@", error);
[error release];
[plistData writeToFile:[NSString stringWithFormat:@"%@/layerlink.info", folderPath] atomically:YES];
NSLog(@"wrote layerlink.info file");
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden