Re: [SOLVED] Re: FSCopyObjectASync Not Calling Callback In Cocoa

2008-05-01 Thread Douglas Davidson


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]


Re: [SOLVED] Re: FSCopyObjectASync Not Calling Callback In Cocoa

2008-05-01 Thread Clark Cox
On Thu, May 1, 2008 at 10:43 AM, stephen joseph butler
<[EMAIL PROTECTED]> wrote:
> 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,

It returns UTF-8, but with a very specific Unicode composition:


>  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.

When you think about this, it is really not possible, as
fileSystemRepresentation works on any string, including those that do
not represent existing files. There is no way to know, in general,
which filesystem a particular path will live on.

>
>  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.



-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

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

2008-05-01 Thread stephen joseph butler
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]


[SOLVED] Re: FSCopyObjectASync Not Calling Callback In Cocoa

2008-05-01 Thread Matt Long
Thanks for the help. The first response I got (Steve) was the correct  
one for what I was needing. I didn't correctly schedule with the run  
loop.


Here's a couple of points

Mike Fischer suggested that the operation was completing in less time  
than the one second specified. This is a good thought, but the file  
I'm copying is about 1GB (video file).


John Daub suggested that it might be a C++ issue. It doesn't appear  
that this is the issue. I've gotten it working without specifying the  
extern C pre-processor calls. Thanks, though.


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.


Anyhow, thanks again. If you would like to see the completed code,  
write me offline. I am updating a progress indicator in the callback.  
Seems to work pretty well.


-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

2008-05-01 Thread Mike Fischer

Am 01.05.2008 um 16:18 schrieb Michael Vannorsdel <[EMAIL PROTECTED]>:


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.


The operative word being "should". Not everything that should be is.



  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.



Rereading all of the documentation (not just that for the  
FSCopyObjectASync function) I have to agree with your analysis. It's  
interesting though that the OP reported that the copy operation  
itself worked fine, apparently without any runloop support.


Thanks for making sense of the sparse documentation ;-)


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

2008-05-01 Thread stephen joseph butler
On Wed, Apr 30, 2008 at 7:42 PM, Matt Long <[EMAIL PROTECTED]>
wrote:

>FSPathMakeRef( (const UInt8 *)[[sourceFilePath stringValue]
> cStringUsingEncoding:NSUTF8StringEncoding], &source, NULL );
>Boolean isDir = true;
>FSPathMakeRef( (const UInt8 *)[[destinationFilePath stringValue]
> cStringUsingEncoding:NSUTF8StringEncoding], &destination, &isDir );


Along with the  other comments, I don't think anyone has mention that these
should be -[NSString fileSystemRepresentation].
___

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

2008-05-01 Thread Michael Vannorsdel
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: FSCopyObjectASync Not Calling Callback In Cocoa

2008-05-01 Thread Mike Fischer

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

2008-04-30 Thread Steve Christensen
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]


FSCopyObjectASync Not Calling Callback In Cocoa

2008-04-30 Thread Matt Long
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]