Old Mac OS and relative pathnames?

Lic. Edgar J. De Cleene edgardec2001 at yahoo.com.ar
Wed Nov 13 08:49:06 UTC 2002


Ned:

I hope not wasting your time.
I attach something I use to create directories and moving files to correct
paths.
It's for MacPerl 5.2

For squeak I use this simple mechanism

setFolder
    slash _ FileDirectory slash.
    "Toma el separador de directorios, no es el mismo en todos los OS"
    oldFolder _ FileDirectory default.
    "Guarda el directorio de arranque"
    newFolder _ FileList2 modalFolderSelector.
    "Invoca la ventana de dialogo para seleccionar directorio"
    newFolder _ newFolder pathName , slash.
    FileDirectory setDefaultDirectory: newFolder

resetFolder
    FileDirectory setDefaultDirectory: oldFolder pathName
    "Al teminar volvemos al directorio default"

And this way could create, read, write all kinds of files no matter Mac
odities.

Sorry Spanish comments, but I wish help quick.

Edgar

-------------- next part --------------
#! perl
require "StandardFile.pl";
use Mac::Files;
$INPUT_FILE = &StandardFile'GetFile("From:", "TEXT");

$milinea = 'nada';

################################################ lose_path
sub lose_path {
#
#   Lose the path and return the filename part only
#
   local($path) = @_;
    $path =~ s/^.*:([^:]+)$/$1/;
    return($path);   # its just the last bit of the filename now
}

################################################ get_path
sub get_path {
#
#   Lose the filename part and return dir name (end in $pd)
#
    local($filename) = @_;
    $filename =~ s/([^:])+$//;
    return($filename); # its a path now with $pd at end
}
$folder_parent = &get_path($INPUT_FILE);

# read the whole file into memory.
open(INPUT_FILE) ||Êdie "El archivo no existe ";
 
@array = <INPUT_FILE>;
  
    
close(INPUT_FILE);

# specify which string to find.
$stringToFind = "<A HREF=";
$eliminafin = "#.+";
$eliminafin2 = "\".+";
$eliminapri = "^.+=\"";
# iterate over the array looking for the
# string.


for ($index = 0; $index <= $#array; $index++) {
 $_ = @array[$index];
	#s/$eliminafin//;
 if (m/$stringToFind/) {

    s/$eliminapri//;
    s/$eliminafin//;
    if (m/$eliminafin2/) {
     s/$eliminafin2//;
     }

     	if ($milinea ne $_  && length > 2) {
        ($milinea = $_) =~ s/"/$1/g;
    
        ($folder_name = $milinea) =~ s/([^\/])+$//;
        $folder_name = substr($folder_name,0,-1);
        ($file_name = $milinea) =~ s/^.+\///;
        if ($folder_name) {
           $path_folder = $folder_parent . $folder_name;
           eval {$info =FSpGetCatInfo ("$path_folder")};
           if (!$info) { print "Creo el folder $folder_name\n ";
           $info = FSpDirCreate("$path_folder");
        }# fin si hay folder
$path_file = $folder_parent .$file_name ;
$path_file =substr($path_file,0,-1);
stat($path_file);
print "archivo existe " if -e;
stat($path_folder);
print "folder existe " if -e;
$mover = 	FSpCatMove("$path_file","$path_folder")||die; 
      }# fin si mi linea es mas larga que dos
     print "$folder_name\t,$file_name\t,$mover\n" if length > 2 ;
    
    }
}
}




More information about the Squeak-dev mailing list