Safe asynchronous file copies

  • Hi!

    I am looking for a way to safely copy or move several files to a
    single destination folder.

    - Safe: I want it to check bevor overwriting existing files
    - Smart: If I copy two files of the same name at the same time, I want
    both files to exist at destination with their names suffixed by a
    counter
    - Asynchronous: No beachball, but a progress bar
    - Support resource forks, attributes, ...
    - Bonus: authentication if needed

    I see no Cocoa API living up to the task. NSFileManager/NSWorkspace
    only provide the building blocks. One would need to pour in quite some
    effort to wrap them with the above features.

    The Finder does all this and has an interface familiar to the user.
    AppleScript might be the way to go. My AppleScript knowledge is very
    limited. I am not actually sure the Finder exposes these features to
    AppleScript. I don't even know how to pass a list of file paths to
    Apple Script.

    Is there a Carbon API to do this?

    Has anyone else been down this road?

    Pierre

    ---
    Pierre Bernard
    http://www.bernard-web.com/pierre
    http://www.houdah.com
  • On Nov 17, 2007, at 3:25 PM, Pierre Bernard wrote:

    > Hi!
    >
    > I am looking for a way to safely copy or move several files to a
    > single destination folder.
    >
    > - Safe: I want it to check bevor overwriting existing files
    > - Smart: If I copy two files of the same name at the same time, I
    > want both files to exist at destination with their names suffixed
    > by a counter
    > - Asynchronous: No beachball, but a progress bar
    > - Support resource forks, attributes, ...
    > - Bonus: authentication if needed
    >
    > I see no Cocoa API living up to the task. NSFileManager/NSWorkspace
    > only provide the building blocks. One would need to pour in quite
    > some effort to wrap them with the above features.
    >
    > The Finder does all this and has an interface familiar to the user.
    > AppleScript might be the way to go. My AppleScript knowledge is
    > very limited. I am not actually sure the Finder exposes these
    > features to AppleScript. I don't even know how to pass a list of
    > file paths to Apple Script.
    >
    > Is there a Carbon API to do this?
    >
    > Has anyone else been down this road?
    >
    > Pierre

    There's no single API for doing what you're asking; you need to write
    some code.

    It's not particularly difficult, but you'll want to do some research
    into available Cocoa frameworks, Carbon APIs and even system tools
    like ditto. It's hard to say which would work best for your needs--
    you may even want to use more than one. I believe that some of this
    has been discussed on the Apple lists before, such as how to
    determine progress during a file copy.

    - d
  • Use the FSCopyObject APIs. There's FSCopyObjectAsync and
    FSPathCopyObjectAsync. It's how the Finder copies files.

    King Chung Huang
    Information Technologies
    University of Calgary

    On 17-Nov-07, at 3:04 PM, Dave Hersey wrote:

    > On Nov 17, 2007, at 3:25 PM, Pierre Bernard wrote:
    >
    >> Hi!
    >>
    >> I am looking for a way to safely copy or move several files to a
    >> single destination folder.
    >>
    >> - Safe: I want it to check bevor overwriting existing files
    >> - Smart: If I copy two files of the same name at the same time, I
    >> want both files to exist at destination with their names suffixed
    >> by a counter
    >> - Asynchronous: No beachball, but a progress bar
    >> - Support resource forks, attributes, ...
    >> - Bonus: authentication if needed
    >>
    >> I see no Cocoa API living up to the task. NSFileManager/NSWorkspace
    >> only provide the building blocks. One would need to pour in quite
    >> some effort to wrap them with the above features.
    >>
    >> The Finder does all this and has an interface familiar to the user.
    >> AppleScript might be the way to go. My AppleScript knowledge is
    >> very limited. I am not actually sure the Finder exposes these
    >> features to AppleScript. I don't even know how to pass a list of
    >> file paths to Apple Script.
    >>
    >> Is there a Carbon API to do this?
    >>
    >> Has anyone else been down this road?
    >>
    >> Pierre
    >
    > There's no single API for doing what you're asking; you need to
    > write some code.
    >
    > It's not particularly difficult, but you'll want to do some research
    > into available Cocoa frameworks, Carbon APIs and even system tools
    > like ditto. It's hard to say which would work best for your needs--
    > you may even want to use more than one. I believe that some of this
    > has been discussed on the Apple lists before, such as how to
    > determine progress during a file copy.
    >
    > - d
    >
  • Thanks!

    I will look into this.

    I just might up rolling my own open source controller for this task.

    Pierre

    On Nov 18, 2007, at 12:30 AM, King Chung Huang wrote:

    > Use the FSCopyObject APIs. There's FSCopyObjectAsync and
    > FSPathCopyObjectAsync. It's how the Finder copies files.
    >
    > King Chung Huang
    > Information Technologies
    > University of Calgary
    >
    > On 17-Nov-07, at 3:04 PM, Dave Hersey wrote:
    >
    >> On Nov 17, 2007, at 3:25 PM, Pierre Bernard wrote:
    >>
    >>> Hi!
    >>>
    >>> I am looking for a way to safely copy or move several files to a
    >>> single destination folder.
    >>>
    >>> - Safe: I want it to check bevor overwriting existing files
    >>> - Smart: If I copy two files of the same name at the same time, I
    >>> want both files to exist at destination with their names suffixed
    >>> by a counter
    >>> - Asynchronous: No beachball, but a progress bar
    >>> - Support resource forks, attributes, ...
    >>> - Bonus: authentication if needed
    >>>
    >>> I see no Cocoa API living up to the task. NSFileManager/
    >>> NSWorkspace only provide the building blocks. One would need to
    >>> pour in quite some effort to wrap them with the above features.
    >>>
    >>> The Finder does all this and has an interface familiar to the
    >>> user. AppleScript might be the way to go. My AppleScript knowledge
    >>> is very limited. I am not actually sure the Finder exposes these
    >>> features to AppleScript. I don't even know how to pass a list of
    >>> file paths to Apple Script.
    >>>
    >>> Is there a Carbon API to do this?
    >>>
    >>> Has anyone else been down this road?
    >>>
    >>> Pierre
    >>
    >> There's no single API for doing what you're asking; you need to
    >> write some code.
    >>
    >> It's not particularly difficult, but you'll want to do some
    >> research into available Cocoa frameworks, Carbon APIs and even
    >> system tools like ditto. It's hard to say which would work best for
    >> your needs--you may even want to use more than one. I believe that
    >> some of this has been discussed on the Apple lists before, such as
    >> how to determine progress during a file copy.
    >>
    >> - d
    >>


    ---
    Pierre Bernard
    http://www.bernard-web.com/pierre
    http://www.houdah.com
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today