How to display file copy progress in 10.8

4 Solutions Collect From Internet About “How to display file copy progress in 10.8”

My answer assumes you’re talking about showing the progress of a single file being copied.

Yes, “FSCopyObjectAsync” been deprecated but it’s not gone yet.

And as you have discovered, Apple has not yet provided a useful replacement for the functionality that will eventually be removed. I suspect (but do not know for certain) that when the new functionality comes in, perhaps for 10.9, it will be delivered in the “NSFileManagerDelegate” protocol for delegates to make use of.

To make certain of that, Apple needs to be aware there are lots of developers need this. File a bug report at http://bugreporter.apple.com — it’ll likely be closed as a duplicate, but every vote counts.

copyfile(3) is alternative for FSCopyObjectAsync. Here is example of copyfile(3) with Progress Callback.

Coping files with progressIndicator in C

#define BUFSIZE (64*1024)

void *thread_proc(void *arg);
      {
          //outPath & inPatn an NSString paths

          char buffer[BUFSIZE];
          const char * outputFile = [outPath UTF8String];
          const char * inputFile = [inPath UTF8String];
          int in = open(inputFile, O_RDONLY);
          int out = open(outputFile, O_WRONLY | O_CREAT | O_TRUNC);

          vvolatile off_t progress;
          progress = 0;             
          ssize_t bytes_read;
          double fileSize = 0;
          NSNumber * theSize;

          if ([inPath getResourceValue:&theSize forKey:NSURLFileSizeKey error:nil])
                  fileSize = [theSize doubleValue];

          [progressIndicator setMaxValue:fileSize];      
          while((bytes_read = read(in, buffer, BUFSIZE)) > 0)
          {
              write(out, buffer, BUFSIZE);
              progress += bytes_read;

              [progressIndicator setDoubleValue:progress];

          }
          // copy is done, or an error occurred
          close(in);
          close(out);
      }

I created an open source project addressing this issue, I wrapped copy file(3) on a NSOperation and created a gui for it, please check it out and maybe contribute to make it better.

https://github.com/larod/FileCopyDemo

enter image description here