HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filesystem.h File Reference

Utilities for dealing with file names and files portably. More...

#include <cstdint>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <mutex>
#include <string>
#include <vector>
#include <OpenImageIO/export.h>
#include <OpenImageIO/oiioversion.h>
#include <OpenImageIO/span.h>
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/string_view.h>
+ Include dependency graph for filesystem.h:

Go to the source code of this file.

Classes

class  Filesystem::IOProxy
 
class  Filesystem::IOFile
 
class  Filesystem::IOVecOutput
 
class  Filesystem::IOMemReader
 IOProxy subclass for reading that wraps an cspan<char>. More...
 

Namespaces

 Filesystem
 Platform-independent utilities for manipulating file names, files, directories, and other file system miscellany.
 

Macros

#define OIIO_FILESYSTEM_H
 
#define OIIO_FILESYSTEM_SUPPORTS_IOPROXY   1
 
#define OIIO_IOPROXY_HAS_ERROR   1
 

Typedefs

typedef std::ofstream ofstream
 

Functions

OIIO_UTIL_API std::string Filesystem::filename (string_view filepath) noexcept
 
OIIO_UTIL_API std::string Filesystem::extension (string_view filepath, bool include_dot=true) noexcept
 
OIIO_UTIL_API std::string Filesystem::parent_path (string_view filepath) noexcept
 
OIIO_UTIL_API std::string Filesystem::replace_extension (const std::string &filepath, const std::string &new_extension) noexcept
 
OIIO_UTIL_API std::string Filesystem::generic_filepath (string_view filepath) noexcept
 
OIIO_UTIL_API std::vector
< std::string
Filesystem::searchpath_split (string_view searchpath, bool validonly=false)
 
OIIO_UTIL_API void Filesystem::searchpath_split (const std::string &searchpath, std::vector< std::string > &dirs, bool validonly=false)
 
OIIO_UTIL_API std::string Filesystem::searchpath_find (const std::string &filename, const std::vector< std::string > &dirs, bool testcwd=true, bool recursive=false)
 
OIIO_UTIL_API bool Filesystem::get_directory_entries (const std::string &dirname, std::vector< std::string > &filenames, bool recursive=false, const std::string &filter_regex=std::string())
 
OIIO_UTIL_API bool Filesystem::path_is_absolute (string_view path, bool dot_is_absolute=false)
 
OIIO_UTIL_API bool Filesystem::exists (string_view path) noexcept
 
OIIO_UTIL_API bool Filesystem::is_directory (string_view path) noexcept
 
OIIO_UTIL_API bool Filesystem::is_regular (string_view path) noexcept
 
OIIO_UTIL_API bool Filesystem::create_directory (string_view path, std::string &err)
 
bool Filesystem::create_directory (string_view path)
 
OIIO_UTIL_API bool Filesystem::copy (string_view from, string_view to, std::string &err)
 
bool Filesystem::copy (string_view from, string_view to)
 
OIIO_UTIL_API bool Filesystem::rename (string_view from, string_view to, std::string &err)
 
bool Filesystem::rename (string_view from, string_view to)
 
OIIO_UTIL_API bool Filesystem::remove (string_view path, std::string &err)
 
bool Filesystem::remove (string_view path)
 
OIIO_UTIL_API unsigned long long Filesystem::remove_all (string_view path, std::string &err)
 
unsigned long long Filesystem::remove_all (string_view path)
 
OIIO_UTIL_API std::string Filesystem::temp_directory_path ()
 
OIIO_UTIL_API std::string Filesystem::unique_path (string_view model="%%%%-%%%%-%%%%-%%%%")
 
OIIO_UTIL_API FILE * Filesystem::fopen (string_view path, string_view mode)
 Version of fopen that can handle UTF-8 paths even on Windows. More...
 
OIIO_UTIL_API int Filesystem::fseek (FILE *file, int64_t offset, int whence)
 Version of fseek that works with 64 bit offsets on all systems. More...
 
OIIO_UTIL_API int64_t Filesystem::ftell (FILE *file)
 Version of ftell that works with 64 bit offsets on all systems. More...
 
OIIO_UTIL_API std::string Filesystem::current_path ()
 
OIIO_UTIL_API void Filesystem::open (OIIO::ifstream &stream, string_view path, std::ios_base::openmode mode=std::ios_base::in)
 
OIIO_UTIL_API void Filesystem::open (OIIO::ofstream &stream, string_view path, std::ios_base::openmode mode=std::ios_base::out)
 
OIIO_UTIL_API int Filesystem::open (string_view path, int flags)
 
OIIO_UTIL_API bool Filesystem::read_text_file (string_view filename, std::string &str)
 
OIIO_UTIL_API bool Filesystem::write_text_file (string_view filename, string_view str)
 
template<typename T >
bool Filesystem::write_binary_file (string_view filename, cspan< T > data)
 
template<typename T >
bool Filesystem::write_binary_file (string_view filename, const std::vector< T > &data)
 
OIIO_UTIL_API size_t Filesystem::read_bytes (string_view path, void *buffer, size_t n, size_t pos=0)
 
OIIO_UTIL_API std::time_t Filesystem::last_write_time (string_view path) noexcept
 
OIIO_UTIL_API void Filesystem::last_write_time (string_view path, std::time_t time) noexcept
 
OIIO_UTIL_API uint64_t Filesystem::file_size (string_view path) noexcept
 
OIIO_UTIL_API void Filesystem::convert_native_arguments (int argc, const char *argv[])
 Ensure command line arguments are UTF-8 everywhere. More...
 
OIIO_UTIL_API bool Filesystem::enumerate_sequence (string_view desc, std::vector< int > &numbers)
 
OIIO_UTIL_API bool Filesystem::parse_pattern (const char *pattern, int framepadding_override, std::string &normalized_pattern, std::string &framespec)
 
OIIO_UTIL_API bool Filesystem::enumerate_file_sequence (const std::string &pattern, const std::vector< int > &numbers, std::vector< std::string > &filenames)
 
OIIO_UTIL_API bool Filesystem::enumerate_file_sequence (const std::string &pattern, const std::vector< int > &numbers, const std::vector< string_view > &views, std::vector< std::string > &filenames)
 
OIIO_UTIL_API bool Filesystem::scan_for_matching_filenames (const std::string &pattern, const std::vector< string_view > &views, std::vector< int > &frame_numbers, std::vector< string_view > &frame_views, std::vector< std::string > &filenames)
 
OIIO_UTIL_API bool Filesystem::scan_for_matching_filenames (const std::string &pattern, std::vector< int > &numbers, std::vector< std::string > &filenames)
 
OIIO_UTIL_API std::string Filesystem::filename_to_regex (string_view pattern, bool simple_glob=true)
 

Variables

OIIO_NAMESPACE_BEGIN typedef
std::ifstream 
ifstream
 

Detailed Description

Utilities for dealing with file names and files portably.

Some helpful nomenclature:

  • "filename" - a file or directory name, relative or absolute
  • "searchpath" - a list of directories separated by ':' or ';'.

Definition in file filesystem.h.

Macro Definition Documentation

#define OIIO_FILESYSTEM_H

Definition at line 19 of file filesystem.h.

#define OIIO_FILESYSTEM_SUPPORTS_IOPROXY   1

Definition at line 43 of file filesystem.h.

#define OIIO_IOPROXY_HAS_ERROR   1

Definition at line 424 of file filesystem.h.

Typedef Documentation

typedef std::ofstream ofstream

Definition at line 58 of file filesystem.h.

Variable Documentation

OIIO_NAMESPACE_BEGIN typedef std::ifstream ifstream

Definition at line 57 of file filesystem.h.