home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 February
/
PCWK0296.iso
/
po7_win
/
install
/
makedir.vrf
< prev
next >
Wrap
Text File
|
1995-01-06
|
14KB
|
413 lines
/* Copyright (c) Oracle Corporation 1993. All Rights Reserved */
/*****************************************************************************
NAME
makedir.vrf - V3 common checks for valid path name.
DESCRIPTION
This script requests an absolute directory name until a valid path is
found. This directory is created if it does not already exist. NFS
paths are not checked for legal names. HPFS paths are checked for
legal HPFS names. All other paths are checked for legal FAT names.
IN Variables:
string makedir_default_dir
string makedir_select_dir_prompt
string makedir_select_dir_content (dos/os2 only)
string makedir_select_dir_help (dos/os2 only)
Used in a text dialog to request a directory name.
If Windows, choose directory dialog is used instead
(content & help will not be available).
boolean makedir_root_allowed
Set to true if '%drive%:\' is considered valid.
boolean makedir_skip_pass
Set to true means user has already entered a path to check, using
multiple_text_dialog in calling script, for example. If unbound,
default to false.
string makedir_root_message
string makedir_root_content
string makedir_root_help
Used in information dialog if makedir_root_allowed = false and
a root path was entered. The variable %makedir_path_to_check%
can referred to in these 3 strings to reference the root path
that was entered.
string list makedir_bad_dir_list
string list makedir_bad_dir_message_list
string list makedir_bad_dir_content_list
string list makedir_bad_dir_help_list
List of known bad directories and their associated messages.
These will be checked for and message will be displayed. Can
be left unbound (all 4 must be unbound) if empty. If content
string is "", then no help is displayed with message.
All of the above strings are instantiated immediately before usage.
RETURNS: string
The valid directory that was specified. This directory is
guaranteed to exist.
NOTE:
This script uses only variables with prefix 'makedir_'.
This script requires Installer 3.0.10.1.1 or later.
This script is shared by OS/2, DOS, and Windows.
MODIFIED MM/DD/YY REASON
zzerhoun 12/15/94 Changed to allow to set path_to_check in calling script
ming 01/13/94 Changed to allow to run under DOS and OS/2.
ming 01/12/94 Added 'stringsonly to explode calls.
ming 12/30/93 Created.
*****************************************************************************/
{
{ makedir_bad_dir_list = makedir_bad_dir_list; }
[ 'unbound_variable:
{
makedir_bad_dir_list = list();
makedir_bad_dir_message_list = list();
makedir_bad_dir_content_list = list();
makedir_bad_dir_help_list = list();
} ]
makedir_old_current_directory = current_directory(); /* need to restore this later */
makedir_bad_names = list("kbd$","prn","nul","com1","com2","com3","com4","con","clock$",
"lpt1","lpt2","lpt3","screen$","pointer$","mouse$");
makedir_drives = dos_mapped_drives();
makedir_new_dirs = list(); /* list of directories created by this script */
{
while (true)
{
makedir_redo = false;
while (not(empty(makedir_new_dirs)))
{ /* clean up */
makedir_new_dir = first(makedir_new_dirs);
makedir_new_dirs = rest(makedir_new_dirs);
remove_directory(makedir_new_dir);
} [ 'default: continue(); ]
makedir_select_dir_prompt_inst = instantiate(makedir_select_dir_prompt);
makedir_default_dir_inst = instantiate(makedir_default_dir);
{
if (not(makedir_skip_pass))
signal('UNBOUND_VARIABLE);
}
['UNBOUND_VARIABLE:
{
makedir_path_to_check = choose_directory_dialog(makedir_select_dir_prompt_inst,
makedir_default_dir_inst);
continue();
}
]
makedir_skip_pass = FALSE;
pathify(makedir_path_to_check);
/* check for known bad directories */
makedir_bad_dirs = makedir_bad_dir_list;
makedir_bad_dir_messages = makedir_bad_dir_message_list;
makedir_bad_dir_contents = makedir_bad_dir_content_list;
makedir_bad_dir_helps = makedir_bad_dir_help_list;
while (not(empty(makedir_bad_dirs)))
{
if (makedir_path_to_check==first(makedir_bad_dirs))
{
makedir_bad_dir_contents_inst = instantiate(first(makedir_bad_dir_contents));
if (makedir_bad_dir_contents_inst=="")
information_dialog(instantiate(first(makedir_bad_dir_messages)));
else
information_dialog(instantiate(first(makedir_bad_dir_messages)),
makedir_bad_dir_contents_inst,
instantiate(first(makedir_bad_dir_helps)));
makedir_redo = TRUE;
break();
}
makedir_bad_dirs = rest(makedir_bad_dirs);
makedir_bad_dir_messages = rest(makedir_bad_dir_messages);
makedir_bad_dir_contents = rest(makedir_bad_dir_contents);
makedir_bad_dir_helps = rest(makedir_bad_dir_helps);
}
if (makedir_redo)
continue();
if (not(contains(makedir_path_to_check,":")))
{
information_dialog(instantiate(makedir_specify_drive));
continue(); /* no : */
}
makedir_drive_path = explode(makedir_path_to_check,":",'stringsonly);
makedir_drive = first(makedir_drive_path); /* find the drive */
if (not(member(makedir_drives,makedir_drive)))
{
information_dialog(instantiate(makedir_bad_drive));
continue(); /* bad drive letter */
}
makedir_path = rest(makedir_drive_path);
if (empty(makedir_path))
{
information_dialog(instantiate(makedir_no_dir));
continue(); /* nothing after : */
}
makedir_rest_path = rest(makedir_path);
if (not(empty(makedir_rest_path)))
{
information_dialog(instantiate(makedir_invalid_path));
continue(); /* extra : */
}
makedir_path = first(makedir_path);
if (first(explode(makedir_path,"\",true,'stringsonly))!="\")
{
information_dialog(instantiate(makedir_absolute_path));
continue(); /* not absolute path */
}
{
makedir_fstype = dos_file_system_type("%makedir_drive%:");
} ['default: makedir_fstype = 'fat; ]
/* assume FAT if not disk not accessible - probably floppy */
if ((makedir_fstype!='nfs) || (makedir_fstype!='ntnf))
{
makedir_bad_chars = list("*","?","<",">","|",",","+","=","[","]",";","&","-");
while (not(empty(makedir_bad_chars)))
{ /* check for illegal characters */
makedir_bad_char = first(makedir_bad_chars);
makedir_bad_chars = rest(makedir_bad_chars);
if (contains(makedir_path,makedir_bad_char))
{
information_dialog(instantiate(makedir_illegal_char));
makedir_redo = true;
break();
}
}
if (makedir_redo)
continue();
}
if (contains(makedir_path,"\\"))
{
information_dialog(instantiate(makedir_invalid_path));
continue();
}
makedir_names = explode(makedir_path,"\",'stringsonly);
if (empty(makedir_names))
{
{
makedir_root_allowed = makedir_root_allowed;
} [ 'unbound_variable: makedir_root_allowed = false; ]
if (not(makedir_root_allowed))
{
information_dialog(instantiate(makedir_root_message),
instantiate(makedir_root_content),
instantiate(makedir_root_help));
continue(); /* case of d:\ */
}
}
else
{
makedir_current_path = "%makedir_drive%:";
change_directory(makedir_current_path);
/* check for bad names */
if ((makedir_fstype=='hpfs) || (makedir_fstype=='ntfs))
while (not(empty(makedir_names)))
{
makedir_name = first(makedir_names);
makedir_names = rest(makedir_names);
if ((length(makedir_name)>254))
{
information_dialog(instantiate(makedir_name_too_long));
makedir_redo = true; /* too long */
break();
}
if (member(makedir_bad_names,makedir_name))
{
information_dialog(instantiate(makedir_illegal_name));
makedir_redo = true; /* illegal name */
break();
}
makedir_current_path = "%makedir_current_path%\%makedir_name%";
{
makedir_exists = exists(makedir_current_path);
} [ 'default:
{
information_dialog(instantiate(makedir_invalid_path));
makedir_redo = true; /* can't check existence */
break();
} ]
if (makedir_exists)
{
{
change_directory(makedir_current_path);
} [ 'default(makedir_signal):
{
information_dialog(instantiate(makedir_dir_not_accessible));
makedir_redo = true;
break();
} ]
}
else
{
{
make_directory(makedir_current_path);
if (not(exists(makedir_current_path)))
signal('make_directory_failure,"Can't make directory '%makedir_current_path%'.");
makedir_new_dirs = cons(makedir_current_path,makedir_new_dirs);
} [ 'default(makedir_signal):
{
information_dialog(instantiate(makedir_cant_create_dir));
makedir_redo = true;
break();
} ]
}
}
else if ((makedir_fstype=='nfs) || (makedir_fstype=='ntnf))
while (not(empty(makedir_names)))
{
makedir_name = first(makedir_names); /* find last name */
makedir_names = rest(makedir_names);
makedir_current_path = "%makedir_current_path%\%makedir_name%";
{
makedir_exists = exists(makedir_current_path);
} [ 'default:
{
information_dialog(instantiate(makedir_invalid_path));
makedir_redo = true; /* can't check existence */
break();
} ]
if (makedir_exists)
{
{
change_directory(makedir_current_path);
} [ 'default(makedir_signal):
{
information_dialog(instantiate(makedir_dir_not_accessible));
makedir_redo = true;
break();
} ]
}
else
{
{
make_directory(makedir_current_path);
if (not(exists(makedir_current_path)))
signal('make_directory_failure,"Can't make directory '%makedir_current_path%'.");
makedir_new_dirs = cons(makedir_current_path,makedir_new_dirs);
} [ 'default(makedir_signal):
{
information_dialog(instantiate(makedir_cant_create_dir));
makedir_redo = true;
break();
} ]
}
}
else /* FAT */
while (not(empty(makedir_names)))
{
makedir_name = first(makedir_names);
makedir_names = rest(makedir_names);
if (member(makedir_bad_names,makedir_name))
{
information_dialog(instantiate(makedir_illegal_name));
makedir_redo = true; /* illegal name */
break();
}
if (count(makedir_name,".")>1)
{
information_dialog(instantiate(makedir_illegal_name));
makedir_redo = true; /* too many .'s */
break();
}
makedir_base_ext = explode(makedir_name,".",'stringsonly);
makedir_base = first(makedir_base_ext);
if (length(makedir_base)>8)
{
information_dialog(instantiate(makedir_long_basename));
makedir_redo = true; /* basename too long */
break();
}
makedir__ext = rest(makedir_base_ext);
if (not(empty(makedir__ext)))
{ /* has extension - check it */
makedir_ext = first(makedir__ext);
if (length(makedir_ext)>3)
{
information_dialog(instantiate(makedir_long_extension));
makedir_redo = true; /* extension too long */
break();
}
}
makedir_current_path = "%makedir_current_path%\%makedir_name%";
{
makedir_exists = exists(makedir_current_path);
} [ 'default:
{
information_dialog(instantiate(makedir_invalid_path));
makedir_redo = true; /* can't check existence */
break();
} ]
if (makedir_exists)
{
{
change_directory(makedir_current_path);
} [ 'default(makedir_signal):
{
information_dialog(instantiate(makedir_dir_not_accessible));
makedir_redo = true;
break();
} ]
}
else
{
{
make_directory(makedir_current_path);
if (not(exists(makedir_current_path)))
signal('make_directory_failure,"Can't make directory '%makedir_current_path%'.");
makedir_new_dirs = cons(makedir_current_path,makedir_new_dirs);
} [ 'default(makedir_signal):
{
information_dialog(instantiate(makedir_cant_create_dir));
makedir_redo = true;
break();
} ]
}
}
if (makedir_redo)
continue();
/* reject if last name contains tabs or final white space */
if (implode(explode(makedir_name,'stringsonly))!=makedir_name)
{
information_dialog(instantiate(makedir_has_white_space));
continue();
}
}
change_directory(makedir_old_current_directory);
return(makedir_path_to_check);
}
} [ 'default(uncaught_signal, uncaught_signal_message):
{
while (not(empty(makedir_new_dirs)))
{
makedir_new_dir = first(makedir_new_dirs);
makedir_new_dirs = rest(makedir_new_dirs);
remove_directory(makedir_new_dir);
} [ 'default: continue(); ]
change_directory(makedir_old_current_directory);
signal(uncaught_signal, uncaught_signal_message);
} ]
}