File System Type of a file

Matt Deatherage mattd at macjournals.com
Sun Mar 25 00:02:02 PDT 2007


On 3/23/07 at 3:26 AM, Florent Lacheroy
<florent.lacheroy at alwancolor.com> wrote:

> To explain my situation: I've tested Apple method of
> NSFileManager::movePath:toPath: and it systematically fails when
> moving a file to a HFS volume (I think it's because filename length
> limitation).

This always sounds harsher than I mean it, but why don't you *know* what
the error is?  I think you can add an easy callback handler to that
method to get the path and description of the error:

<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/
instm/NSObject/fileManager:shouldProceedAfterError:>

Apparently the APIs available from the system don't distinguish between
HFS and HFS Plus volumes, which surprises me.  In Mac OS 9, calling
PBXGetVolInfoSync (or Async) would give you an ioVSigWord of $4244 for
HFS but $482B for HFS Plus.  However, Mac OS X is not documented as
doing this for this call, and the PBXGetVolInfo calls are deprecated in
Tiger or later anyway.  (Even in Mac OS 9, PBGetVInfo and PGHGetVInfo
returned $4244 for HFS Plus volumes "for compatibility with some
programs.")

It also surprises me that there doesn't seem to be a way to pass a
pathname to the system and say "hey, is this legal syntax for this
volume?"  I was just about positive that finally got added at some
point, be it through URLs or converting paths to some other object and
back, but I can't find it.

...oh, it looks like I was thinking of QuickTime's
"NativePathnameToFSSpec", but it's only part of QuickTime for Windows,
and even if it weren't, it only returns FSSpec structures, not helpful
in Cocoa.  Dang.

But at least you can find out what the error is.  If you're right, I
think at some level it should be -37 (bdNameErr), but I have no strong
recommendations on what to do about it.  Not even MoreFilesX has a
routine that will copy a file to a volume, change its name to something
conforming to the destination file system's syntax if necessary, and
return something telling you what the new name is.  I'm sure Finder does
it, but I don't think the capability is exposed anywhere.

Except maybe via Apple events, but that's a whole nother subject.  Sigh.

--Matt

--
Matt Deatherage                              <mattd at macjournals.com>
GCSF, Incorporated                      <http://www.macjournals.com>

"It's not like some directories really hold something else, like
pixels, or maybe pudding." -- MDJ 2003.05.22




More information about the MacOSX-dev mailing list