Description
Utility class with functions for file reading and writing.
  Note: initFSProvider() is called by Util::init()
File System Provider
Streamed reading and writing
  
    
      |  |  | 
  
  
    
      |  |  | 
    
      | std::unique_ptr< std::iostream > | open(const FileName & fileName) Return an input and output stream (or nullptr on failure) for reading from and writing to a file.
 | 
    
      |  |  | 
    
      | std::unique_ptr< std::istream > | openForReading(const FileName & fileName) Return an input stream (or nullptr on failure) for reading from a file.
 | 
    
      |  |  | 
    
      | std::unique_ptr< std::ostream > | openForWriting(const FileName & fileName) | 
    
      |  |  | 
    
      | std::unique_ptr< std::ostream > | openForAppending(const FileName & fileName) | 
  
Loading and saving complete files
Misc
Documentation
function
 Util::FileUtils::registerFSProvider
Registers an additional file system provider for the given fsName. Files of the type “fsName://foo.bar” are than handled by that provider
Defined in Util/IO/FileUtils.h:38
function
 Util::FileUtils::open
  
    
      |  |  |  | 
  
  
    
      |  |  |  | 
    
      | std::unique_ptr< std::iostream > open( | const FileName & | fileName ) | 
  
Return an input and output stream (or nullptr on failure) for reading from and writing to a file.
Defined in Util/IO/FileUtils.h:50
function
 Util::FileUtils::openForReading
Return an input stream (or nullptr on failure) for reading from a file.
Defined in Util/IO/FileUtils.h:52
function
 Util::FileUtils::openForWriting
Return an output stream (or nullptr on failure) for writing to a file. The file is truncated: Any current content is discarded, assuming a length of zero on opening.
Defined in Util/IO/FileUtils.h:57
function
 Util::FileUtils::openForAppending
Return an output stream (or nullptr on failure) for appending to a file. The stream’s position indicator is set to the end of the stream before.
Defined in Util/IO/FileUtils.h:62
function
 Util::FileUtils::loadFile
Defined in Util/IO/FileUtils.h:69
function
 Util::FileUtils::getFileContents
Defined in Util/IO/FileUtils.h:70
function
 Util::FileUtils::getParsedFileContents
Defined in Util/IO/FileUtils.h:71
function
 Util::FileUtils::saveFile
  
    
      |  |  |  | 
  
  
    
      |  |  |  | 
    
      | bool saveFile( | const FileName & | filename, | 
    
      |  | const std::vector< uint8_t > & | data, | 
    
      |  | bool | overwrite | 
    
      | ) |  |  | 
  
Defined in Util/IO/FileUtils.h:73
variable
 Util::FileUtils::DIR_FILES
flag for dir(…)
Defined in Util/IO/FileUtils.h:94
variable
 Util::FileUtils::DIR_DIRECTORIES
flag for dir(…)
Defined in Util/IO/FileUtils.h:95
variable
 Util::FileUtils::DIR_RECURSIVE
flag for dir(…)
Defined in Util/IO/FileUtils.h:96
variable
 Util::FileUtils::DIR_HIDDEN_FILES
flag for dir(…)
Defined in Util/IO/FileUtils.h:97
function
 Util::FileUtils::isFile
Defined in Util/IO/FileUtils.h:80
function
 Util::FileUtils::isDir
Defined in Util/IO/FileUtils.h:81
function
 Util::FileUtils::fileSize
Defined in Util/IO/FileUtils.h:82
function
 Util::FileUtils::findFile
Search a file in different paths. The paths are checked absolute and relative to the originating file path.
Parameters
  - fileName
- File name to search.
- pathHints
- List of paths, which are searched for the file.
- newName
- New file name in the case the file was found.
Returns
trueif the file was found andfalseotherwise.
Defined in Util/IO/FileUtils.h:92
function
 Util::FileUtils::dir
Get files and directories in the given directory (path). The resulting filenames are inserted intoresults. The type of entries is determined byflags. DIR_RECURSIVE searches recursive in all subdirectories.
  Note: Only the provider and directory part ofpathis taken; you can create an appropriate Directory-FileName with FileName::createDirName (…)
Defined in Util/IO/FileUtils.h:103
function
 Util::FileUtils::makeRelativeIfPossible
Try to make the givenpathrelative to the givenfixedPath. If the directory ofpath(or the directory to the container in path) begins with the directory offixedPath(or the directory to the container in fixedPath), the directory entry is truncated accordingly.
Returns
true iff the path could be changed
  Note: Example:
fixedPath:          "file://./data/scene/Szene_1.minsg"
        path:               "file://./data/scene/../model/tree1.ply"
    dir of the path begins with the dir of the fixedPath ---> make it relative
        resulting path:     "file://../model/tree1.ply"
  Note: Example:
fixedPath:          "file://./a/b/c/Szene_1.minsg"
        path:               "zip://./a/b/c/d/Foo.zip$./tree1.ply"
    dir of the path begins with the dir of the fixedPath ---> make it relative
        resulting path:     "zip://d/Foo.zip$./tree1.ply"
Defined in Util/IO/FileUtils.h:126
function
 Util::FileUtils::createDir
Defined in Util/IO/FileUtils.h:134
function
 Util::FileUtils::remove
Defined in Util/IO/FileUtils.h:135
function
 Util::FileUtils::generateNewRandFilename
Defined in Util/IO/FileUtils.h:137
function
 Util::FileUtils::copyFile
Copy the file with pathsourceto the file with pathdest. If the destination file already exists, it will be overwritten.
Parameters
  - source
- Path to source file
- dest
- Path to destination file
Returns
trueif successful,falseotherwise
Defined in Util/IO/FileUtils.h:148
function
 Util::FileUtils::flush
Make sure that any pending data will be written to its destination.
Parameters
  - path
- Path that will be used to determine the correct data to be flushed. It is enough if it contains a file system name, e.g. “zip://”, “file://”.
Defined in Util/IO/FileUtils.h:156