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

Re: [MacPerl-Toolbox] FSSpec/Alias problems



At 11.27 -0700 2000.04.28, Mat Marcus wrote:
>I am trying to send an AppleEvent to CodeWarrior to export a project
>as XML. I would like to send an 'alis' (alias) parameter to specify
>the output file. The output file does not currently exist. When
>coding in C++ I expect a -43 error (fnfErr or file not found) since
>the output file does not yet exist. It appears that MacPerl believes
>that it should not create an FSSpec or an alias for me in the
>presence of this error. I really don't want to have to create the
>file first just so I can specify it. I've tried MakeFSSpec,
>NewAlias*, and fullpaths to no avail. Am I missing something or is
>this a bug? Shouldn't NewAliasMinimalFromFullPath  work for
>non-existent file in valid directories?

It seems to work for me.

  #!perl -wl
  use Mac::Files;
  $x = NewAliasMinimalFromFullPath('Bourque:Foo:Bar:Baz');  # non-existent dir
  <>;  # wait for me to create dir
  print scalar ResolveAlias($x);  # prints path

If I do not create the file, it prints nothing but a warning about
uninitialized value.  So I can only assume the alias is being created, but
it cannot be resolved properly unless the file/folder is present.  And when
I create the alias, neither Foo, nor Baz, nor Bar are present.

Now, for MakeFSSpec, it is a different story.  You're right; it should
create it if there is a valid path, but invalid file.  And it does:

  #!perl -wl
  print MacPerl::MakeFSSpec('Bourque:Foo') || 'ack!';  # good dir
  print MacPerl::MakeFSSpec('Bourque:Foo:Bar') || 'ack!';  # bad dir

However, the other version aparently doesn't:

  #!perl -wl
  use Mac::Files;
  my $dir = FSpGetCatInfo('Bourque:');
  print FSMakeFSSpec($dir->ioVRefNum, $dir->ioDirID, 'Foo') || 'ack!';

That prints 'ack!'.  I changed the code in Files.xs to this:

	CODE:
	gLastMacOSErr = FSMakeFSSpec(vRefNum, dirID, fileName, &RETVAL);
	if ((gLastMacOSErr != noErr) && (gLastMacOSErr != fnfErr)) {
		XSRETURN_UNDEF;
	}

Previously, it just returned UNDEF is gLastMacOSErr.  I couldn't build a
CFM68K version (my compilers and libraries may be incompatible, since I
have been working on the new 5.6 stuff).  You can get the new Mac::Files
here:

    http://pudge.net/files/macperl/temp/Mac-Files.tar.gz

Installable with installme/untarzip stuff from cpan-mac.  If you do it by
hand, then make sure you demacbinarize the shared lib.  And again, MacPPC
only.  Hope it works!

-- 
Chris Nandor       |     pudge@pobox.com      |     http://pudge.net/
Andover.Net        | chris.nandor@andover.net | http://slashcode.com/

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org