Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ pathutil(3) — NEXTSTEP 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

text(3)

spell(3)

pathutil(3)  —  UNIX Programmer’s Manual

NAME

pathutil - path name utilities

SYNOPSIS

#include <text/pathutil.h>

DESCRIPTION

These functions perform useful transformations on path names.  They constitute the path utilities of the text library, libtext.  The link editor searches this library under the "-ltext" option.  Declarations for these functions may be obtained either from the include file <text/pathutil.h>, or from the master include file <text/text.h>. 

SUMMARY

char ∗ fullPath(char ∗parent, char ∗base);

Returns a pointer to a static array containing parent/base.  If parent is not supplied, "." is used as a default.  Supports the full path length recognized by the file system. 

char ∗ basename(char ∗s);

Returns a pointer to the base component of path name s. 

char ∗ parentname(char ∗s);

Returns a pointer to a static array containing the name of the parent directory of path name s.  Backs up the directory tree using .. if necessary, until the root directory is reached. 

directoryApply(char ∗name, int (∗f)(char ∗parent, char ∗file, struct statbuf ∗b), int recurse);

Enumerates the files in directory name, visiting each file or directory exactly once, and applies f to each one.  Returns the logical AND of the return values of the calls to f.  recurse controls recursion and directory descent as follows:

 If recurse is 0, does not descend into directories.
If recurse is 1, descends into directories.
If recurse is 2, descends into directories and follows symbolic links.
 

directoryApply also responds to two global flags when directory descent is enabled.  If directoryPostDescent is true, directoryApply enumerates directory names after enumerating their contents, rather than before.  If directoryDepthFirst is true, directoryApply descends into directories as they are encountered; otherwise, it buffers the names of directories as they are encountered, then descends into the directories after the contents of the current directory have been enumerated. 

int directoryStat(char ∗parent, char ∗s, struct stat ∗b)

lstat’s parent/s, cacheing the stat buffer in b.  Returns S_IFDIR if ’s’ is a directory, S_IFLNK if ’s’ is a symbolic link, or 0 otherwise. 

char ∗ newDatedFilename(char ∗directory);

Creates a new file in directory with a name of the form dd-mm-yy.nnn.  Returns the name of the new file, or zero if the file was not created. 

char ∗ filenameToRegex(char ∗s);

Generates a regular expression which can be used by recmp(), et. al. from a file name pattern in sh(1) syntax. 

char ∗∗ getPath(char ∗env);

Returns a path list accumulated through calls to setPath() and addPath().  If the accumulated path list is empty, uses the supplied environment variable instead. 

void setPath(char ∗s);

Sets the path list used by getPath to s. 

void addPath(char ∗s);

Adds s to the path list used by getPath. 

char ∗ pwd()

Returns a pointer to a static string containing the current working directory. 

char ∗ AbsolutePath(char ∗s);

Returns the absolute path name of s. 

SEE ALSO

text(3), spell(3)

NeXT, Inc.  —  July 7, 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026