ISFileManager.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2021 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef IS_SDK_IS_FILE_MANAGER_H_
14 #define IS_SDK_IS_FILE_MANAGER_H_
15 
16 #include "ISConstants.h"
17 #include <string>
18 #include <vector>
19 #include <ctime>
20 
21 namespace ISFileManager
22 {
23  typedef struct
24  {
25  std::string name;
26  uint64_t size;
28  } file_info_t;
29 
35  bool PathIsDir(const std::string& path);
36 
37  // get all files in a folder - files parameter is not cleared in this function
38  // files contains the full path to the file
39  // return false if no files found, true otherwise
40  bool GetAllFilesInDirectory(const std::string& directory, bool recursive, std::vector<std::string>& files);
41  bool GetAllFilesInDirectory(const std::string& directory, bool recursive, const std::string& regexPattern, std::vector<std::string>& files);
42 
43  bool DeleteFile(const std::string& fullFilePath);
44  void DeleteDirectory(const std::string& directory, bool recursive = true);
45 
46  // get space used in a directory recursively - files is filled with all files in the directory, sorted by modification date, files is NOT cleared beforehand. sortByDate of false sorts by file name
47  uint64_t GetDirectorySpaceUsed(const std::string& directory, bool recursive = true);
48  uint64_t GetDirectorySpaceUsed(const std::string& directory, std::vector<file_info_t>& files, bool sortByDate = true, bool recursive = true);
49  uint64_t GetDirectorySpaceUsed(const std::string& directory, std::string regexPattern, std::vector<file_info_t>& files, bool sortByDate = true, bool recursive = true);
50 
51  // get free space for the disk that the specified directory exists on
52  uint64_t GetDirectorySpaceAvailable(const std::string& directory);
53 
54  // get just the file name from a path
55  std::string GetFileName(const std::string& path);
56 
57  bool TouchFile(const std::string& path);
58 
59 }
60 
61 #endif //IS_SDK_IS_FILE_MANAGER_H_
bool PathIsDir(const std::string &path)
uint64_t GetDirectorySpaceAvailable(const std::string &directory)
bool GetAllFilesInDirectory(const std::string &directory, bool recursive, const std::string &regexPattern, std::vector< std::string > &files)
bool DeleteFile(const std::string &fullFilePath)
std::string GetFileName(const std::string &path)
uint64_t GetDirectorySpaceUsed(const std::string &directory, bool recursive)
void DeleteDirectory(const std::string &directory, bool recursive)
bool TouchFile(const std::string &path)


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57