<<<<<<<<<<<<<<<<<

filename(unix) 1 filename(unix)

NAME

filename - object to perform filename parsing and construction.

DESCRIPTION

Filename performs two related activities: it can parse files into its various components, or it can construct filenames from its components, including default values.

Filename considers a file to consist of a directory, filename, and extension. Parsing a file means breaking a file into these pieces. Building a file means using these pieces (including default values) to build a fully elaborated file specification.

A directory is everything up to the last "/" in the file. If there is no "/", then the file has no directory specified.

An extension is everything from the last "." to the last character in the file name. If there is no "." then there is no extension.

A filename is everything in between the last "/" and the last ".".

SUPERCLASS

object

INSTANCE VARIABLES

default_directory the default directory (if directory string is empty) to use when building a file.

default_filename the default filename (if filename string is empty) to use when building a file.

default_extension the default extension (if extension string is empty) to use when building a file.

directory name of directory to use when building files, or the result of parsing a file.

filename name of filename to use when building files, or the result of parsing a file.

extension name of extension to use when building files, or the result of parsing a file.

file fully elaborated file specification

MESSAGES

default_directory= dir_spec set the default directory specification.

default_directory? get the default directory specification.

default_filename= filename_spec set the default filename specification.

default_filename? get the default filename specification.

default_extension= ext_spec set the default extension specification.

default_extension? get the default extension specification.

set_defaults:(dir_spec, filename_spec, ext_spec) set the default directory, filename, and extension specification with a single command.

directory= dir_spec set the directory specification.

directory? get the directory specification.

filename= dir_spec set the filename specification.

filename? get the filename specification.

extension= dir_spec set the extension specification.

extension? get the extension specification.

file= file_spec set the current file specification

parse_file! parse the current file specification into its component pieces.

build_file! build a file specification from the component pieces of the file variable (adding default specifications, if necessary).

EXAMPLE

filename new: f file=`/home/junk.scr' parse_file! print:(directory, filename, extension) ; -> f: directory= (`/home') -> f: filename= (`junk') -> f: extension= (`.scr')

filename new: f set_defaults: (`/home/', `junk', `.scr') file= `joyce_is_trouble' build_file! print: file ; ->f: file= (`/home/joyce_is_trouble.scr')

SEE ALSO

filep


Please send comments and suggestions to
consult@rpi.edu