Difference between revisions of "Prokee Module: path"

From prokee
Jump to navigation Jump to search
m (Text replacement - "f.e." to "e.g.")
Line 3: Line 3:
 
A path may relate to a path within the file system, but can also represent a path within a graph. This module handles paths, which are provided as a null-terminated string.
 
A path may relate to a path within the file system, but can also represent a path within a graph. This module handles paths, which are provided as a null-terminated string.
  
If the edges of a graph are named with strings, f.e. ''edge1'', ''edge2'', .... Then a path string could be constructed by appending the names of consecutive edges and separate them with a special character, as f.e. the '/' character. Then we get "''edge1/edge2/edge3''" as a possible path string.
+
If the edges of a graph are named with strings, e.g. ''edge1'', ''edge2'', .... Then a path string could be constructed by appending the names of consecutive edges and separate them with a special character, as e.g. the '/' character. Then we get "''edge1/edge2/edge3''" as a possible path string.
  
Edges must not be named with the empty string. The path "''edge1//edge3''" f.e. will be interpreted as "''edge1/edge3''".
+
Edges must not be named with the empty string. The path "''edge1//edge3''" e.g. will be interpreted as "''edge1/edge3''".
  
 
== Paths within File Systems ==
 
== Paths within File Systems ==

Revision as of 23:02, 3 May 2019

The module path provides functions for manipulating strings which holds paths.

A path may relate to a path within the file system, but can also represent a path within a graph. This module handles paths, which are provided as a null-terminated string.

If the edges of a graph are named with strings, e.g. edge1, edge2, .... Then a path string could be constructed by appending the names of consecutive edges and separate them with a special character, as e.g. the '/' character. Then we get "edge1/edge2/edge3" as a possible path string.

Edges must not be named with the empty string. The path "edge1//edge3" e.g. will be interpreted as "edge1/edge3".

Paths within File Systems

For a path within a file system, we append a '/' character to all directory names, by convention. Therefore the path C:/Users/Max/Documents/ is considered to be a path to a directory, while C:/Users/Max/Documents/mydoc.pdf describes a path to a file.

On Windows systems, the '\' character can be used instead of '/'. The module provides also the option to set an individual character for this purpose.

Special Directories

  • ./ represents the current directory.
  • ../ represents the parent directory.
  • ~/ represents the path to the users directory.

Labels and Root-Directory

A path may begin with the name of a label. Labels are used on different operating systems to name a partition, disk or device. F.e. on the Amiga, paths may start with the name of the floppy disk, as in Extras Disk:mytext.txt or with the name of the floppy drive like in df0:mytext.txt. The character used to mark the end of the label is the colon ':' in these examples. The colon is the default character used for labels. If needed, the module provides functionality to use another symbol instead.

On operating systems which do not support labels, like on Linux, a absolute path starts with a special symbol, the root symbol '/'. The module also allows to alternatively set an individual character as root symbol.

Filename Extension (Suffix)

Filenames may be extended by a suffix. Traditionally on MS-DOS/Windows operating systems, this filename extension consists of up to three characters, which are delimited from the filename by a full stop '.' character. The module allows also longer filename extensions and it also allows to use a different character instead of the full stop.

Absolute and Relative Paths

If a path starts with a label or with the root symbol, then it is considered to be an absolute path. In all other cases the path is considered relative. Mind that ~/ is therefore considered to be relative, while of course it is not.

Implementations