uicore::Directory Class Reference

Directory utility class. More...

#include <directory.h>

Static Public Member Functions

static std::string appdata (const std::string &company_name, const std::string &application_name, const std::string &version, bool create_dirs_if_missing=true)
 Returns the current user's roaming application data directory. More...
 
static bool create (const std::string &dir_name, bool recursive=false)
 Create directory. More...
 
static std::string current ()
 Get current directory. More...
 
static std::vector< std::stringdirectories (const std::string &path, bool return_full_path_names=true)
 Returns all subdirectories in a directory. More...
 
static std::vector< std::stringfiles (const std::string &path, bool return_full_path_names=true)
 Returns all files in a directory. More...
 
static std::string local_appdata (const std::string &company_name, const std::string &application_name, const std::string &version, bool create_dirs_if_missing=true)
 Returns the current user's local (nonroaming) application data directory. More...
 
static bool remove (const std::string &dir_name, bool delete_files=false, bool delete_sub_directories=false)
 Remove directory. More...
 
static bool rename (const std::string &old_name, const std::string &new_name)
 Rename directory. More...
 
static std::string resourcedata (const std::string &application_name, const std::string &data_dir_name="Resources")
 Returns the application resource data directory. More...
 
static bool set_current (const std::string &dir_name)
 Change current directory. More...
 

Detailed Description

Directory utility class.

Member Function Documentation

static std::string uicore::Directory::appdata ( const std::string company_name,
const std::string application_name,
const std::string version,
bool  create_dirs_if_missing = true 
)
static

Returns the current user's roaming application data directory.

In Windows, this functions returns special folder directory CSIDL_APPDATA appended with the "company_name\application_name\version" string. A typical path would be "C:\Documents and Settings\username\Application Data\company_name\application_name\version\".
In OS X, this function returns the directory "~/Library/company_name/application_name/version/".
In Linux, this function returns the directory "~/.company_name/application_name/version/".

Parameters
company_name= Company name.
application_name= Application name.
version= Application version.
create_dirs_if_missing= If true, function will create all missing directories in the path.
Returns
the current user's roaming application data directory.
static bool uicore::Directory::create ( const std::string dir_name,
bool  recursive = false 
)
static

Create directory.

Parameters
dir_name= Directory name for create.
recursive= If true, function will create all directories in the path, otherwise only the last directory
Returns
true on success or false on error.
static std::string uicore::Directory::current ( )
static

Get current directory.

Returns
the current directory path.
static std::vector<std::string> uicore::Directory::directories ( const std::string path,
bool  return_full_path_names = true 
)
static

Returns all subdirectories in a directory.

static std::vector<std::string> uicore::Directory::files ( const std::string path,
bool  return_full_path_names = true 
)
static

Returns all files in a directory.

static std::string uicore::Directory::local_appdata ( const std::string company_name,
const std::string application_name,
const std::string version,
bool  create_dirs_if_missing = true 
)
static

Returns the current user's local (nonroaming) application data directory.

In Windows, this functions returns special folder directory CSIDL_LOCAL_APPDATA appended with the "company_name\application_name\version" string. A typical path would be "C:\Documents and Settings\username\Local Settings\Application Data\company_name\application_name\version\".
In OS X, this function returns the directory "~/Library/company_name/application_name/version/".
In Linux, this function returns the directory "~/.company_name/application_name/version/".

Parameters
company_name= Company name.
application_name= Application name.
version= Application version.
create_dirs_if_missing= If true, function will create all missing directories in the path.
Returns
the current user's local (nonroaming) application data directory.
static bool uicore::Directory::remove ( const std::string dir_name,
bool  delete_files = false,
bool  delete_sub_directories = false 
)
static

Remove directory.

Parameters
dir_name= Directory name for delete.
delete_files= If true, function will delete files.
delete_sub_directories= If true, function will delete subdirectories too.
Returns
true on success or false on error.
static bool uicore::Directory::rename ( const std::string old_name,
const std::string new_name 
)
static

Rename directory.

Parameters
old_name= Old name of the directory to be renamed.
new_name= New directory name.
Returns
true on success or false on error.
static std::string uicore::Directory::resourcedata ( const std::string application_name,
const std::string data_dir_name = "Resources" 
)
static

Returns the application resource data directory.

In Windows, this function returns a data_dir_name subdirectory located at the executable. If the executable path is "C:\Program Files\My Application\MyApp.exe", then it will return the path "C:\Program Files\My Application\data_dir_name\".
In OS X, this function returns a "Resources" subdirectory inside the application bundle. For example, if the application executable path is "/Applications/MyApplication.app/Contents/MacOS/MyApplication", then it will return "/Applications/MyApplication.app/Contents/Resources/". If the executable is not in an application bundle, it will use the same behavior as in Windows; that is, it will return a data_dir_name subdirectory next to the executable.
In Linux, this function will return the directory "../share/application_name/" relative to the executable, so if it is located in "/usr/bin" it will return "/usr/share/application_name/"

Parameters
application_name= Application name.
data_dir_name= Data directory name.
Returns
the application resource data directory.
static bool uicore::Directory::set_current ( const std::string dir_name)
static

Change current directory.

Parameters
dir_name= Directory name to change to.
Returns
true on success or false on error.

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