At 14:47 Uhr -0500 12.06.2001, Randy Boring wrote:
>>I figured out my errors with the file list. One of the problems is that
>>there is
>>an invisible MPW icon the the directory. What is that? The file name is Icon.
>>Another problem is that I needed to chomp the fileName before using it. Why
>>would I have to do that?
>
>Kathy,
>
>Wiser Perlers than myself could answer whether you need to chomp the
>filename in general, but in this case it is because of the file name.
>The file's name is actually "Icon\0x0D", i.e., the carriage return in the
>last character of the filename. That file is what holds the custom icons
>that users can paste onto files and folders, I believe. The name was
>probably chosen by Apple so that users would have a very hard time
>entering it as the name of one of their documents. Any character can be
>in a file path; colon delimits volume:folders:filename, so it is illegal
>in a file or folder name, but any other character is possible, even \0x00
>(NULL).
>
>Hope that helps,
>
> -Randy
Kathy,
the -f is not an option, it's a file test (lookup "-f" in Shuck). It tells you,
whether or not a file is a plain file, and actually, "Icon\015" (octal, I prefer
this) or "Icon\x0D" (hexadecimal) -- but not "Icon\0x0D", that's wrong in Perl -- is a
plain file.
To get rid of it and other invisible files you may want to use the invisible()
function below. I send it along with some Mac OS file system documentation, which I've
written for the File::Find module that comes with MacPerl 5.6.1. Hope, you'll find it
helpful:
Mac OS (Classic) users should note a few differences:
The path separator is ':', not '/', and the current directory is denoted
as ':', not '.'. You should be careful about specifying relative pathnames.
While a full path always begins with a volume name, a relative pathname
should always begin with a ':'. If specifying a volume name only, a
trailing ':' is required.
[...]
The invisible system file "Icon\015" is ignored. While this file may
appear in every directory, there are some more invisible system files
on every volume, which are all located at the volume root level (i.e.
"MacintoshHD:"). These system files are *not* excluded automatically.
Your filter may use the following code to recognize invisible files or
directories (requires Mac::Files):
use Mac::Files;
# invisible() -- returns 1 if file/directory is invisible,
# 0 if it's visible or undef if an error occured
sub invisible($) {
my $file = shift;
my ($fileCat, $fileInfo);
my $invisible_flag = 1 << 14;
if ( $fileCat = FSpGetCatInfo($file) ) {
if ($fileInfo = $fileCat->ioFlFndrInfo() ) {
return (($fileInfo->fdFlags & $invisible_flag) && 1);
}
}
return undef;
}
Generally, invisible files are system files, unless an odd application
decides to use invisible files for its own purposes. To distinguish
such files from system files, you have to look at the *type* and *creator*
file attributes. The MacPerl built-in functions GetFileInfo(FILE) and
SetFileInfo(CREATOR, TYPE, FILES) offer access to these attributes
(see MacPerl.pm for details).
Files that appear on the desktop actually reside in an (hidden) directory
named "Desktop Folder" on the particular disk volume. Note that, although
all desktop files appear to be on the same "virtual" desktop, each disk
volume actually maintains its own "Desktop Folder" directory.
Of course, you could also filter the file "Icon\015" simply by it's name.
HTH.
Best regards,
--Thomas
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com