21 #ifndef CYBER_COMMON_FILE_H_ 22 #define CYBER_COMMON_FILE_H_ 27 #include <sys/types.h> 35 #include "google/protobuf/io/zero_copy_stream_impl.h" 36 #include "google/protobuf/text_format.h" 61 const std::string &file_name);
72 google::protobuf::Message *message);
82 const std::string &file_name);
93 google::protobuf::Message *message);
104 google::protobuf::Message *message);
112 bool GetContent(
const std::string &file_name, std::string *content);
119 const std::string &relative_path);
142 std::vector<std::string>
Glob(
const std::string &pattern);
150 bool CopyFile(
const std::string &from,
const std::string &to);
158 bool CopyDir(
const std::string &from,
const std::string &to);
166 bool Copy(
const std::string &from,
const std::string &to);
190 std::vector<std::string>
ListSubPaths(
const std::string &directory_path,
191 const unsigned char d_type = DT_DIR);
194 const bool remove_extension =
false);
208 #endif // CYBER_COMMON_FILE_H_ std::vector< std::string > ListSubPaths(const std::string &directory_path, const unsigned char d_type=DT_DIR)
List sub-paths.
bool DeleteFile(const std::string &filename)
bool RemoveAllFiles(const std::string &directory_path)
Remove all the files under a specified directory. Note that sub-directories are NOT affected...
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool PathExists(const std::string &path)
Check if the path exists.
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
bool DirectoryExists(const std::string &directory_path)
Check if the directory specified by directory_path exists and is indeed a directory.
bool CopyFile(const std::string &from, const std::string &to)
Copy a file.
bool SetProtoToASCIIFile(const google::protobuf::Message &message, int file_descriptor)
std::string GetFileName(const std::string &path, const bool remove_extension=false)
bool GetType(const std::string &filename, FileType *type)
bool CopyDir(const std::string &from, const std::string &to)
Copy a directory.
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs, and merges the parsed content to the proto.
bool GetContent(const std::string &file_name, std::string *content)
Get file content as string.
bool SetProtoToBinaryFile(const google::protobuf::Message &message, const std::string &file_name)
Sets the content of the file specified by the file_name to be the binary representation of the input ...
bool GetProtoFromASCIIFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as ascii representation of protobufs...
FileType
Definition: file.h:49
bool CreateDir(const std::string &dir)
bool EnsureDirectory(const std::string &directory_path)
Check if a specified directory specified by directory_path exists. If not, recursively create the dir...
bool Copy(const std::string &from, const std::string &to)
Copy a file or directory.
std::string GetCurrentPath()
std::vector< std::string > Glob(const std::string &pattern)
Expand path pattern to matched paths.
bool GetProtoFromBinaryFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as binary representation of protobufs...