Tkrzw
Classes | Namespaces | Functions | Variables
tkrzw_file_util.h File Reference

File system utilities. More...

#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include <cinttypes>
#include "tkrzw_containers.h"
#include "tkrzw_file.h"
#include "tkrzw_lib_common.h"
#include "tkrzw_thread_util.h"

Classes

struct  tkrzw::FileStatus
 Status information of a file. More...
 
class  tkrzw::TemporaryDirectory
 Temporary directory whose life duration is bound with the object. More...
 
class  tkrzw::PageCache
 Page cache for buffering I/O operations. More...
 
class  tkrzw::FileReader
 File reader. More...
 
class  tkrzw::FlatRecord
 Flat record structure in the file. More...
 
class  tkrzw::FlatRecordReader
 Reader of flat records. More...
 

Namespaces

 tkrzw
 Common namespace of Tkrzw.
 

Functions

std::string tkrzw::MakeTemporaryName ()
 Makes a unique name for a temporary file. More...
 
std::string tkrzw::JoinPath (const std::string &base_path, const std::string &child_name)
 Joins a base path and a child name. More...
 
std::string tkrzw::NormalizePath (const std::string &path)
 Normalizes a file path. More...
 
std::string tkrzw::PathToBaseName (const std::string &path)
 Gets the base name part of a path. More...
 
std::string tkrzw::PathToDirectoryName (const std::string &path)
 Gets the directory name part of a path. More...
 
std::string tkrzw::PathToExtension (const std::string &path)
 Gets the extention part of a path. More...
 
Status tkrzw::GetRealPath (const std::string &path, std::string *real_path)
 Gets the normalized and canonical form of a path. More...
 
Status tkrzw::ReadFileStatus (const std::string &path, FileStatus *fstats)
 Reads status information of a file. More...
 
bool tkrzw::PathIsFile (const std::string &path)
 Checks if a path indicates a regular file. More...
 
int64_t tkrzw::GetFileSize (const std::string &path)
 Gets the size of a file. More...
 
bool tkrzw::PathIsDirectory (const std::string &path)
 Checks if a path indicates a directory. More...
 
std::string tkrzw::GetPathToTemporaryDirectory ()
 Gets the path to a directory for temporary files. More...
 
Status tkrzw::WriteFile (const std::string &path, std::string_view content)
 Writes a file with a content. More...
 
Status tkrzw::WriteFileAtomic (const std::string &path, std::string_view content, const std::string &tmp_path="")
 Writes a file with a content, in an atomic manner by file renaming. More...
 
Status tkrzw::ReadFile (const std::string &path, std::string *content, int64_t max_size=INT32MAX)
 Reads the content from a file. More...
 
std::string tkrzw::ReadFileSimple (const std::string &path, std::string_view default_value="", int64_t max_size=INT32MAX)
 Reads the content from a file, in a simple way. More...
 
Status tkrzw::TruncateFile (const std::string &path, int64_t size)
 Truncates a file. More...
 
Status tkrzw::RemoveFile (const std::string &path)
 Removes a file. More...
 
Status tkrzw::RenameFile (const std::string &src_path, const std::string &dest_path)
 Renames a file. More...
 
Status tkrzw::CopyFileData (const std::string &src_path, const std::string &dest_path)
 Copies the data of a file. More...
 
Status tkrzw::ReadDirectory (const std::string &path, std::vector< std::string > *children)
 Reads a directory. More...
 
Status tkrzw::MakeDirectory (const std::string &path, bool recursive=false)
 Makes a directory. More...
 
Status tkrzw::RemoveDirectory (const std::string &path, bool recursive=false)
 Removes a directory. More...
 
Status tkrzw::SynchronizeFile (const std::string &path)
 Synchronizes a file or a directory. More...
 

Variables

const char tkrzw::DIR_SEP_CHR
 Directory separator character. More...
 
const char *const tkrzw::DIR_SEP_STR
 Directory separator string. More...
 
const char tkrzw::EXT_SEP_CHR
 Extension separator character. More...
 
const char *const tkrzw::EXT_SEP_STR
 Extension separator string. More...
 
const char *const tkrzw::CURRENT_DIR_NAME
 Current directory name. More...
 
const char *const tkrzw::PARENT_DIR_NAME
 Parent directory name. More...
 

Detailed Description

File system utilities.