Re: FSCopyObjectASync Not Calling Callback In Cocoa
Am 01.05.2008 um 06:55 schrieb Matt Long [EMAIL PROTECTED]: I execute this code and it successfully copies my file from source to destination: [snip] status returns with no error. However my callback never gets called. Why do you assume it should be called? You passed a minimum of 1 second as statusChangeInterval so if the operation is done in less than a second then I would not expect it to be called. Even if it takes longer the documentation doesn't guarantee anything about when it is supposed to trigger the callback AFAICT. Specifically documetation does not mention that the callback will be called on completion of the operation. [snip] Any idea why? Wrong assumptions? HTH Mike -- Mike Fischer Softwareentwicklung, EDV-Beratung Schulung, Vertrieb Note: I read this list in digest mode! Send me a private copy for faster responses. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: FSCopyObjectASync Not Calling Callback In Cocoa
I read over the docs for this function and not coming to the same conclusions. Being an async function it should be implied the callback will be used if the starting function succeeded. This is the whole point of async operations and the only way to get status reports from them besides having to poll, which defeats the purpose of async operations. Also, the minimum time argument as the docs explains is there to limit the time between multiple calls for a single stage (ie kFSOperationStageRunning) for flood prevention and doesn't apply to stage changes. Also, the presence of a kFSOperationStageComplete: The file operation is complete. makes it pretty clear there should be a status report upon completion. The only error here I believe, as explained by someone else, is forgetting to schedule the event source with the runloop for processing. However after reading the docs I too am lead to believe (and know from experience with this function) that the callback is used and is called upon completion. On May 1, 2008, at 1:39 AM, Mike Fischer wrote: Am 01.05.2008 um 06:55 schrieb Matt Long [EMAIL PROTECTED]: I execute this code and it successfully copies my file from source to destination: [snip] status returns with no error. However my callback never gets called. Why do you assume it should be called? You passed a minimum of 1 second as statusChangeInterval so if the operation is done in less than a second then I would not expect it to be called. Even if it takes longer the documentation doesn't guarantee anything about when it is supposed to trigger the callback AFAICT. Specifically documetation does not mention that the callback will be called on completion of the operation. [snip] Any idea why? Wrong assumptions? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: [SOLVED] Re: FSCopyObjectASync Not Calling Callback In Cocoa
On Thu, May 1, 2008 at 12:03 PM, Matt Long [EMAIL PROTECTED] wrote: Stephen Butler pointed out that I need to use -[NSString fileSystemRepresentation]. I have switched to this and it works. I not real familiar with this call, but it looks like it's working. I'll look into why this is the better choice. I'm just not familiar. For almost all intents and purposes, it returns UTF-8, because that's what the APIs to HFS+, et al expect. However, it's conceivable that some file system might want path strings in another (legacy) format. Say, Shift_JIS, Big5, or KOI8-R. I'm not sure any do. I'm not even sure the vfs layer allows the fs to register a preference. But there's a function for it, so you might as well use it. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: [SOLVED] Re: FSCopyObjectASync Not Calling Callback In Cocoa
On May 1, 2008, at 10:43 AM, stephen joseph butler wrote: On Thu, May 1, 2008 at 12:03 PM, Matt Long [EMAIL PROTECTED] long.com wrote: Stephen Butler pointed out that I need to use -[NSString fileSystemRepresentation]. I have switched to this and it works. I not real familiar with this call, but it looks like it's working. I'll look into why this is the better choice. I'm just not familiar. For almost all intents and purposes, it returns UTF-8, because that's what the APIs to HFS+, et al expect. However, it's conceivable that some file system might want path strings in another (legacy) format. Say, Shift_JIS, Big5, or KOI8-R. I'm not sure any do. I'm not even sure the vfs layer allows the fs to register a preference. But there's a function for it, so you might as well use it. It's not that this varies from one file system to another on the same machine, but rather that the BSD/Posix layer of APIs have a specific representation for file system names, and this method insulates you from the details of that representation. Douglas Davidson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
FSCopyObjectASync Not Calling Callback In Cocoa
I execute this code and it successfully copies my file from source to destination: - (IBAction)startCopy:(id)sender; { FSFileOperationRef fileOp = FSFileOperationCreate(NULL); FSRef source; FSRef destination; FSPathMakeRef( (const UInt8 *)[[sourceFilePath stringValue] cStringUsingEncoding:NSUTF8StringEncoding], source, NULL ); Boolean isDir = true; FSPathMakeRef( (const UInt8 *)[[destinationFilePath stringValue] cStringUsingEncoding:NSUTF8StringEncoding], destination, isDir ); OSStatus status = FSCopyObjectAsync (fileOp, source, destination, NULL, kFSFileOperationDefaultOptions, statusCallback, 1.0, NULL); CFRelease(fileOp); if( status ) NSLog(@Status: %@, status); } status returns with no error. However my callback never gets called. Here's the callback. static void statusCallback (FSFileOperationRef fileOp, const FSRef *currentItem, FSFileOperationStage stage, OSStatus error, CFDictionaryRef statusDictionary, void *info ) { NSLog(@Callback got called.); if (statusDictionary) { CFNumberRef totalBytes, bytesCompleted; bytesCompleted = (CFNumberRef) CFDictionaryGetValue(statusDictionary, kFSOperationBytesCompleteKey); if (bytesCompleted) { fprintf(stderr, \tbytesCompleted: ); CFShow(bytesCompleted); } totalBytes = (CFNumberRef) CFDictionaryGetValue(statusDictionary, kFSOperationTotalBytesKey); if (totalBytes) { fprintf(stderr, \ttotalBytes: ); CFShow(totalBytes); } } } Any idea why? Thanks. -Matt ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: FSCopyObjectASync Not Calling Callback In Cocoa
I noticed in some sample code (http://developer.apple.com/samplecode/ FSFileOperation/listing1.html), that after creating the FSFileOperationRef, it calls FSFileOperationScheduleWithRunLoop, specifying the current run loop. Just a guess that you're probably not making that association so the callback is never being called. On Apr 30, 2008, at 5:42 PM, Matt Long wrote: I execute this code and it successfully copies my file from source to destination: - (IBAction)startCopy:(id)sender; { FSFileOperationRef fileOp = FSFileOperationCreate(NULL); FSRef source; FSRef destination; FSPathMakeRef( (const UInt8 *)[[sourceFilePath stringValue] cStringUsingEncoding:NSUTF8StringEncoding], source, NULL ); Boolean isDir = true; FSPathMakeRef( (const UInt8 *)[[destinationFilePath stringValue] cStringUsingEncoding:NSUTF8StringEncoding], destination, isDir ); OSStatus status = FSCopyObjectAsync (fileOp, source, destination, NULL, kFSFileOperationDefaultOptions, statusCallback, 1.0, NULL); CFRelease(fileOp); if( status ) NSLog(@Status: %@, status); } status returns with no error. However my callback never gets called. Here's the callback. static void statusCallback (FSFileOperationRef fileOp, const FSRef *currentItem, FSFileOperationStage stage, OSStatus error, CFDictionaryRef statusDictionary, void *info ) { [snip] } Any idea why? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]