Module Interface OS:Files

SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST

# OS:Files

This is a subset of the ``Files & Directories`' section of Python's ``os`' package. If you want to add to this module, use the Python function signature where appropriate.

### Import List

        IO

Type Summary
Mode = LONGINT File creation mask.
NameArray = POINTER TO ARRAY OF STRING
Time = LONGREAL Number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time.

Procedure Summary
Exists(STRING): BOOLEAN Return TRUE if an entity path exists.
ListDir(STRING): NameArray Return a list containing the names of the entries in the directory.
MTime(STRING): Time Return modification time of the indicated file.
MakeDirs(STRING, Mode) Recursive directory creation function.
MkDir(STRING, Mode) Creates directory path in the local file system with numeric mode mode.
Remove(STRING) Removes the file path.

Constant Summary
defaultMode Default file creation mask (octal 0777).

Type Detail

### Mode

    TYPE Mode = LONGINT

> File creation mask.

### NameArray

    TYPE NameArray = POINTER TO ARRAY OF STRING

### Time

    TYPE Time = LONGREAL

> Number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time. Subsecond resolution depends on the function used to retrieve the time value, and the operating system in use.

Procedure Detail

### Exists

    PROCEDURE Exists(path: STRING): BOOLEAN

> Return TRUE if an entity path exists.

### ListDir

    PROCEDURE ListDir(path: STRING): NameArray
      RAISES Error;

> Return a list containing the names of the entries in the directory. The list is in arbitrary order. It does not include the special entries ``.`' and ``..`', even if they are present in the directory.

### MTime

    PROCEDURE MTime(path: STRING): Time
      RAISES Error;

> Return modification time of the indicated file.

### MakeDirs

    PROCEDURE MakeDirs(path: STRING;
                       mode: Mode)
      RAISES Error;

> Recursive directory creation function. Like MkDir, but makes all intermediate-level directories needed to contain the leaf directory. This procedure does nothing if the target directory already exists. If the leaf directory does not exists and cannot be created, an exception is raised. [Note: Python actually considers it an error if the directory path already exists. Should we do the same?]

### MkDir

    PROCEDURE MkDir(path: STRING;
                    mode: Mode)
      RAISES Error;

> Creates directory path in the local file system with numeric mode mode. On some systems, mode is ignored. Where it is used, the current ``umask`' value is first masked out.

### Remove

    PROCEDURE Remove(path: STRING)
      RAISES Error;

> Removes the file path.

Constant Detail

### defaultMode

    CONST defaultMode

> Default file creation mask (octal 0777). Minus the flags cleared through ``umask`', all permission bits are set.