Libraries.System.Path Documentation

The Path class is used to represent a path on the system. A path can be either absolute or relative. This class provides a consistent interface for manipulating paths, and provides a system that is more or less consistent throughout operating systems.

Example Code


// TODO

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetPath()

Get the set path. This may be either relative or absolute; to find out, use the IsPathRelative() and IsPathAbsolute() actions. If no path is set, an InvalidPathError is thrown.

Return

text: the absolute or relative path set for this instance of Path.

Example


use Libraries.System.Path

Path p
p:SetRelativePath("./hello.txt")
output p:GetPath() // willoutput  "./hello.txt"

p:SetAbsolutePath("/Users/jeff")
output p:GetPath() // willoutput  "/Users/jeff"

p:SetAbsolutePath("C:\Windows\")
output p:GetPath() // willoutput  "C:\Windows\"

IsPathAbsolute()

Returns true if the set path is absolute. This action will raise an InvalidPathError if this instance of "Path" does not have a set path using either the SetPathAbsolute() or SetPathRelative() action. An "absolute" path is a path that refers to an exact location on disk--that is, what the path refers to is independent of the current directory. As an example, /hello.txt is an absolute path, as on UNIX systems, it refers to a file under the root of the hard disk, outside of any particular directory. In addition, the path C:\Program Files is also absolute, as it refers to the "Program Files" directory on the "C" drive in Windows. If we were to write the path Program Files this would refer to the "Program Files" in the current directory, which could be on any drive, not necessarily just "C." If a path is not absolute, it is relative. For a description of relative paths, see the IsPathRelative() action in this class.

Return

boolean: true if the path is absolute; false otherwise.

Example


use Libraries.System.Path

Path p
p:SetAbsolutePath("C:\Windows")
output p:IsPathAbsolute() // willoutput  "true", as we called SetAbsolutePath

p:SetAbsolutePath("/Users/jeff") // on Mac and Unix/Linux systems, '/' means root of file system.
output p:IsPathAbsolute() // willoutput  "true", as we called SetAsolutePath

IsPathRelative()

Returns true if the set path is relative. A "relative" path is a path that does not refer to an exact location--that is, what it refers to depends on the current directory our application is in. As an example, the path ./hello.txt is relative, as is foo.txt as these both refer to files in the current directory. In addition, the path images/bar.png is also relative, as it refers to a file in the "images" directory under the current directory. If a path is not relative, it is absolute. For a description of absolute paths, see the IsPathAbsolute() action in this class.

Return

boolean: true if the path is relative; false otherwise.

Example


use Libraries.System.Path

Path p
p:SetRelativePath("./hello.txt")
output p:IsPathRelative() // willoutput  "true", as we called SetRelativePath

SetAbsolutePath(text path)

Set an absolute path. See IsAbsolutePath() for an explanation of absolute paths. If the given path is not absolute, an InvalidPathError will be raised.

Parameters

  • text path: the path to set

Example


use Libraries.System.Path

Path p
p:SetAbsolutePath("C:\Windows")
p:SetAbsolutePath("/Users/jeff") // on Mac and Unix/Linux systems, '/' means root of file system.

SetRelativePath(text path)

Set a relative path. See IsRelativePath() for an explanation of relative paths. If the given path is not relative, an InvalidPathError will be raised.

Parameters

  • text path: the path to set

Example


use Libraries.System.Path

Path p
p:SetRelativePath("./hello.txt") // in current directory
p:SetRelativePath("../../hello.txt") // go 2 directories up from our current directory
p:SetRelativePath("hello.txt") // in current directory