Re: How to detect a file has resource fork, or not?
Re: How to detect a file has resource fork, or not?
- Subject: Re: How to detect a file has resource fork, or not?
- From: Chris Janton <email@hidden>
- Date: Tue, 16 Mar 2004 02:36:05 -0700
here's a shell-based test
set f to choose file
set res_path to quoted form of POSIX path of f & "/..namedfork/rsrc"
set byte_count_str to do shell script "cat " & res_path & " | wc -c"
if byte_count_str as number is greater than 0 then
-- resource fork is non-empty
end if
warning - gratuitous use of "cat"
You can simply state the above command as
"wc -c " & res_path
no need to cat the file into a pipe - wc will read it just fine.
Now for a "simpler" shell based test for an empty file
try
do shell script "test -s ~/foo/..namedfork/rsrc"
on error errMsg number errNum
{errMsg, errNum}
end try
"test -s" returns true if a file exists *and* has a size greater than 0
The "test" command (and its friend in the shell "[ expression ]" ) is
well worth a look-see in the man pages.
8)
----------------------------------
Chris Janton - face at CentosPrime dot COM
Netminder for Opus1.COM
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.