[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Deleting files & interaction with AppleScript



On Thu, 07 Jan 1999 08:47:25 +0000, G. Ann Campbell wrote:

>Morning, all (or whenever it is where you are)
>
>I've got two questions today. First, how do you have MacPerl delete a file? My
>Perl for dummies suggests unlink, which doesn't seem to work.

unlink is the way. It should work. Do specify the full path. If for some
reason, this doesn't work, or you think it's not safe (it isn't: "poof!"
go your files. Now way to get them back if you deleted too much.):

>Do you just
>rename it to the trash directory? And if so, do you rename it to the trash
>directory on the volume it's on, or to your own trash?

Renaming ONLY works if on the same volume. So you should get the name of
the trash folder on that volume. I'd expect to use a function from
Mac::Files for that.

But, no matter what I try, I keep getting the path of the trash folder
on my system disk. What am I doing wrong? (I bet the first parameter is
of the wrong type.)

	use Mac::Files;
	while($file = shift) {
		my($volume)= $file=~/^([^:]+):/;
		my $trash = FindFolder($volume, kTrashFolderType);
		print "Volume = $volume, Trash folder = $trash\n";
	}

(Save as droplet, drop files on the droplet to get the trash folder for
the volume where the file is on. But it doesn't work. I tried
FindFolder("$volume:",kTrashFolderType"), with the same effect.)

p.s. in the Mac::Files docs I found NewAliasMinimal, "returns an
aliashandle (...), best used for short lived aliases", but do I need to
delete it too when I'm done, or does it go away by itself?

	Bart.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch