reference

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

ofFileUtils.cpp File Reference
#include "ofFileUtils.h"
#include "ofLog.h"
#include "ofUtils.h"
#include <pwd.h>
#include <sys/stat.h>
#include <unistd.h>

Classes

struct  StringSort
 

Namespaces

namespace  of
 
namespace  of::priv
 

Functions

void of::priv::initfileutils ()
 
ostream & operator<< (ostream &ostr, const ofBuffer &buf)
 
istream & operator>> (istream &istr, ofBuffer &buf)
 
ofBuffer ofBufferFromFile (const of::filesystem::path &path, bool binary)
 
bool ofBufferToFile (const of::filesystem::path &path, const ofBuffer &buffer, bool binary)
 
void ofEnableDataPath ()
 Enable the use of the data path.
 
void ofDisableDataPath ()
 Disable the use of the data path.
 
bool ofRestoreWorkingDirectoryToDefault ()
 Reset the working directory to the platform default.
 
void ofSetDataPathRoot (const of::filesystem::path &newRoot)
 Set the relative path to the data/ folder from the executable.
 
std::string ofToDataPath (const of::filesystem::path &path, bool makeAbsolute)
 Make a path relative to the location of the data/ folder.
 

Function Documentation

◆ ofBufferFromFile()

ofBuffer ofBufferFromFile ( const of::filesystem::path &  path,
bool  binary = true 
)

Read the contents of a file at path into a buffer.

Opens as a text file by default.

Parameters
pathfile to open
binaryset to false if you are reading a text file & want lines split at endline characters automatically

◆ ofBufferToFile()

bool ofBufferToFile ( const of::filesystem::path &  path,
const ofBuffer buffer,
bool  binary = true 
)

Write the contents of a buffer to a file at path.

Saves as a text file by default.

Parameters
pathfile to open
bufferdata source to write from
binaryset to false if you are writing a text file & want lines split at endline characters automatically

◆ ofDisableDataPath()

void ofDisableDataPath ( )

Disable the use of the data path.

This function causes ofToDataPath() to ignore the relative path set with ofSetDataPathRoot().

◆ ofEnableDataPath()

void ofEnableDataPath ( )

Enable the use of the data path.

Path

This function causes ofToDataPath() to respect the relative path set with ofSetDataPathRoot(). This is enabled by default.

◆ ofRestoreWorkingDirectoryToDefault()

bool ofRestoreWorkingDirectoryToDefault ( )

Reset the working directory to the platform default.

The default working directory is where the application was started from or the exe directory in case of osx bundles. GLUT might change the default working directory to the resources directory in the bundle in osx. This will restore it to the exe dir or whatever was the current dir when the application was started

◆ ofSetDataPathRoot()

void ofSetDataPathRoot ( const of::filesystem::path &  root)

Set the relative path to the data/ folder from the executable.

This method can be useful when users want to embed the data as a resource folder within an *.app bundle on OSX or perhaps work from a shared data folder in the user's Documents directory.

Warning
The provided path must have a trailing slash (/).
Parameters
rootThe path to the data/ folder relative to the app executable.

◆ ofToDataPath()

std::string ofToDataPath ( const of::filesystem::path &  path,
bool  absolute = false 
)

Make a path relative to the location of the data/ folder.

This funtion returns path unchanged if ofDisableDataPath() was called first.

By default, a relative path is returned. Users requiring absolute paths for (e.g. for non-openFrameworks functions), can specify that an absolute path be returned.

Parameters
pathThe path to make relative to the data/ folder.
absoluteSet to true to return an absolute path.
Returns
the new path, unless paths were disabled with ofDisableDataPath().

◆ operator<<()

ostream & operator<< ( ostream &  ostr,
const ofBuffer buf 
)

◆ operator>>()

istream & operator>> ( istream &  istr,
ofBuffer buf 
)