Re: First timer: Finder Copy vs. cp
Re: First timer: Finder Copy vs. cp
- Subject: Re: First timer: Finder Copy vs. cp
- From: Dan Shoop <email@hidden>
- Date: Thu, 10 Aug 2006 13:32:55 -0400
At 7:12 PM -0700 8/9/06, Jeffrey Ellis wrote:
on 8/9/06 5:50 PM, Dan Shoop at email@hidden wrote:
At 12:42 PM -0700 8/9/06, Terry Lambert wrote:
On Aug 7, 2006, at 2:01 PM, Jeffrey Ellis wrote:
Hi--
If the Finder is based on Darwin, why are there no direct commands
which will replicate a Finder Copy, i.e., copy all the metadata for
a given file, not just it's resource forks as in ditto or rsync?
I guess basically, the question from a programming standpoint, is
there a way to replicate a Finder Copy without actually calling the
UI?
Sorry for the n00b-ness of this question.
Thanks :)
"man cp".
The short answer is that the command line utility "cp" will copy the
metadata by default unless you tell it not to by specifying "-X" as
one of the arguments. So the support is already there, and on by
default.
If the metadata in question includes ACLs, then you will want to
specify "-p" to "preserve attributes" - primarily, protections and
timestamps - of which ACLs are a subset.
cp does not duplicate the behavior of the Finder, nor does ditto.
There are no shell commands I'm aware of that accurately duplicates
its behavior. (Which is a huge shame.)
One telling issue is that the Finder properly preserves Creation
Date, while command line tools do not. The BSD behavior for creation
dates is to munge it with modified date, even when creating what are
arguably not Apple Doubles (since the Apple Double spec says that
this metadata should be preserved in the Apple Double) either
explicitly based on their necessity due to foreign file systems or
even 'internally' when copying to HFS based volumes.
:Shameless Plug:
See this month's issue of MacTech for a further analysis and
discussion. I believe there are copies available at the WWDC, if
you're there.
See http://iwiring.net:8000/papers/Who_Copies_What.pdf for a summary
of how tools compare, from this article.
If you're interested in a copy of the article, email me privately.
At 4:16 PM -0700 8/9/06, Jeffrey Ellis wrote:
Wow... I saw a list of everything cp does, and you're right. It looks like
it does everything.
>> Okay, so I guess this is my next question. If cp does
everything, why would
anyone use ditto? I always thought that was used because of it's ability to
copy resource forks.
Because ditto and cp copy different metadata. For instance ditto
doesn't copy BSD flags while cp can. (The Finder only copies one BSD
flag, uchg)
Bottom line if you want the behavior of the Finder you need to use
the Finder. Neither ditto, cp, tar, rsync or other tools handle
metadata in the exact same manner.
Ah. Yes, I saw that might be the main drawback. Do you think there might be
a way to correct this, or would BSD simply alter any changes to cp?
cp is a BSD environment tool. The issue is that different
environments "see" different views of the filesystem metadata. BSD,
for instance, uses copyfile(). Carbon has yet different system calls
for copying files. Hence the behaviors are different.
Also, would the latest version of cp run in 10.3 or earlier?
Peerhaps, but since it relies on system routines such as copyfile()
to do it's work, the behavior is likely to remain that of the
copyfile() it calls in that OS version.
--
-dhan
------------------------------------------------------------------------
Dan Shoop AIM: iWiring
Systems & Networks Architect http://www.ustsvs.com/
email@hidden http://www.iwiring.net/
1-714-363-1174
pgp key fingerprint: FAC0 9434 B5A5 24A8 D0AF 12B1 7840 3BE7 3736 DE0B
iWiring provides systems and networks support for Mac OS X, unix, and
Open Source application technologies at affordable rates.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden