|
| generator< std::filesystem::path > | hi::v1::glob (glob_pattern pattern) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (std::string_view pattern) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (std::string pattern) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (char const *pattern) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (std::filesystem::path pattern) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (path_location location, std::filesystem::path ref) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (path_location location, std::string_view ref) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (path_location location, std::string ref) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::glob (path_location location, char const *ref) |
| | Find paths on the filesystem that match the glob pattern.
|
| generator< std::filesystem::path > | hi::v1::get_paths (path_location location) |
| | Get a set of paths.
|
| std::optional< std::filesystem::path > | hi::v1::find_path (path_location location, std::filesystem::path const &ref) noexcept |
| | Find a path.
|
| std::filesystem::path | hi::v1::get_path (path_location location) |
| | Get the single and only path.
|
This module contains file handling utilities:
File and file-views
file is a RAII object holding an handle to an open file. You can use access_mode flags to control how a file is opened:
- reading, writing,
- if it should create a new file,
- truncate the an already existing file,
- create the directories when creating a file.
A file_view is a RAII object holding a memory-mapping of the file. This object allows easy and fast access to the data in a file, as-if the file was a std::span<> or std::string_view.
Path locations
The path-locations functions are used to find files and directories based on the context of the operating system, the user account and application.
For example fonts are located in multiple places:
- the font-directory where a user can install their own fonts,
- the font-directory that is part of the application's resources, and
- the font-directory which is shared between all users of the operating system.
To iterate over all the font directories:
}
generator< std::filesystem::path > get_paths(path_location location)
Get a set of paths.
@ font_dirs
The directories where the fonts for the system and resource fonts are located.
Definition path_location.hpp:61
To find the first matching file in one of the font directories:
}
std::optional< std::filesystem::path > find_path(path_location location, std::filesystem::path const &ref) noexcept
Find a path.
Definition path_location.hpp:83
glob
To find files based on a pattern using wild cards like * you can use the glob utilities.
The constructor of the glob_pattern object parses a string or std::filesystem::path which contain one or more of the following tokens:
| Token | Description |
| foo | Matches the text "foo". |
| ? | Matches any single character except '/'. |
| [abcd] | Matches a single character that is 'a', 'b', 'c' or 'd'. |
| [a-d] | Matches a single character that is 'a', 'b', 'c' or 'd'. |
| [-a-d] | Matches a single character that is '-', 'a', 'b', 'c' or 'd'. |
| {foo,bar,baz} | Matches the text "foo", "bar" or "baz". |
| * | Matches zero or more character except '/'. |
| /**/ | Matches one or more directories. A single slash or zero or more characters between two slashes. |
Then the glob() function will search for files and directories matching this pattern. glob() is also overloaded to directly parse a pattern and combine it with path_location.
For example to find all the files in the font directories:
*.ttf ")) {
}
generator< std::filesystem::path > glob(glob_pattern pattern)
Find paths on the filesystem that match the glob pattern.
Definition glob.hpp:875
URL / URI
The URI, URL and URN terms can be confusing, here is a short explanation.
- A URI (Unique Resource Identifier) is a specification for parsing and writing identifiers.
- A URL (Unique Resource Locator) is a type of URI which is used to address things.
- A URN (Unique Resource Name) is a type of URI which is used to name things.
HikoGUI currently implements dereferencing of the following types of URLs:
- relative path: A relative path does not start with a scheme and can be joined with a base URL to get an absolute URL.
- file-URL: A file accessible via the operating system. This scheme supports the following features:
- relative paths (can not be joined using URL joining),
- absolute path (relative to the current drive or file-share),
- relative path on a specific drive,
- absolute path on a specific drive and file-share,
- conversion of drive to a file-share name,
- the server name may be part of the double-slash "//" path or the authority.
- resource-URL: A relative path that converts into a file-path by searching for the first file in one of the directories of path_location::resource_dirs.
Both file: and resource: URLs may be implicitly converted to a std::filesystem::path.