clan::Directory Class Reference - ClanLib SDK
Description: clan::Directory Class Reference

Static Public Member Functions | List of all members
clan::Directory Class Reference
clanCore I/O Data

Directory utility class. More...

`#include <directory.h>`

## Static Public Member Functions
static bool | create (const std::string &dir_name, bool recursive=false)
| Create directory.
static std::string | get_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.
static std::string | get_current ()
| Get current directory.
static std::string | get_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.
static std::string | get_resourcedata (const std::string &application_name, const std::string &data_dir_name="Resources")
| Returns the application resource data directory.
static bool | remove (const std::string &dir_name, bool delete_files=false, bool delete_sub_directories=false)
| Remove directory.
static bool | rename (const std::string &old_name, const std::string &new_name)
| Rename directory.
static bool | set_current (const std::string &dir_name)
| Change current directory.

## Detailed Description

Directory utility class.

## Member Function Documentation

## ◆ create()

static bool clan::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.

## ◆ get_appdata()

static std::string clan::Directory::get_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\".\n In OS X, this function returns the directory "~/Library/company_name/application_name/version/".\n 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.

## ◆ get_current()

static std::string clan::Directory::get_current | ( |  | ) |
| static

Get current directory.

Returns
  the current directory path.

## ◆ get_local_appdata()

static std::string clan::Directory::get_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\".\n In OS X, this function returns the directory "~/Library/company_name/application_name/version/".\n 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.

## ◆ get_resourcedata()

static std::string clan::Directory::get_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\".\n 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.\n 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.

## ◆ remove()

static bool clan::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.

## ◆ rename()

static bool clan::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.

## ◆ set_current()

static bool clan::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:

- directory.h