pdal::FileUtils

namespace pdal::FileUtils

Functions

PDAL_DLL std::istream * pdal::FileUtils::openFile(std::string const & filename, bool asBinary = true)

Open an existing file for reading.

Return
Pointer to opened stream.
Parameters
  • filename: Filename.
  • asBinary: Read as binary file (don’t convert /r/n to /n)

PDAL_DLL std::ostream * pdal::FileUtils::createFile(std::string const & filename, bool asBinary = true)

Create a file and open for writing.

Return
Point to opened stream.
Parameters
  • filename: Filename.
  • asBinary: Write as binary file (don’t convert /n to /r/n)

PDAL_DLL bool pdal::FileUtils::directoryExists(const std::string & dirname)

Determine if a directory exists.

Return
Whether a directory exists.
Parameters
  • dirname: Name of directory.

PDAL_DLL bool pdal::FileUtils::createDirectory(const std::string & dirname)

Create a directory.

Return
Whether the directory was created.
Parameters
  • dirname: Directory name.

PDAL_DLL bool pdal::FileUtils::createDirectories(const std::string & path)

Create all directories in the provided path.

Return
on failure
Parameters
  • dirname: Path name.

PDAL_DLL void pdal::FileUtils::deleteDirectory(const std::string & dirname)

Delete a directory and its contents.

Parameters
  • dirname: Directory name.

PDAL_DLL std::vector< std::string > pdal::FileUtils::directoryList(const std::string & dirname)

List the contents of a directory.

Return
List of entries in the directory.
Parameters
  • dirname: Name of directory to list.

PDAL_DLL void pdal::FileUtils::closeFile(std::ostream * ofs)

Close a file created with createFile.

Parameters
  • ofs: Pointer to stream to close.

PDAL_DLL void pdal::FileUtils::closeFile(std::istream * ifs)

Close a file created with openFile.

Parameters
  • ifs: Pointer to stream to close.

PDAL_DLL bool pdal::FileUtils::deleteFile(const std::string & filename)

Delete a file.

Return
true if successful, false otherwise
Parameters
  • filename: Name of file to delete.

PDAL_DLL void pdal::FileUtils::renameFile(const std::string & dest, const std::string & src)

Rename a file.

Parameters
  • dest: Desired filename.
  • src: Source filename.

PDAL_DLL bool pdal::FileUtils::fileExists(const std::string & filename)

Determine if a file exists.

Return
Whether the file exists.
Parameters
  • Filename.:

PDAL_DLL uintmax_t pdal::FileUtils::fileSize(const std::string & filename)

Get the size of a file.

Return
Size of file.
Parameters
  • filename: Filename.

PDAL_DLL std::string pdal::FileUtils::readFileIntoString(const std::string & filename)

Read a file into a string.

Return
File contents as a string
Parameters
  • filename: Filename.

PDAL_DLL std::string pdal::FileUtils::getcwd()

Get the current working directory with trailing separator.

Return
The current working directory.

PDAL_DLL std::string pdal::FileUtils::toAbsolutePath(const std::string & filename)

If the filename is an absolute path, just return it otherwise, make it absolute (relative to current working dir) and return it.

Return
Absolute version of provided filename.
Parameters
  • filename: Name of file to convert to absolute path.

PDAL_DLL std::string pdal::FileUtils::toAbsolutePath(const std::string & filename, const std::string base)

If the filename is an absolute path, just return it otherwise, make it absolute (relative to base dir) and return that.

Return
Absolute version of provided filename relative to base.
Parameters
  • filename: Name of file to convert to absolute path.
  • base: Base name to use.

PDAL_DLL std::string pdal::FileUtils::getFilename(const std::string & path)

Return the file component of the given path, e.g.

“d:/foo/bar/a.c” -> “a.c”

Return
File part of path.
Parameters
  • path: Path from which to extract file component.

PDAL_DLL std::string pdal::FileUtils::getDirectory(const std::string & path)

Return the directory component of the given path, e.g.

“d:/foo/bar/a.c” -> “d:/foo/bar/”

Return
Directory part of path.
Parameters
  • path: Path from which to extract directory component.

PDAL_DLL std::string pdal::FileUtils::stem(const std::string & path)

Return the filename stripped of the extension.

. and .. are returned unchanged.

Return
Stem of filename.
Parameters
  • path: File path from which to extract file stem.

PDAL_DLL bool pdal::FileUtils::isDirectory(const std::string & path)

Determine if path is a directory.

Return
Whether the path represents a directory.
Parameters
  • path: Directory to check.

PDAL_DLL bool pdal::FileUtils::isAbsolutePath(const std::string & path)

Determine if the path is an absolute path.

Return
Whether the path is absolute.
Parameters
  • path: Path to test.

PDAL_DLL void pdal::FileUtils::fileTimes(const std::string & filename, struct tm * createTime, struct tm * modTime)

Get the file creation and modification times.

Parameters
  • filename: Filename.
  • createTime: Pointer to creation time structure.
  • modTime: Pointer to modification time structure.

PDAL_DLL std::string pdal::FileUtils::extension(const std::string & path)

Return the extension of the filename, including the separator (.).

Return
Extension of filename.
Parameters
  • path: File path from which to extract extension.

PDAL_DLL std::vector< std::string > pdal::FileUtils::glob(std::string filespec)

Expand a filespec to a list of files.

Return
List of files that correspond to provided file specification.
Parameters
  • filespec: File specification to expand.