FileUtils.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 
6 bool CDM_DECL WriteFile(const std::string& content, const std::string& filename);// ASCII Support only
7 bool CDM_DECL ReadFile(const std::string& filename, std::string& content);// ASCII Support only
8 bool CDM_DECL IsDirectory(std::string const& dir);
9 bool CDM_DECL IsRelativePath(std::string const& path);
10 bool CDM_DECL CreatePath(const std::string&);
11 bool CDM_DECL CreateFilePath(const std::string&);
12 std::string CDM_DECL Replace(const std::string& original, const std::string& replace, const std::string& withThis);
13 void CDM_DECL Trim(std::string& s);
14 void CDM_DECL TrimFront(std::string& s);
15 void CDM_DECL TrimBack(std::string& s);
16 void CDM_DECL ListFiles(const std::string& dir, std::vector<std::string>& files, bool recursive, const std::string& mask = "", const std::string& exclusion = "");
17 std::string CDM_DECL GetCurrentWorkingDirectory();
18 void CDM_DECL MakeDirectory(std::string const& dir);
19 bool CDM_DECL DeleteFile(const std::string &dir, short retry=1);
20 bool CDM_DECL DeleteDirectory(const std::string& dir);
21 bool CDM_DECL FileExists(const std::string& filename);
22 bool CDM_DECL FindFileInFilePath(const std::string& filepath, const std::string& find, std::string& found);
23 bool CDM_DECL IsJSONFile(const std::string& filename);
24 std::uintmax_t CDM_DECL FileSize(const std::string& filename);
25 std::string CDM_DECL RelativePathFrom(const std::string& dir, const std::string& filepath);
26 
27 void CDM_DECL SplitPath(const std::string& filepath, std::string& path);
28 void CDM_DECL SplitPathFilename(const std::string& filepath, std::string& path, std::string& filename);
29 // Get the filename (with extension) from a filepath
30 void CDM_DECL SplitFilename(const std::string& filepath, std::string& filename);
31 // Get the base filename and extension of a filepath
32 void CDM_DECL SplitFilenameExt(const std::string& filepath, std::string& filename, std::string& ext);
33 // Get the path from the filename
34 void CDM_DECL SplitPathFilenameExt(const std::string& filepath, std::string& path, std::string& filename, std::string& ext);

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.