Directory

From Clean
Jump to navigationJump to search

The Directory module lets you access and manipulate directories. It separates platform dependent file system features from those features that all supported platforms have in common.

The following operations are supported:

  • getting the contents of a directory with various information about all it's files;
  • getting this information for a single file;
  • creating a directory;
  • moving/renaming files/directories;
  • removing files/directories;
  • setting and retrieving the current directory;
  • getting the names of all disks.

Paths can be specified in a platform independent way. Therefore we defined the following types:

::Path = RelativePath [PathStep]
       | AbsolutePath DiskName [PathStep]
// on UNIX systems the DiskName is ignored
// on DOS/Windows/MacOS the ":" is omitted
::PathStep =   PathUp
           |   PathDown String
::DiskName :== String

To reference a file named "a" in the current directory's parent direcory type RelativePath [PathUp, PathDown "a"]. The corresponding platform dependent specifications would be "..\\a" (Windows) " ../a" (Unix) or " ::a" (MacOS). To reference the file named "a" on disk "myDisk" of your Mac type AbsolutePath "myDisk" [PathDown "a"].

The specifications in the definition module should be self explanatory.

Hints: Specifying absolute paths inherently leads into platform dependent programs.To check whether a given file exists use the "getFileInfo" function.