That Terminal
A terminal emulator designed for video making purposes.
share.hh File Reference

Facilities for finding share-files (files supplied with program) and cache-files (files generated by program). More...

#include <string>
#include <string_view>
#include <filesystem>
Include dependency graph for share.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void SaveArg0 (const char *arg0)
 
std::pair< std::filesystem::path, std::filesystem::file_status > FindShareFile (const std::filesystem::path &file_to_find, std::initializer_list< std::string_view > extra_paths={})
 
std::pair< std::filesystem::path, std::filesystem::file_status > FindCacheFile (const std::filesystem::path &file_to_find, bool is_file)
 

Detailed Description

Facilities for finding share-files (files supplied with program) and cache-files (files generated by program).

Function Documentation

◆ FindCacheFile()

std::pair<std::filesystem::path, std::filesystem::file_status> FindCacheFile ( const std::filesystem::path &  file_to_find,
bool  is_file 
)

Attempts to locate a particular file (files generated by that_terminal).

These directories are searched, in order: $HOME/.cache/that_terminal
/home/$USER/.cache/that_terminal
/run/user/$UID
/run/$UID
$TEMP/that_terminal-$UID followed by the extra paths, if given. where $UID stands for value of getuid(), not an environment variable.

Parameters
file_to_findFindname to search for
is_fileTrue if looking for files, false if for directories.
Returns
Pair(path, std::filesystem::status(path)) If is_file = false, returns the path where a directory by given name is found. If is_file = true, returns the path where the file exists or where it could be successfully created, whichever is found first.

◆ FindShareFile()

std::pair<std::filesystem::path, std::filesystem::file_status> FindShareFile ( const std::filesystem::path &  file_to_find,
std::initializer_list< std::string_view >  extra_paths = {} 
)

Attempts to locate a particular file (files supplied with that_terminal).

These directories are searched, in order: arg0_path/share/
$HOME/.local/share/that_terminal/
/home/$USER/.local/share/that_terminal/
/usr/local/share/
/usr/share/ followed by the extra paths, if given.

Parameters
file_to_findFilename to search for
extra_pathsExtra paths to search
Returns
The location where this file is found, if any: pair(path, std::filesystem::status(path)).

◆ SaveArg0()

void SaveArg0 ( const char *  arg0)

This function is to be called by main(). It saves the value of argv[0] so that the files can be located in arg0_path/share/.

Parameters
arg0Value of argv[0]