############################################################################
#
# File: basename.icn
#
# Subject: Procedure to produce base name of file
#
# Author: Frank Lhota, Ralph Griswold, Charles Shartsis
#
# Date: July 19, 1999
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This procedure is based on the UNIX basename(1) utility. It strips off
# any path information and removes the specified suffix, if present.
#
# It should work under UNIX, MS-DOS, and the Macintosh.
#
############################################################################
procedure basename(name, suffix) #: base name of file
local i, base
name ? {
every i := upto('/\\:')
tab(integer(i) + 1) # get rid of path, if any
if ( base := tab ( -*\suffix ) ) & =suffix then return base
else return tab ( 0 )
}
end
This page produced by UniDoc on 2021/04/15 @ 23:59:43.