> I have an application which (amongst other things) copies files to other
> devices. Resource files should _not_ be copied (i.e. no ._myfile.ext).
[quoted text clipped - 11 lines]
> Alternatively, I'm looking at 'post-processing' the copy, or writing my
> own copy routine/tool.
How about:
ditto --norsrc

Signature
Clark S. Cox III
clarkcox3@gmail.com
Patrick Machielse - 28 Dec 2006 19:02 GMT
> > My question: is there a different command line tool (not part of the dev
> > tools) that can perform a 'naked' file copy, or is there an undocumented
[quoted text clipped - 3 lines]
>
> ditto --norsrc
This seems like a promising candidate. I've never really used it before,
so it didn't immediately spring to mind (and since it's not referenced
in the cp man page, I didn't find it. I think there's a theme here...)
ditto doesn't support all the cp options I use, but I think it may be
'good enough'.
thanks,
patrick
> I have an application which (amongst other things) copies files to other
> devices. Resource files should _not_ be copied (i.e. no ._myfile.ext).
[quoted text clipped - 7 lines]
> My question: is there a different command line tool (not part of the dev
> tools) that can perform a 'naked' file copy,
I do not know whether they are or are not part of the dev tools, but
cat source_path > destination_path
or
ditto --norsrc source_path destination_path
should work.
> or is there an undocumented flag to cp that disables res.forks?
I do not know about undocumented ones, but "man 5 compat" might be of
help.
> Alternatively, I'm looking at 'post-processing' the copy, or writing my
> own copy routine/tool.
Writing your own is a stupid idea, given that the source for the 10.3
version of cp is available
(<http://www.opensource.apple.com/darwinsource/10.3.9/>)
Reinder
Clark S. Cox III - 28 Dec 2006 12:47 GMT
>> I have an application which (amongst other things) copies files to other
>> devices. Resource files should _not_ be copied (i.e. no ._myfile.ext).
[quoted text clipped - 11 lines]
>
> cat source_path > destination_path
cat is probably a bad idea, as you will lose meta-data such as
permissions, user/group, etc.

Signature
Clark S. Cox III
clarkcox3@gmail.com
Patrick Machielse - 28 Dec 2006 19:02 GMT
> > or is there an undocumented flag to cp that disables res.forks?
>
> I do not know about undocumented ones, but "man 5 compat" might be of
> help.
Interesting pointer. This could work, but the LEGACY section of man cp
doesn't indicate that it will restore resource fork stripping. The only
way to find out is to try, I guess.
> > Alternatively, I'm looking at 'post-processing' the copy, or writing my
> > own copy routine/tool.
>
> Writing your own is a stupid idea, given that the source for the 10.3
> version of cp is available
> (<http://www.opensource.apple.com/darwinsource/10.3.9/>)
True, I always forget about that. Stupid me! ;-) Still, I'd only do this
as a last resort.
patrick
Patrick Machielse - 29 Dec 2006 15:54 GMT
> > > or is there an undocumented flag to cp that disables res.forks?
> >
[quoted text clipped - 4 lines]
> doesn't indicate that it will restore resource fork stripping. The only
> way to find out is to try, I guess.
A quick test reveals that setting the environment variable COMMAND_MODE
to 'legacy' does not revert cp to the 10.3 behavior of stripping
resource forks. Alas.
patrick
> My question: is there a different command line tool (not part of the dev
> tools) that can perform a 'naked' file copy, or is there an undocumented
> flag to cp that disables res.forks?
If you're doing the copy from within your application, why not just do
this:
FILE *in = fopen(infilename, "rb");
FILE *out = fopen(outfilename, "wb);
char buffer[1000];
size_t count;
while ((count = fread(buffer, 1, 1000, in)) != 0)
{
fwrite(buffer, 1, count, out);
}
fclose(out);
fclose(in);
Add some error-checking lines to make this useable in an actual
application and you should be done. It definitely won't go copying any
resource forke.
-- David
Patrick Machielse - 28 Dec 2006 19:02 GMT
> If you're doing the copy from within your application, why not just do
> this:
[quoted text clipped - 16 lines]
> application and you should be done. It definitely won't go copying any
> resource forke.
Yeah, but I'm trying to be as lazy as possible here, so if there's a
shortcut available through a standard tool I'll gladly take it ;-)
Also, there's always a heap of details to consider if it must be robust,
and re-inventing the wheel here makes me look stupid (see other
reply..).
patrick