75 return std::filesystem::is_regular_file(f);
82 return std::filesystem::is_directory(p);
89 return std::filesystem::exists(f);
97 std::filesystem::path p(path);
98 return std::filesystem::create_directories(p);
106 std::filesystem::rename(file,newFile);
120 return (std::filesystem::remove_all(path)!=0);
122 return std::filesystem::remove(path);
124 }
catch(std::exception& e) {
125 std::cerr<<e.what()<<
"\n";
142 return std::filesystem::remove(file);
149 std::vector<tString> files;
152 for_each(files.begin(),files.end(),[&](
const auto& file) {
153 std::filesystem::remove(file);
162 std::vector<tString> files;
165 for_each(files.begin(),files.end(),[&](
const auto& file) {
166 std::filesystem::remove(file);
175 return std::filesystem::path(posix_path).make_preferred().string();
184 if (std::filesystem::exists(path)) {
185 for (
const auto & entry : std::filesystem::directory_iterator(path))
186 if (std::filesystem::is_directory(entry.path())) paths.push_back(entry.path());
194 std::filesystem::path p(aPath);
204 if (std::filesystem::exists(path)) {
205 for (
const auto & entry : std::filesystem::directory_iterator(path))
206 if (std::filesystem::is_regular_file(entry.path())) files.push_back(entry.path());
216 if (std::filesystem::exists(path)) {
218 for (
const auto & entry : std::filesystem::directory_iterator(path)) {
221 if ( (ext.compare(
"")!=0) &&
222 (exts.find(ext)!=tString::npos) &&
223 (std::filesystem::is_regular_file(entry.path()))) files.push_back(entry.path());
239 if (std::filesystem::exists(sourcePath)&&std::filesystem::exists(destPath)) {
242 std::filesystem::copy_options copyOptions;
244 copyOptions=std::filesystem::copy_options::update_existing;
246 for (
const auto & entry : std::filesystem::directory_iterator(sourcePath)) {
249 if ( (ext.compare(
"")!=0) && (exts.find(ext)!=tString::npos) &&
250 (std::filesystem::is_regular_file(entry.path()))) std::filesystem::copy(entry.path(),destPath,copyOptions);
265 if (std::filesystem::exists(sourcePath)&&std::filesystem::exists(destPath)) {
266 std::filesystem::copy_options copyOptions;
268 copyOptions=std::filesystem::copy_options::update_existing;
269 std::filesystem::copy(sourcePath,destPath,copyOptions);
283 if (std::filesystem::exists(dest)) {
284 std::filesystem::copy_options copyOptions;
286 copyOptions=std::filesystem::copy_options::overwrite_existing;
287 if (!std::filesystem::equivalent(source,dest)) std::filesystem::copy(source,dest,copyOptions);
290 std::filesystem::copy(source,dest);
310 if (std::filesystem::exists(sourcePath)) {
311 const auto copyOptions = std::filesystem::copy_options::update_existing
312 | std::filesystem::copy_options::recursive;
314 std::filesystem::copy(sourcePath,destPath,copyOptions);
326 for (
const auto & entry : std::filesystem::directory_iterator(path))
327 content.push_back(entry.path());
335 return std::filesystem::current_path() ;
342 return std::filesystem::absolute(path) ;
349 return std::filesystem::path(file).stem();
357 return std::filesystem::path(file).extension();
365 return std::filesystem::path(file).parent_path();;
372 return std::filesystem::path(file).filename();
this class describes the file system IO by default write on standart output
Definition: CORE_IO.h:20
static tString GetPath(const tString &file)
get path containing the file
Definition: CORE_IO.h:364
static tBoolean RemovePath(const tString &path)
remove an empty path
Definition: CORE_IO.h:133
static tString GetCurrentPath()
get the current path
Definition: CORE_IO.h:334
static tString GetFileName(const tString &file)
get path containing the file
Definition: CORE_IO.h:371
static void GetFiles(const tString &path, std::vector< tString > &files)
get all the files within the directory
Definition: CORE_IO.h:202
virtual ~CORE_IO(void)
destroy a CORE_IO
Definition: CORE_IO.h:47
static tBoolean RemoveFile(const tString &file)
remove a file
Definition: CORE_IO.h:141
static tBoolean CopyFiles(const tString &sourcePath, const tString &destPath, const tBoolean &overwrite)
copy all the files within the directory to destination path
Definition: CORE_IO.h:262
static tBoolean CopyFile(const tString &source, const tString &dest, const tBoolean &overwrite)
copy file
Definition: CORE_IO.h:280
static tString GetSystemPath(const tString &posix_path)
get the system path corresponding to posix path
Definition: CORE_IO.h:174
static tString GetPathName(const tString &aPath)
get all the paths within the directory
Definition: CORE_IO.h:193
static tString GetAbsolutePath(const tString &path)
get the absolute path of the path
Definition: CORE_IO.h:341
static tBoolean IsPath(const tString &p)
return true if the path designed by p is a path
Definition: CORE_IO.h:81
static void GetFiles(const tString &path, const tString &exts, std::vector< tString > &files)
get all the files within the directory with extension of the form .ext
Definition: CORE_IO.h:214
static tBoolean CopyFiles(const tString &sourcePath, const tString &exts, const tString &destPath, const tBoolean &overwrite)
copy all the files with extension within the directory to destination path
Definition: CORE_IO.h:235
static void RemoveAllFiles(const tString &path, const tString &exts)
remove all files with extension within the path
Definition: CORE_IO.h:161
static tBoolean CopyPath(const tString &sourcePath, const tString &destPath)
copy path
Definition: CORE_IO.h:309
static tBoolean Exists(const tString &f)
return true if the file or the path exists
Definition: CORE_IO.h:88
static tBoolean CopyFile(const tString &source, const tString &dest)
copy file
Definition: CORE_IO.h:299
static void GetContent(const tString &path, std::vector< tString > &content)
get all the content files or paths within the directory
Definition: CORE_IO.h:324
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: CORE_IO.h:66
static tBoolean CreatePath(const tString &path)
create a path
Definition: CORE_IO.h:96
static tString GetExtension(const tString &file)
get extension of the file
Definition: CORE_IO.h:356
static tBoolean IsFile(const tString &f)
return true if the file is a regular file
Definition: CORE_IO.h:74
static tBoolean Rename(const tString &file, const tString &newFile)
Definition: CORE_IO.h:104
static void RemoveAllFiles(const tString &path)
remove all files within a path
Definition: CORE_IO.h:148
static tString GetBaseName(const tString &file)
get base name of the file
Definition: CORE_IO.h:348
CORE_IO()
build a CORE_IO
Definition: CORE_IO.h:37
static void GetPaths(const tString &path, std::vector< tString > &paths)
get all the paths within the directory
Definition: CORE_IO.h:182
static tBoolean RemovePath(const tString &path, const tBoolean &force)
remove a path
Definition: CORE_IO.h:117
abstract base class for most classes.
Definition: CORE_Object.h:48
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:259
void toLower(tString &s)
turn a string to lower value
Definition: functions.h:375
#define tString
Definition: types.h:147
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151