Fcitx
Public Types | Public Member Functions | Static Public Member Functions | List of all members
fcitx::StandardPath Class Reference

Utility class to open, locate, list files based on XDG standard. More...

#include <fcitx-utils/standardpath.h>

Public Types

enum  Type {
  Type::Config, Type::PkgConfig, Type::Data, Type::Cache,
  Type::Runtime, Type::Addon, Type::PkgData
}
 Enum for location type. More...
 

Public Member Functions

 StandardPath (const std::string &packageName, const std::unordered_map< std::string, std::string > &builtInPath, bool skipBuiltInPath, bool skipUserPath)
 Allow to construct a StandardPath with customized internal value. More...
 
 StandardPath (bool skipFcitxPath, bool skipUserPath)
 
 StandardPath (bool skipFcitxPath=false)
 
void scanDirectories (Type type, const std::function< bool(const std::string &path, bool user)> &scanner) const
 Scan the directories of given type. More...
 
void scanDirectories (const std::string &userDir, const std::vector< std::string > &directories, const std::function< bool(const std::string &path, bool user)> &scanner) const
 Scan the given directories. More...
 
void scanFiles (Type type, const std::string &path, const std::function< bool(const std::string &path, const std::string &dir, bool user)> &scanner) const
 Scan files scan file under [directory]/[path]. More...
 
std::string userDirectory (Type type) const
 Get user writable directory for given type.
 
std::vector< std::string > directories (Type type) const
 Get all directories in the order of priority.
 
std::string locate (Type type, const std::string &path) const
 Check if a file exists.
 
std::vector< std::string > locateAll (Type type, const std::string &path) const
 list all matched files.
 
StandardPathFile open (Type type, const std::string &path, int flags) const
 Open the first matched and succeeded file. More...
 
StandardPathFile openUser (Type type, const std::string &path, int flags) const
 Open the user file.
 
StandardPathFile openSystem (Type type, const std::string &path, int flags) const
 Open the non-user file. More...
 
StandardPathTempFile openUserTemp (Type type, const std::string &pathOrig) const
 Open user file, but create file with mktemp.
 
bool safeSave (Type type, const std::string &pathOrig, const std::function< bool(int)> &callback) const
 Save the file safely with write and rename to make sure the operation is atomic. More...
 
std::map< std::string, std::string > locateWithFilter (Type type, const std::string &path, std::function< bool(const std::string &path, const std::string &dir, bool user)> filter) const
 Locate all files match the filter under first [directory]/[path]. More...
 
template<typename Arg1 , typename... Args>
std::map< std::string, std::string > locate (Type type, const std::string &path, Arg1 arg1, Args... args) const
 Locate all files match the filter under first [directory]/[path]. More...
 
std::vector< StandardPathFileopenAll (Type type, const std::string &path, int flags) const
 Open all files match the first [directory]/[path].
 
StandardPathFileMap multiOpenFilter (Type type, const std::string &path, int flags, std::function< bool(const std::string &path, const std::string &dir, bool user)> filter) const
 Open all files match the filter under first [directory]/[path].
 
template<typename... Args>
StandardPathFileMap multiOpen (Type type, const std::string &path, int flags, Args... args) const
 Open all files match the filter under first [directory]/[path]. More...
 
StandardPathFilesMap multiOpenAllFilter (Type type, const std::string &path, int flags, std::function< bool(const std::string &path, const std::string &dir, bool user)> filter) const
 Open all files match the filter under all [directory]/[path].
 
template<typename... Args>
StandardPathFilesMap multiOpenAll (Type type, const std::string &path, int flags, Args... args) const
 Open all files match the filter under all [directory]/[path]. More...
 
int64_t timestamp (Type type, const std::string &path) const
 
void syncUmask () const
 Sync system umask to internal state. More...
 
bool skipBuiltInPath () const
 Whether this StandardPath is configured to Skip built-in path. More...
 
bool skipUserPath () const
 Whether this StandardPath is configured to Skip user path. More...
 

Static Public Member Functions

static const StandardPathglobal ()
 Return the global instance of StandardPath. More...
 
static const char * fcitxPath (const char *path)
 Return fcitx specific path defined at compile time. More...
 
static std::string fcitxPath (const char *path, const char *subPath)
 Return a path under specific fcitxPath directory. More...
 
static std::string findExecutable (const std::string &name)
 Check if certain executable presents in PATH. More...
 
static bool hasExecutable (const std::string &name)
 Check if certain executable presents in PATH. More...
 

Detailed Description

Utility class to open, locate, list files based on XDG standard.

Definition at line 181 of file standardpath.h.


The documentation for this class was generated from the following files: