Write an app that writes an app
Write an app that writes an app
- Subject: Write an app that writes an app
- From: Philip Aker <email@hidden>
- Date: Fri, 09 Aug 2002 06:36:05 -0700
(wuz: Re: stripping resource forks from a file.)
On Wednesday, August 7, 2002, at 06:21 PM, garbanzito wrote:
we had a thread on this earlier.. the following will leave the
file in place and preserve all HFS+ metadata:
do shell script "cat /dev/null >yourfile/..namedfork/rsrc"
I have been keeping this topic in mind but following a slightly
different tact. Discovered that 'ditto' creates a copy but
preserves metadata. It normally strips the resource fork but has
a -rsrc option which will copy it as well. It dusts the Finder
for speed.
do shell script "ditto ~/Desktop/m.scpt ~/Desktop/n.scpt"
do shell script "ditto -rsrc ~/Desktop/m.scpt ~/Desktop/o.scpt"
However, the interesting thing for me is that the
/..namedfork.rsrc works with 'DeRez'. The following (compiled as
an application) will create a clone of itself. In this version
the new name selected for the spawn should have the ".app"
extension. By extending these calls to Rez and DeRez, it would
be possible (for instance) to utilize custom data stored in the
resource fork of a scripting application, swap out the 'scpt'
(128) resource for something else, add custom icons (for display
dialog) etc., etc. Rez and DeRez work with data forks as well.
try
set newname to POSIX path of ((choose file name with prompt
"Save new application as:" default name "NewApp.app") as string)
set p2m to POSIX path of (path to me as string)
set forkpath to p2m & "/..namedfork/rsrc"
set carbr to
"/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/Carbon.r"
do shell script "/Developer/Tools/DeRez " & forkpath &
space & carbr & " > ~/Desktop/derezout.r"
do shell script "ditto " & p2m & space & newname
do shell script "/Developer/Tools/Rez " & carbr & "
~/Desktop/derezout.r -c aplt -t APPL -o " & newname
do shell script "rm ~/Desktop/derezout.r"
do shell script "open " & newname
on error errstr number errnum
if (errnum is not -128) then
display dialog errstr
end if
end try
Philip Aker
http://www.aker.ca
_______________________________________________
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.