--------------------------------------------------------------------------
INTERFACE--------------------------------------------------------------------------FSUtils ; IMPORT Pathname, TextSeq; FROM Ctypes IMPORT int, const_char_star;
EXCEPTION E(TEXT);--------------------------------------------------------------------------
PROCEDURE Exists(fn : Pathname.T) : BOOLEAN; (* <=> `fn' exists *)--------------------------------------------------------------------------
PROCEDURE IsReadable(fn : Pathname.T) : BOOLEAN; (* <=> `fn' is readable by this process *)--------------------------------------------------------------------------
PROCEDURE IsWritable(fn : Pathname.T) : BOOLEAN; (* <=> `fn' is writable by this process *)--------------------------------------------------------------------------
PROCEDURE IsExecutable(fn : Pathname.T) : BOOLEAN; (* <=> `fn' is executable by this process *)--------------------------------------------------------------------------
PROCEDURE IsDir(fn : Pathname.T) : BOOLEAN; (* <=> `fn' is a directory *)--------------------------------------------------------------------------
PROCEDURE IsFile(fn : Pathname.T) : BOOLEAN; (* <=> `fn' is an ordinary file *)--------------------------------------------------------------------------
PROCEDURE MakeDir(path : Pathname.T); (* Build all directories in `path', if they do not exist, or crash. *)--------------------------------------------------------------------------
PROCEDURE SubDirs(path : Pathname.T; relative := FALSE) : TextSeq.T RAISES {E}; (* Return a list of all subdirectories. *)--------------------------------------------------------------------------
PROCEDURE SubFiles(path : Pathname.T; relative := FALSE) : TextSeq.T RAISES {E}; (* Return a list of all ordinary files in directory `path'. *)--------------------------------------------------------------------------
PROCEDURE RemoveFile(fn : Pathname.T); (* Remove file `fn' if it exists and crash in case of errors. *)--------------------------------------------------------------------------
PROCEDURE RemoveDir(fn : Pathname.T); (* Remove directory `fn' if it exists and crash in case of errors. *)--------------------------------------------------------------------------
PROCEDURE TouchFile(fn : Pathname.T); (* Touch the file `fn' and crash in case of errors. *)--------------------------------------------------------------------------
PROCEDURE Mkdir(path : Pathname.T) RAISES {E}; (* Build all directories in `path', if they do not exist. *)--------------------------------------------------------------------------
PROCEDURE Rm(fn : Pathname.T) RAISES {E}; (* Remove file `fn' if it exists. *)--------------------------------------------------------------------------
PROCEDURE Rmdir(fn : Pathname.T) RAISES {E}; (* Remove directory `fn' if it exists. *)--------------------------------------------------------------------------
PROCEDURE RmRec(fn : Pathname.T) RAISES {E}; (* Remove directory `fn' and all its contents recursively. *)--------------------------------------------------------------------------
PROCEDURE Touch(fn : Pathname.T) RAISES {E}; (* Touch the file `fn'. *)--------------------------------------------------------------------------
PROCEDURE CanonicalPathname(fn : Pathname.T) : Pathname.T RAISES {E}; (* Return a unique absolute path for file `fn'. *)--------------------------------------------------------------------------
PROCEDURE Cp(src, dest : Pathname.T) RAISES {E}; (* Copy file `src' to file 'dest'. *)---------------------------------------------------------------------------
PROCEDURE FileContents(fn : Pathname.T) : TEXT RAISES {E}; (* Return the contents of file `fn' as text. *)---------------------------------------------------------------------------
PROCEDURE PutFile(fn : Pathname.T; data : TEXT) RAISES {E}; (* Write `data' into file `fn'. Create or overwrite `fn' as needed. *)---------------------------------------------------------------------------
<*EXTERNAL FSUtils__X_OK*> VAR X_OK: int; (* executable *) <*EXTERNAL FSUtils__W_OK*> VAR W_OK: int; (* writable *) <*EXTERNAL FSUtils__R_OK*> VAR R_OK: int; (* readable *) <*EXTERNAL FSUtils__access*>PROCEDURE access (path: const_char_star; mode: int): int; END FSUtils.