7#ifndef _AUROSTD_XFILE_H_
8#define _AUROSTD_XFILE_H_
22 namespace fs = std::filesystem;
31 bool SSH_DirectoryMake(
const std::string& user, std::string machine, std::string Directory);
34 bool SubDirectoryLS(
const std::string& directory_raw, std::vector<std::string>& vsubd);
35 bool DirectoryLS(
const std::string& directory_raw, std::vector<std::string>& vfiles);
36 bool DirectoryLS(
const std::string& directory_raw, std::deque<std::string>& vfiles);
39 std::string
dirname(
const std::string& file);
52 bool IsCompressed(
const std::string& FileNameIn, std::string& FileNameOut);
55 bool FileExist(
const std::string& FileName, std::string& FileNameOut);
64 unsigned long long int FileSize(
const std::string& FileName);
65 void InFileExistCheck(
const std::string& routine,
const std::string& FileNameRaw,
const std::ifstream& file_to_check);
68 std::string
TmpStrCreate(
const std::string& identifier_raw =
"",
const std::string& tmpdir_raw =
"",
bool hidden =
false,
bool directory =
false);
69 std::string
TmpFileCreate(
const std::string& identifier =
"",
const std::string& tmpdir =
"",
bool hidden =
false);
70 std::string
TmpDirectoryCreate(
const std::string& identifier =
"",
const std::string& tmpdir =
"",
bool hidden =
false);
73 bool CopyFile(
const std::string& file_from,
const std::string& file_to);
74 bool LinkFile(
const std::string& file_from,
const std::string& file_to,
bool soft =
true);
75 bool file2directory(
const std::string& file,
const std::string& destination);
76 bool file2directory(
const std::vector<std::string>& files,
const std::string& destination);
77 bool file2file(
const std::string& file,
const std::string& destination);
81 bool RemoveFile(
const std::string& directory,
const std::regex& regex_pattern);
88 size_t file2string(
const std::string& FileNameIN, std::string& StringIN);
93 size_t file2vectorstring(
const std::string& FileNameIN, std::vector<std::string>& vline,
bool consecutive =
false,
bool trim_edges =
false);
95 size_t compressfile2vectorstring(
const std::string& FileNameIN, std::vector<std::string>& vline,
bool consecutive =
false,
bool trim_edges =
false);
112 void DecompressFile(
const std::string& file_raw,
const std::string& outfile_raw =
"",
bool keep =
false);
114 void DecompressFiles(
const std::string& archive_file,
const std::string& directory =
"",
bool keep =
false);
117 fs::path
CompressFiles(
const std::vector<std::string>& files,
const fs::path& relative_to_path,
const std::string& archive_name,
compression_type ct =
XZ,
bool keep =
false);
118 bool MatchCompressed(
const std::string& CompressedFileName,
const std::string& FileNameOUT);
131 std::string
get_content(
const std::string& filename,
const std::string& collection);
132 void save_to_file(
const std::string& filename,
const std::string& collection,
const std::string& target_path);
133 void save_to_folder(
const std::string& path,
const std::string& collection,
const std::string& target_path);
void save_to_file(const std::string &filename, const std::string &collection, const std::string &target_path)
write a embedded file into the filesystem
std::string get_content(const std::string &filename, const std::string &collection)
get the content of an embedded file
string get_test_file(string file)
return data for unittests
void save_to_folder(const std::string &path, const std::string &collection, const std::string &target_path)
write a embedded file into the filesystem
aurostd::JSON::object get_unit_test()
return data for unittests
unified namespace to read and write JSON
string basename(const string &file)
returns the basename of file
bool string2file(const string &StringOUTPUT, const std::string &FileNameRawOUTPUT, const compression_type ct, const string &mode)
write string into a file
void CompressFile(const string &file_raw, const compression_type ct, const bool keep)
compress file
bool vectorstring2file(const vtype< string > &vline, const string &FileNameOUT, const compression_type ct)
write a list of strings to file
bool DirectoryLS(const string &directory_raw, vector< string > &vfiles)
returns the content of a directory
bool RemoveDirectory(const string &directory)
remove a file
unsigned long long int FileSize(const string &FileName)
returns in bytes the size of a file
bool RemoveFiles(const string &directory)
removes all regular files inside a directory, not recursive
bool file2directory(const string &file, const string &destination)
move file to directory
string TmpFileCreate(const string &identifier, const string &tmpdir, const bool hidden)
create a string pointing to the location of a unique temp file
long int SecondsSinceFileModified(const string &FileNameRaw)
gets duration since file modification
long int GetTimestampModified(const string &FileNameRaw)
gets modification time
bool stringstream2compressfile(const stringstream &content, const string &file, const compression_type ct)
stringstream to compressed file
const std::vector< std::string > compression_suffix
void compressfiles2compressfiles(const string &directory, const compression_type ct, const bool keep)
convert compressed files in a directory to another compression
string TmpStrCreate(const string &identifier_raw, const string &tmpdir_raw, const bool hidden, const bool directory)
create a string pointing to the location of a unique temp file or directory
void compressfile2compressfile(const string &file, const compression_type ct, const bool keep)
convert a compressed file to another compression
bool CompressFileExist(const string &FileName)
check if a file or its compressed variant exits
string CleanFileName(const string &fileIN)
cleans file names from obvious things
size_t file2string(const string &FileNameIN, string &StringIN)
read the content of a file into a string
void InFileExistCheck(const string &routine, const string &FileNameRaw, const ifstream &file_to_check)
checks if a filestream is empty
utype mode(const xvector< utype > &a)
bool string2compressfile(const string &content, const string &file_raw, const compression_type ct)
string to compressed file
bool DirectoryMake(const string &directory_raw)
create a directory
size_t compressfile2vectorstring(const string &FileNameIN, vector< string > &vline, bool consecutive, bool trim_edges)
write the content of a compressed file into a vector of strings
bool FileExist(const string &FileName)
check if file exists
void compressfile2stringstream(const string &file_raw, stringstream &content)
write the content of a compressed file into a stringstream
bool FileEmpty(const string &FileNameRaw)
check if file is empty
string TmpDirectoryCreate(const string &identifier, const string &tmpdir, const bool hidden)
create a string pointing to the location of a unique temp directory
bool FileNotEmpty(const string &FileName)
check if file is not empty
string dirname(const string &file)
returns the dirname of file
size_t compressfile2string(const string &FileNameIN, string &content)
compressed file to string
bool SSH_DirectoryMake(const string &user, const string &machine, const string &directory_raw)
create a directory on a remote computer
bool CopyFile(const string &file_from, const string &file_to)
copy a file
string GetFileExtension(const string &FileName)
returns the file extension
bool CompressFileWithinList(const vector< string > &list, const string &input)
Determines whether a compressed file is within the list.
bool MatchCompressed(const string &CompressedFileName, const string &FileNameOUT)
compress a file based on the compression of another filed
bool IsCompressed(const string &FileNameIn)
check if a file is compressed
void DecompressFiles(const string &archive_file, const string &directory, const bool keep)
decompress files
bool IsDirectory(const string &path)
check if path is a directory
bool SubDirectoryLS(const string &directory_raw, vector< string > &vsubd)
returns all the subdirectories of a directory, including itself
bool LinkFile(const string &file_from, const string &file_to, const bool soft)
link a file
bool DirectoryWritable(const string &directory_raw)
create a temporary file to check if a directory is writable
bool file2file(const string &file, const string &destination)
move file to another file
void DecompressFile(const string &file_raw, const string &outfile_raw, const bool keep)
decompress file
bool stringstream2file(const stringstream &StringstreamOUTPUT, const string &FileNameOUTPUT, const compression_type ct, const string &mode)
write stringstream into a file
fs::path CompressFiles(const vector< string > &files_raw, const fs::path &relative_to_path, const string &archive_name, const compression_type ct, const bool keep)
compress files
bool DirectorySkipped(const string &directory)
check the existence of a SKIP file
bool DirectoryLocked(const string &directory, const string &LOCK)
check the existence of a LOCK file
bool RemoveFile(const string &file)
remove a file
size_t file2vectorstring(const string &FileNameIN, vector< string > &vline, bool consecutive, bool trim_edges)
write the content of a file into a vector of strings
compression_type GetCompressionType(const fs::path &path)
bool compressfile2tempfile(const string &FileNameIN, string &FileNameOUT)
decompress a file to a temp file
void file2stringstream(const string &FileNameIN, stringstream &StringstreamIN)
write the content of a file into a stringstream 20241216 | Hagen Eckert - add transparent compression...
void CompressInit(archive *a, const compression_type ct, const bool single)
initialize compression
storge container for a JSON object