Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fileutils.h
Go to the documentation of this file.
1 
18 #ifndef ION_PORT_FILEUTILS_H_
19 #define ION_PORT_FILEUTILS_H_
20 
21 #include <chrono> // NOLINT
22 #include <cstdio>
23 #include <string>
24 #include <vector>
25 
26 namespace ion {
27 namespace port {
28 
32 ION_API std::string GetCanonicalFilePath(const std::string& path);
33 
36 ION_API bool GetFileModificationTime(
37  const std::string& path, std::chrono::system_clock::time_point* time);
38 
42 ION_API std::string GetTemporaryDirectory();
43 
47 ION_API std::string GetTemporaryFilename();
48 
50 ION_API std::string GetCurrentWorkingDirectory();
51 
56 ION_API FILE* OpenFile(const std::string& path, const std::string& mode);
57 
60 ION_API bool ReadDataFromFile(const std::string& path, std::string* out);
61 
64 ION_API bool RemoveFile(const std::string& path);
65 
68 ION_API std::vector<std::string> ListDirectory(const std::string& path);
69 
70 } // namespace port
71 } // namespace ion
72 
73 #endif // ION_PORT_FILEUTILS_H_
std::string GetTemporaryFilename()
Returns a platform-dependent string that names a valid filename which may be opened for reading or wr...
Definition: fileutils.cc:156
std::vector< std::string > ListDirectory(const std::string &path)
Returns the contents of path, non-recursively.
Definition: fileutils.cc:219
std::string GetCurrentWorkingDirectory()
Returns a platform-dependent string that is the current working directory.
Definition: fileutils.cc:57
bool RemoveFile(const std::string &path)
Attempts to remove the file at path and returns whether the file was successfully removed...
Definition: fileutils.cc:209
bool ReadDataFromFile(const std::string &path, std::string *out)
Opens the file at path and read the contents of the file into a string.
Definition: fileutils.cc:191
bool GetFileModificationTime(const std::string &path, std::chrono::system_clock::time_point *time)
Reads the last modification time of the passed file path into time and returns true, iff the file exists.
Definition: fileutils.cc:74
std::string GetCanonicalFilePath(const std::string &path)
Returns a canonical version of a file path string.
Definition: fileutils.cc:40
FILE * OpenFile(const std::string &path, const std::string &mode)
Opens the file at path and returns a FILE pointer suitable for passing to fread, fwrite, fclose, etc.
Definition: fileutils.cc:180
std::string GetTemporaryDirectory()
Returns a platform-dependent string that names the temporary directory.
Definition: fileutils.cc:136