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