Luna::Path

A container that contains a sequence of names that describe one path.

class Luna::Path

Path is one kind of string that describes the location of one node in a hierarchical-based node tree, given that each node in the tree can be identified by a name string. For example, a file path is used to identify a file or folder in the given file system.

Path is designed to be platform-independent and efficient to handle file path related operations. In implementation, the path object does not store the path string directly, but breaks it down to several parts, and stores each part independently. This makes path-related operations very fast and consumes less memory if you need to store lots of paths.

One path is composed by the following components:1. The root name, which usually determines the domain of the path. For example, then volume symbol on Windows (like C:) is one kind of root name.

  1. The directory nodes that composes the path. For example, "C:\Games\MyGame\" has root name "C:" and two directory nodes "Games" and "MyGame". In file object, every directory node as well as the root name is stored independently as one Name object, and they are grouped into one array to form the path sequence.

  2. The path flags, see EPathFlag for details. Basically, path object uses flags to determine if one path is absolute (if begins with one separator), and if one path represents a directory (if it ends with one separator). This flags are properly set when the path string gets parsed, but it may not be correct. For example, if you parse one path string that represents a directory but does not ends with a separator, the EPathFlag::directory will not be set for that path. The path object will not use runtime system calls like file_attribute to determine if one path is valid or represents a directory, it is the user's responsibility to check it before using it.

Member functions