Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Filesystem

DEFINITION MODULE Filesystem;

(* Filesystem Operations *)

TYPE
    Status = (
               success,           (* operation completed successfully     *)
               pathNotFound,      (* no path found with this pathname     *)
               alreadExists,      (* attempt to create an existing entry  *)
               pathTooLong,       (* the passed in pathname is too long   *)
               nameTooLong,       (* the passed in filename is too long   *)
               invalidPath,       (* the passed in pathname is invalid    *)
               invalidName,       (* the passed in filename is invalid    *)
               invalidAttributes, (* the passed in attributes are invalid *)
               accessDenied,      (* the filesystem denied access         *)
               deviceError );     (* the device reported a failure        *)


    Attribute = ( readable, writable, executable, directory );

    Attributes = SET OF Attributes;

CONST
    isReadable = { Attribute.readable };
    isWritable = { Attribute.writable };
    isExecutable = { Attribute.executable };
    isDirectory = { Attribute.directory };
    isReadableAndWritable = { Attribute.readable, Attribute.writable };


(* filesystem parameters *)

PROCEDURE maxFilenameLength : CARDINAL;
(* Returns the maximum filename length *)

PROCEDURE maxPathnameLength : CARDINAL;
(* Returns the maximum pathname length *)


(* operations on filesystem entries *)

PROCEDURE EntryExistsAtPath ( path : ARRAY OF CHAR ) : BOOLEAN;
(* Returns TRUE if a filesystem entry exists at <path>. *)

PROCEDURE attrAtPath ( path       : ARRAY OF CHAR;
                       VAR status : Status ) : Attributes;
(* Returns the file attributes of the filesystem entry at <pathname>. *)

PROCEDURE SetAttrAtPath ( path       : ARRAY OF CHAR;
                          attributes : Attributes;
                          VAR status : Status );
(* Sets the file attributes of the entry at <path> to <attributes>.*)

PROCEDURE CreateEntryAtPath ( pathname : ARRAY OF CHAR;
                              attributes : Attributes;
                              VAR status : Status );
(* Creates a new filesystem entry at <path> with <attributes>. *)

PROCEDURE RenameEntryAtPath ( path, newName : ARRAY OF CHAR;
                              VAR status : Status );
(* Changes the name of the entry at <pathname> to <newName>. *)

PROCEDURE MoveEntryAtPath ( path, newPath : ARRAY OF CHAR;
                            VAR status : Status );
(* Moves the entry at <path> to <newPath>. *)

PROCEDURE RemoveEntryAtPath ( path : ARRAY OF CHAR; VAR status : Status );
(* Removes the filesystem entry at <path>. *)

END Filesystem.