writablePath - multiple declarations

Function writablePath

Get writable path for specific location.

string writablePath (
  StandardPath type,
  FolderFlag params = cast(FolderFlag)0
) nothrow @safe;

Returns

Path where files of type should be written to by current user, or an empty string if could not determine path.

Parameters

NameDescription
type Location to lookup.
params Union of FolderFlags.

Note

This function does not cache its results.

Example

string downloadsDir = writablePath(StandardPath.downloads, FolderFlag.verify);
if (downloadsDir.length) {
    //Open file dialog with this directory.
} else {
    //Could not detect default downloads directory.
    //Ask user to choose default downloads directory for this application.
}

See Also

StandardPath, FolderFlag, standardPaths

Function writablePath

Evaluate writable path for specific location and append subfolder. This can be used with StandardPath.config and StandardPath.data to retrieve folder specific for this application instead of generic path.

string writablePath (
  StandardPath type,
  string subfolder,
  FolderFlag params = cast(FolderFlag)0
) nothrow @safe;

Returns

Path where files of type should be written to by current user concatenated with subfolder, or an empty string if could not determine path.

Parameters

NameDescription
type Location to lookup.
subfolder Subfolder that will be appended to base writable path.
params Union of FolderFlags. This affects both base path and sub path.

Note

This function does not cache its results.

Example

enum organizationName = "MyLittleCompany";
enum applicationName = "MyLittleApplication";

string configDir = writablePath(StandardPath.config, buildPath(organizationName, applicationName), FolderFlag.create);
if (configDir.length) {
    string configFile = buildPath(configDir, "config.conf");
    //read or write configuration file.
} else {
    throw new Exception("Could not create application config directory");
}