fileHandle writeData not reporting error nor writing data
fileHandle writeData not reporting error nor writing data
- Subject: fileHandle writeData not reporting error nor writing data
- From: Ken Hawkins <email@hidden>
- Date: Tue, 23 Mar 2004 14:37:49 -0800
The following bit of code is what is not returning an erro nor writing
the file:
NSEnumerator *deviceEnumerator = [[value mediaList:YES]
objectEnumerator];
XMTrack * track = nil;
NSData * buffer = nil;
NSString * dest = nil;
NSFileHandle * outFile = nil;
while ((track = [deviceEnumerator nextObject]) != nil)
{
NSString * outDir = [NSString stringWithFormat:@"%@/%@", [self
fileDirectory], [value volumeName]];
// now we go through and extract the files
// redundant select check here
if([track isSelected])
{
dest = [NSString stringWithFormat:@"%@/%@.%@", outDir, [track name],
[self fileExtension]];
outFile = [NSFileHandle fileHandleForWritingAtPath:dest];
if(outFile = nil)
{
[log toLog:self level:kLOG_ERROR message:
[NSString stringWithFormat:@"failed to open %@",
dest]];
return;
}
[log toLog:self level:kLOG_DEBUG message:
[NSString stringWithFormat:@"xtracting %@ to %@",
[track name], dest]];
//get the buffer
buffer = [[track mediaHandle] readDataToEndOfFile];
if([buffer length] > 0)
{
[outFile write
Data:buffer];
[log toLog:self level:kLOG_DEBUG message:
[NSString stringWithFormat:@"xtracte %@ with length of %i",
dest, [buffer length]]];
}
[[track mediaHandle] closeFile];
[outFile closeFile];
break;
}
}
i can go all the way through here and the debug stuff comes out as:
2004-03-23 14:33:28.448 CDXtractor[905] DEBUG xtracting Mystic's Dream
to /Users/ken/downloads/The Mask & The Mirror/Mystic's Dream.mp3
2004-03-23 14:34:08.173 CDXtractor[905] DEBUG xtracte
/Users/ken/downloads/The Mask & The Mirror/Mystic's Dream.mp3 with
length of 81475632
this is the correct length but there is no file created. does
'fileHandleForWritingAtPath' NOt return nil if a file is not found? the
outFile is supposed to be a newly created file.
thanks,
ken;
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.