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

Re: [MacPerl] PC file names



Chris Nandor wrote (2/13/98 3:52 PM):

>I have a PPC 604e/180, PC Exchange (without which I could not mount said PC
>floppy), and I can directly access a file on the floppy with MacPerl (I
>read its contents and print them out), but I cannot read the directory of
>said floppy with MacPerl (opendir() does not fail, but readdir() returns
>nothing).

The following seems to work fine for me when saved as a droplet (IIfx, 
7.6.1, PC Exchange):
##########################################################
#!perl

while (@ARGV) {
    my $arg = shift;
    process( $arg );        
}

sub process {
    my $fn = shift;
    if ( -d $fn ) {
        local *D;
        opendir D, "$fn" or die "Couldn't open dir $fn; $!";
        while ( my $file = readdir D ) {
            ( my $sub = "$fn:$file" ) =~ s/::/:/;
            process( $sub ) ;
        }
    } else {
        eval {
                     open F, "$fn" or die "Couldn't open $fn; $!";
        };
        print $@, return if $@;
        print ++$argnr, ": $fn\n"; # or process as you like
        close F; 
    }
}

##########################################################
 
I just happened to have this fragment lying around. I did have to make 
one modification, however; because the diskette name had a colon appended 
when it was passed through @ARGV I had to strip out the extra colon 
before processing the top level directory. And I took out some lines that 
probably won't be needed since I don't think DOS has folder icons. Also, 
I didn't have time to try to find a module for this, but there might be 
one around somewhere.  Anyone know of any?

Larry

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