# flibs/strings(n) 1.0 "flibs"

## NAME

flibs/strings - Manipulate file and directory names

## TABLE OF CONTENTS

TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
ROUTINES
COPYRIGHT

## SYNOPSIS

use filedir
rootname = filedir_rootname( filename )
extension = filedir_extension( filename )
basename = filedir_basename( filename )
dirname = filedir_dirname( filename )
dirname = filedir_concat( directory, filename )
newname = filedir_add_extension( filename, extension )

## DESCRIPTION

The filedir contains a number of routines to manipulate file and directory names:

- Strip the extension from a file name and return the "root name".
- Determine instead the extension from a file name and return that.
- Strip the directory name from the path to the file and return the "base name".
- Strip the file name from the path to the file and return the directory.
- Concatenate file and directory names.
- Add an extension to a file name.

These are all relatively simple routines, but they are fairly common, hence the module.

## ROUTINES

The module contains the following routines:

use filedir
  To import the subroutines, use this module.
rootname = filedir_rootname( filename )
  Strips the extension if any off the file name and returns the result.
  character(len=*) filename
    Name of the file
extension = filedir_extension( filename )
  Returns the extension if any found in a file name
  character(len=*) filename
    Name of the file
basename = filedir_basename( filename )
  Returns the base name of a file (so, without the directory part)
  character(len=*) filename
    Name of the file
dirname = filedir_dirname( filename )
  Returns the directory part of a file name
  character(len=*) filename
    Name of the file
dirname = filedir_concat( directory, filename )
  Prepend the directory to the file name
  character(len=*) directory
    Directory to prepend
  character(len=*) filename
    Name of the file
newname = filedir_add_extension( filename, extension )
  Append an extension to the file name
  character(len=*) directory
    Directory to prepend
  character(len=*) filename
    Name of the file

Note: The functions all return strings that are large enough to guarantee that the entire result can be hold. In many cases, the length is the same as that of the input argument, but for instance with file_add_extension it is the sum of the lengths of the two arguments plus 1 (for the dot).

## COPYRIGHT

Copyright © 2005 Arjen Markus <arjenmarkus@sourceforge.net>