Next: filestatus
Up: simlib
Previous: DirectoryFile
FileNameClass
NAME
filenameclass - contains routines to manipulate filenames
DESCRIPTION
Implements standard operations on UNIX filenames for
accessing parts of a filename using the terminology of Unix
'cdh'.
AUTHOR
Gorel Hedin, Lund University.
TERMINOLOGY
DETAILED INTERFACE
class FilenameClass;
Class for manipulation of filenames, extracting parts and
combining directory paths and single file names. All
operations return NEW simula texts.
These operations are the simliar to the "modifiers" h, t, r,
e in UNIX csh. The parts of a filename are named as follows:
head - the part before the last slash
tail - the part after the last slash
basename- the part before the last dot
suffix - the part after the last dot
slash - separator between directories, in Unix a '/'
dot - separator between basename and suffix, in Unix
'.'
If there is no slash in the filename, then
head=tail=filename
If there is no dot in the filename, then basename=filename,
suffix=NOTEXT
Example
Argument: a/b/c.d c .d c. / a/ /a -
Results:
head a/b c .d c. - a - -
tail c.d c .d c. - - a -
basename a/b/c c - c / a/ /a -
suffix d - d - - - - -
(Special cases: '-' means NOTEXT)
Supers: -
Kind: Instantiable
Init: none
Sequencing:
(Head/Tail/Basename/Suffix/HeadAndTail/DefineSeparators)*
OPERATIONS:
Head
text procedure Head(F);
text F; ! full file name.;
Returns the head of filename F.
Tail
text procedure Tail(F);
text F; ! full file name.;
Returns the tail of F.
Basename
text procedure Basename(F);
text F; ! full file name.;
Returns the basename of F.
Suffix
text procedure Suffix(F);
text F; ! full file name.;
Returns the suffix of F.
HeadAndTail
text procedure HeadAndTail(H,T);
text H,T; ! Head and Tail part of constructed filename. ;
Returns H & '/' & T (if default value on separator 'Slash').
BasenameAndSuffix
text procedure BasenameAndSuffix(B,S);
text B,S; ! Basename and Suffix of the constructed
filename. ;
Returns B & '.' & S (if default value on separator 'Dot')
DefineSeparators
procedure DefineSeparators(aSlash,aDot);
character aSlash, aDot;
Re-defines the separators, default vaules are '/' and '.'
respectively.