libdcp
Public Member Functions | Private Attributes | List of all members
dcp::File Class Reference

#include <file.h>

Public Member Functions

 File (boost::filesystem::path, std::string mode)
 
 File (File &&other)
 
Fileoperator= (File &&other)
 
 File (File const &)=delete
 
Fileoperator= (File const &)=delete
 
 operator bool () const
 
size_t write (const void *ptr, size_t size, size_t nmemb)
 
size_t read (void *ptr, size_t size, size_t nmemb)
 
int eof ()
 
char * gets (char *s, int size)
 
int puts (char const *s)
 
int seek (int64_t offset, int whence)
 
int64_t tell ()
 
int error ()
 
void checked_write (void const *ptr, size_t size)
 
void checked_read (void *ptr, size_t size)
 
void close ()
 
boost::filesystem::path path () const
 
FILE * take ()
 
FILE * get ()
 
int open_error () const
 

Private Attributes

boost::filesystem::path _path
 
FILE * _file = nullptr
 
int _open_error = 0
 

Detailed Description

A wrapper for stdio files that gives RAII and allows us to open files with UTF-8 names on Windows.

Definition at line 48 of file file.h.

Constructor & Destructor Documentation

◆ File()

File::File ( boost::filesystem::path  path,
std::string  mode 
)
Parameters
pathPath to open
modemode flags, as for fopen(3)

Definition at line 53 of file file.cc.

Member Function Documentation

◆ close()

void File::close ( )

Close the file; it is not necessary to call this as the destructor will do it if required.

Definition at line 96 of file file.cc.

◆ eof()

int File::eof ( )

feof() wrapper

Definition at line 122 of file file.cc.

◆ error()

int File::error ( )

ferror wrapper

Definition at line 214 of file file.cc.

◆ gets()

char * File::gets ( char *  s,
int  size 
)

fgets() wrapper

Definition at line 130 of file file.cc.

◆ open_error()

int dcp::File::open_error ( ) const
inline
Returns
Error returned by the fopen / _wfopen call; errno on POSIX, GetLastError() on Windows.

Definition at line 107 of file file.h.

◆ puts()

int File::puts ( char const *  s)

fputs() wrapper

Definition at line 138 of file file.cc.

◆ read()

size_t File::read ( void *  ptr,
size_t  size,
size_t  nmemb 
)

fread() wrapper

Definition at line 114 of file file.cc.

◆ seek()

int File::seek ( int64_t  offset,
int  whence 
)

fseek/fseeki64 wrapper

Definition at line 189 of file file.cc.

◆ take()

FILE * File::take ( )

Take ownership of the underlying FILE*; the File object will not closed it after this call.

Definition at line 180 of file file.cc.

◆ tell()

int64_t File::tell ( )

ftell/ftelli64 wrapper

Definition at line 201 of file file.cc.

◆ write()

size_t File::write ( const void *  ptr,
size_t  size,
size_t  nmemb 
)

fwrite() wrapper

Definition at line 106 of file file.cc.


The documentation for this class was generated from the following files: