reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

#include <ofFileUtils.h>

Static Public Member Functions

static std::string getFileExt (const of::filesystem::path &filename)
 
static std::string removeExt (const of::filesystem::path &filename)
 
static std::string addLeadingSlash (const of::filesystem::path &path)
 
static std::string addTrailingSlash (const of::filesystem::path &path)
 
static std::string removeTrailingSlash (const of::filesystem::path &path)
 
static std::string getPathForDirectory (const of::filesystem::path &path)
 
static std::string getAbsolutePath (const of::filesystem::path &path, bool bRelativeToData=true)
 
static bool isAbsolute (const of::filesystem::path &path)
 
static std::string getFileName (const of::filesystem::path &filePath, bool bRelativeToData=true)
 
static std::string getBaseName (const of::filesystem::path &filePath)
 
static std::string getEnclosingDirectory (const of::filesystem::path &filePath, bool bRelativeToData=true)
 
static bool createEnclosingDirectory (const of::filesystem::path &filePath, bool bRelativeToData=true, bool bRecursive=true)
 
static std::string getCurrentWorkingDirectory ()
 
static std::string join (const of::filesystem::path &path1, const of::filesystem::path &path2)
 
static std::string getCurrentExePath ()
 
static std::string getCurrentExeDir ()
 
static std::string getUserHomeDir ()
 
static std::string makeRelative (const of::filesystem::path &from, const of::filesystem::path &to)
 

Detailed Description

Static class for working with file path strings.

Member Function Documentation

◆ addLeadingSlash()

string ofFilePath::addLeadingSlash ( const of::filesystem::path &  path)
static

Prepend path with a slash, ie. "images" -> "/images".

Parameters
pathfile or directory path
Returns
slah + path

◆ addTrailingSlash()

std::string ofFilePath::addTrailingSlash ( const of::filesystem::path &  path)
static

Append path with a slash, ie. "images" -> "images/".

Parameters
pathdirectory path
Returns
path + slash

◆ createEnclosingDirectory()

bool ofFilePath::createEnclosingDirectory ( const of::filesystem::path &  filePath,
bool  bRelativeToData = true,
bool  bRecursive = true 
)
static

Create the enclosing parent directory of a path, ie. "images" is the enclosing directory of "duck.jpg" = "images/duck.jpg".

Assumes the path is in the data folder & automatically creates nested directories as required.

Parameters
bRecursiveset to false to override automatically nested directory creation
bRelativeToDataset to false if you are working with paths that are not in the data folder and want the direct path without relative "../../"
Returns
true if the enclosing directory was created

◆ getAbsolutePath()

std::string ofFilePath::getAbsolutePath ( const of::filesystem::path &  path,
bool  bRelativeToData = true 
)
static

Get the absolute, full path for a given path, ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images".

Parameters
pathfile or directory path
bRelativeToDataset to false if you are working with paths that are not in the data folder and want the direct path without relative "../../"
Returns
absolute path

◆ getBaseName()

string ofFilePath::getBaseName ( const of::filesystem::path &  filePath)
static

Get a file name without its extension, ie. "images/duck.jpg" -> "duck" and "images/some/folder" -> "folder"

Parameters
filePathfile path
Returns
basename

◆ getCurrentExeDir()

std::string ofFilePath::getCurrentExeDir ( )
static

Get the full path to the application's parent directory.

Windows & Linux: the application's parent directory Mac: the Contents/MacOS folder within the application's .app bundle

Returns
current executable directory

◆ getCurrentExePath()

string ofFilePath::getCurrentExePath ( )
static

Get the full path to the application's executable file.

Mac: the binary within the application's .app bundle Contents/MacOS dir Windows: the .exe Linux: the binary file itself

Returns
current executable path

◆ getCurrentWorkingDirectory()

string ofFilePath::getCurrentWorkingDirectory ( )
static

Get the full path to the app's current working directory.

This may be the app's parent directory or the location the app was launched from (aka on the commandline).

Warning
This location may change if you or a library calls the cd() std C function.
Returns
current working directory

◆ getEnclosingDirectory()

std::string ofFilePath::getEnclosingDirectory ( const of::filesystem::path &  filePath,
bool  bRelativeToData = true 
)
static

Get the enclosing parent directory of a path, ie. "images/duck.jpg" -> "images", assumes the path is in the data directory.

Parameters
filePathfile path
bRelativeToDataset to false if you are working with paths that are not in the data folder and want the direct path without relative "../../"
Returns
enclosing directory

◆ getFileExt()

string ofFilePath::getFileExt ( const of::filesystem::path &  filename)
static

Get the extension of a filename, ie. "duck.jpg" -> "jpg".

Parameters
filenamefile path
Returns
filename extension only

◆ getFileName()

string ofFilePath::getFileName ( const of::filesystem::path &  filePath,
bool  bRelativeToData = true 
)
static

Get the filename of a given path by stripping the parent directories ie. "images/duck.jpg" -> "duck.jpg", assumes the path is in the data folder.

Parameters
filePathfile path
bRelativeToDataset to false if you are working with paths that are not in the data folder and want the direct path without relative "../../"
Returns
filename

◆ getPathForDirectory()

string ofFilePath::getPathForDirectory ( const of::filesystem::path &  path)
static

Cleaned up a directory path by adding a trailing slash if needed.

For Windows-style path strings using "\", a "" will be added. For Unix-style path strings using "/", a "/" will be added.

Parameters
pathdirectory path
Returns
cleaned path + trailing slash (if needed)

◆ getUserHomeDir()

string ofFilePath::getUserHomeDir ( )
static

Get the absolute path to the user's home directory.

Mac OSX: /Users/<username> Windows: <root>\Users<username> Linux: /home/<username>

Returns
home directory path

◆ isAbsolute()

bool ofFilePath::isAbsolute ( const of::filesystem::path &  path)
static

Check if a path is an absolute (aka a full path), ie. "images" -> false, "/Users/mickey/of/apps/myApps/Donald/bin/data/images" -> true.

Parameters
pathfile or directory path
Returns
true if the path is an absolute path

◆ join()

std::string ofFilePath::join ( const of::filesystem::path &  path1,
const of::filesystem::path &  path2 
)
static

Create a single path by joining path1 & path2 using a slash, ie. "/hello/world" + "foo/bar" -> "/hello/world/foo/bar".

Parameters
path1left half of the path to join
path2right half of the path to join
Returns
joined path

◆ makeRelative()

std::string ofFilePath::makeRelative ( const of::filesystem::path &  from,
const of::filesystem::path &  to 
)
static

Make one path relative to another, ie. the relative path of "images/felines/lions" to "images/felines/tigers" is "../tigers".

Parameters
fromstarting path
todestination path
Returns
relative path

◆ removeExt()

std::string ofFilePath::removeExt ( const of::filesystem::path &  filename)
static

Remove extension from a filename, ie. "duck.jpg" ->"duck".

Parameters
filenamefile path
Returns
filename without extension

◆ removeTrailingSlash()

string ofFilePath::removeTrailingSlash ( const of::filesystem::path &  path)
static

Remove a path's trailing slash (if found), ie. "images/" -> "images".

Parameters
pathdirectory path
Returns
path minus trailing slash

The documentation for this class was generated from the following files:
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/utils/ofFileUtils.h
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/utils/ofFileUtils.cpp