Skip to main content
The address of a local or remote file, using the URI format. #include "URL.hpp"

Public Member Functions

Detailed Description

The address of a local or remote file, using the URI format. The URL objects contains the string for a URL path and provides string operations on it. A Project define an URL for each file or folder, the URL will indicate where to fetch the content. A URL is a data location as
A special type of URL is also supported: relative paths
Relative paths infer their global location from their parent directory (PFolder)

Type

The type can be omitted, it is then assumed a “file://” type see URL::getType() “filename” -> “file://filename” The type is tied to a Storage interface, and some project operations ( file access, deletion, etc.) will require the matching Storage plug-in to access the remote file.
Note: (2020R2) only a “file://” interface is provided via StorageFilesystem

Differences with URI specs:

  • a URL object can be initialized with a relative path ( starts with ./) but such an URL is only used for URL composision
  • The single slash file:/path syntax is not supported, only file://...

Path/Filename component

str(), c_str() will return the URL content without the type “file:///path/filename” -> “/path/filename”

Type: file

The file paths are stored with the / separator (if \ windows separator are used, the are converted to /, except file sharing paths)

Constructor & Destructor Documentation

URL() [1/4]

Default constructor.

URL() [2/4]

Constructor from string. Builds URL from string. If type:// is omitted, the type “file” is assumed. Parameters

URL() [3/4]

Constructor from type and path/filename. Builds URL from type and filename. Type is such as “file” Parameters

URL() [4/4]

Constructor from char*. Builds URL from string. If type:// is omitted, the type “file” is assumed. Parameters

~URL()

Destructor.

Member Function Documentation

c_str()

inline

getFilename()

Returns the file component of the URL, path removed. The path is removed and only the filename is returned /path/to/filename -> filename /path/to/ -> (empty string) Returns path/file component of the URL

getFilenamePath()

Returns the path from a filename. Return the path of a file /path/to/file.cas -> /path/to/ /path/folder/ -> /path/folder/ Returns item name as string

getFilenameRoot()

Returns root (suffix removed) from the filename. This function can only be used on file URLs: /path/to/file.cas -> file /path/to/file_cas -> file_cas /path/folder/ -> (empty string) Returns item name as string

getItemName()

Returns the last name (directory or file) from the path. Only the last component of the path is returned, including / for folder name. /path/to/filename -> filename /path/folder/ -> folder/ Returns item name as string

getType()

Return the URL type. Returns type string

getURLComponents()

getURLString()

Returns the full type://path/filename for a URL. The type is always included, even if using implicit file:// ./file -> file://./file /path/file -> file:///path/file Returns Full URL as string

getURLSubset()

Return a subset of the URL components. The getURLComponents() returns an array of the URL items /path/file -> [ / , path/ , file] This function returns the URL forming the subset between indices in this array Parameters Returns URL of the subset, if a folder will end by /

isGlobalPath()

Indicate if URL path/filename is a global path. A global path starts by / , \ (windows file share) or is a windows drive name (i.e. c:/ …) Returns true if global

isInside()

Indicate if URL is inside the specified folder URL. Note that the paths must be exactly the same, symbolic links, aliases or platform-specific case insensivity are not supported Returns true if within the specified path

isLocalPath()

Indicate if URL path/filename is a ./ path. A local path starts by ./ and assumes inside local directory Returns true if relative

isNull()

Indicate if URL path/filename is non null. Returns true if non null

isRelativePath()

Indicate if URL path/filename is a relative path. A relative path starts by ./ or ../ Returns true if relative

isValid()

Indicate if URL is defined. Checks if the URL is non null and atype is defined Returns true if valid

normalizeToFolder()

Ensure the URL is a folder path, if trailing / was missing. Returns false if error

operator!=()

Unequal operator. Returns true if URL::operator==() is false

operator+()

Concatenation operator. Adds the path/filename to the value of current URL and returns the new URL. Returns URL with concatenated value

operator+=()

Self concatenation operator. Adds the path/filename to the current URL modifying the current object. Returns URL with concatenated value

operator==() [1/2]

Equal operator - with string. Returns true if both type and URL string are the same

operator==() [2/2]

Equal operator. Returns true if both type and URL string are the same

simplifyURL()

Simplify URL by removing internal relative paths. Remove relative paths included in the URL, such as /path/to/../file will become /path/file Parameters

str()

Returns the path/file component of the URL. Returns path/file component of the URL

toGlobal()

Convert URL to global path. Appends the URL to the supplied directory Can only be used on a relative URL ( start with ./ or ../ ) Parameters

toRelative()

Convert URL to relative path. Convert the URL to relative from the specified location Can only be used on a global path with a common root Parameters