OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
|
Utility class for converting between file system paths and file URLs. More...
#include <path.hpp>
Public Member Functions | |
FileUrlPathConverter () | |
Constructor. More... | |
~FileUrlPathConverter () | |
Defaulted destructor. More... | |
FileUrlPathConverter (const FileUrlPathConverter &)=delete | |
Explicitly deleted copy constructor. More... | |
FileUrlPathConverter (FileUrlPathConverter &&) noexcept=delete | |
Explicitly deleted move constructor. More... | |
FileUrlPathConverter & | operator= (const FileUrlPathConverter &)=delete |
Explicitly deleted copy assignment. More... | |
FileUrlPathConverter & | operator= (FileUrlPathConverter &&) noexcept=delete |
Explicitly deleted move assignment. More... | |
Str | pathToUrl (std::string_view absolutePath, PathType pathType=PathType::kSystem) const |
Construct a file URL from a path. More... | |
Str | pathFromUrl (std::string_view fileUrl, PathType pathType=PathType::kSystem) const |
Construct a path from a file URL. More... | |
Utility class for converting between file system paths and file URLs.
The PathType argument allows POSIX hosts to process paths/URLs for Windows systems and vice versa.
Construction of this class should not be considered cheap (internally, multiple regex patterns are compiled). Once constructed, an instance can be used to process any number of URLs/paths.
Conversion of Windows UNC paths to file URLs is supported, including \\?\
device paths. However, conversion of file URLs back to Windows paths only supports drive paths or standard UNC share paths, not device paths.
Some corner cases that may be technically valid are not currently supported, and will result in an exception if detected. E.g.
..
) as path segments - these may be a security risk.\\?\
) that have forward-slashes within path segments.C|
. Constructor.
~FileUrlPathConverter | ( | ) |
Defaulted destructor.
|
delete |
Explicitly deleted copy constructor.
|
deletenoexcept |
Explicitly deleted move constructor.
|
delete |
Explicitly deleted copy assignment.
|
deletenoexcept |
Explicitly deleted move assignment.
Str pathFromUrl | ( | std::string_view | fileUrl, |
PathType | pathType = PathType::kSystem |
||
) | const |
Construct a path from a file URL.
Note that long Windows paths may exceed the Windows MAX_PATH limit. Working around this, e.g. by transforming the path to a UNC device path (\\?\C:\
or \\?\UNC\host\share
), is left up to the caller.
fileUrl | URL to convert. |
pathType | Platform associated with path. |
pathType
platform.InputValidationException | if the URL or path that it decodes to is invalid or unsupported. |
Str pathToUrl | ( | std::string_view | absolutePath, |
PathType | pathType = PathType::kSystem |
||
) | const |
Construct a file URL from a path.
The path must be absolute and not contain any upward traversals (..
) within it.
Conversion of Windows UNC paths to file URLs is supported, including standard \\
shares, and \\?\
drive and \\?\\UNC\
share device paths.
Note that Windows device paths of the form \\.\
are not supported. This may be added in a future update.
absolutePath | Path string. |
pathType | Platform associated with path. |
InputValidationException | if the path is invalid or unsupported. |
Copyright 2013-2023 The Foundry Visionmongers Ltd. OpenAssetIO is released under the Apache 2.0 License