|
| template<typename RandomGenerator > |
| std::string | pstore::file::details::name_from_template (std::string const &tmpl, RandomGenerator rng) |
| | The name_from_template() function takes the given file name template and returns a string in which a portion of the template is overwritten to create a file name. More...
|
| |
| template<typename WidthType , typename PointeeType , typename Function > |
| std::size_t | pstore::file::details::split (PointeeType *buffer, std::size_t size, Function const &function) |
| | Unfortunately, the Win32 ReadFile() and WriteFile() functions accept size parameters whose type is DWORD whereas our API uses std::size_t. More...
|
| |
|
template<typename WidthType , typename Function > |
| std::size_t | pstore::file::details::split (void *const buffer, std::size_t const size, Function const &function) |
| |
|
template<typename WidthType , typename Function > |
| std::size_t | pstore::file::details::split (void const *const buffer, std::size_t const size, Function const &function) |
| |
|
std::ostream & | pstore::file::operator<< (std::ostream &os, file_handle const &fh) |
| |
| bool | pstore::file::exists (std::string const &path) |
| | Returns true if the file system contains an object at the location given by path. More...
|
| |
| void | pstore::file::unlink (std::string const &path, bool allow_noent=false) |
| | Deletes the file system object at the location given by path. More...
|
| |
Cross platform file management functions and classes.
template<typename RandomGenerator >
| std::string pstore::file::details::name_from_template |
( |
std::string const & |
tmpl, |
|
|
RandomGenerator |
rng |
|
) |
| |
The name_from_template() function takes the given file name template and returns a string in which a portion of the template is overwritten to create a file name.
The template may be any file name with some number of `Xs' appended to it, for example /tmp/temp.XXXXXX. The trailing `Xs' are replaced with a unique alphanumeric combination. The number of unique file names mktemp() can return depends on the number of `Xs' provided.
- Template Parameters
-
| RandomGenerator | A Callable object with the signature equivalent to std::function<unsigned(unsigned)>. The function's result must be in the range 0 to the value given by the single parameter. |
- Parameters
-
| tmpl | A template string which forms the basis for the result string. Any trailing X characters are replaced by characters derived from the result of the rng function. |
| rng | A random number generator function which should return a value in the range [0,max). |
- Returns
- A string derived from the
tmpl argument but with trailing 'X's replaced by random characters from an internal alphabet.
- Note
- This function is used on platforms that don't have a native implementation of the mkstemp() function.
template<typename WidthType , typename PointeeType , typename Function >
| std::size_t pstore::file::details::split |
( |
PointeeType * |
buffer, |
|
|
std::size_t |
size, |
|
|
Function const & |
function |
|
) |
| |
Unfortunately, the Win32 ReadFile() and WriteFile() functions accept size parameters whose type is DWORD whereas our API uses std::size_t.
std::size_t is obviously 64-bits on a 64-bit host, but DWORD is always 32-bit. This function splits up the request into chunks which are no larger than the WidthType max value.
- Template Parameters
-
| WidthType | The integer type whose largest value determines the largest 'chunk' into which the size parameter can be split. |
| PointeeType | The type of the elements of the buffer array. |
| Function | A callable whose signature whose be equivalent to std::function<std::size_t(PointeeType*,WidthType)>. It is called for each chunk into which size is divided. The return value should be the number of bytes processed; the first argument is the first value to process; the second element is the number of contiguous elements to be processed. |
- Parameters
-
| buffer | The base address of the buffer to be processed by the provided callback. |
| size | The total number of bytes to be processed. |
| function | This function is called repeatedly to operate on each portion of the buffer. |
- Returns
- The sum of the values returned by
function.