Apollo 10.0
自动驾驶开放平台
apollo::localization::msf::system类 参考

#include <system_utility.h>

apollo::localization::msf::system 的协作图:

静态 Public 成员函数

static bool IsExists (const std::string &path)
 Determine if the file or directory exists.
 
static bool IsDirectory (const std::string &path)
 Determine if the path is a directory.
 
static bool CreateDirectory (const std::string &path)
 Try to create a directory.
 
static bool GetFileSize (const std::string &path, unsigned int *size)
 Get the size of a file.
 
static bool CopyFile (const std::string &src, const std::string &dst, bool is_overwrite=true)
 Copy the file.
 
static void GetFilesInFolderRecursive (const std::string &folder, const std::string &ext, std::vector< std::string > *ret)
 get list of files end with ext in folder.
 
static void GetFilesInFolder (const std::string &folder, const std::string &ext, std::vector< std::string > *ret)
 get list of files end with ext in folder.
 
static void GetFoldersInFolder (const std::string &folder, std::vector< std::string > *ret)
 Get list of folders in folder.
 

详细描述

在文件 system_utility.h26 行定义.

成员函数说明

◆ CopyFile()

bool apollo::localization::msf::system::CopyFile ( const std::string &  src,
const std::string &  dst,
bool  is_overwrite = true 
)
static

Copy the file.

在文件 system_utility.cc54 行定义.

55 {
56 boost::filesystem::path path_src(src);
57 boost::filesystem::path path_dst(dst);
58 boost::system::error_code error;
59 if (is_overwrite) {
60 boost::filesystem::copy_file(path_src, path_dst,
61 boost::filesystem::copy_option::fail_if_exists,
62 error);
63 } else {
64 boost::filesystem::copy_file(
65 path_src, path_dst, boost::filesystem::copy_option::overwrite_if_exists,
66 error);
67 }
68
69 if (error) {
70 return false;
71 }
72
73 return true;
74}

◆ CreateDirectory()

bool apollo::localization::msf::system::CreateDirectory ( const std::string &  path)
static

Try to create a directory.

在文件 system_utility.cc39 行定义.

39 {
40 boost::filesystem::path p(path);
41 return boost::filesystem::create_directory(p);
42}

◆ GetFilesInFolder()

void apollo::localization::msf::system::GetFilesInFolder ( const std::string &  folder,
const std::string &  ext,
std::vector< std::string > *  ret 
)
static

get list of files end with ext in folder.

参数
<ext>should be .jpg instead of jpg.

在文件 system_utility.cc97 行定义.

98 {
99 ret->clear();
100 namespace fs = boost::filesystem;
101 if (!fs::exists(folder) || !fs::is_directory(folder)) {
102 return;
103 }
104
105 fs::directory_iterator it(folder);
106 fs::directory_iterator endit;
107
108 while (it != endit) {
109 if (fs::is_regular_file(*it) && it->path().extension() == ext) {
110 ret->push_back(it->path().string());
111 }
112 ++it;
113 }
114 std::sort(ret->begin(), ret->end());
115}

◆ GetFilesInFolderRecursive()

void apollo::localization::msf::system::GetFilesInFolderRecursive ( const std::string &  folder,
const std::string &  ext,
std::vector< std::string > *  ret 
)
static

get list of files end with ext in folder.

参数
<ext>should be .jpg instead of jpg.

在文件 system_utility.cc76 行定义.

78 {
79 ret->clear();
80 namespace fs = boost::filesystem;
81 if (!fs::exists(folder) || !fs::is_directory(folder)) {
82 return;
83 }
84
85 fs::recursive_directory_iterator it(folder);
86 fs::recursive_directory_iterator endit;
87
88 while (it != endit) {
89 if (fs::is_regular_file(*it) && it->path().extension() == ext) {
90 ret->push_back(it->path().string());
91 }
92 ++it;
93 }
94 std::sort(ret->begin(), ret->end());
95}

◆ GetFileSize()

bool apollo::localization::msf::system::GetFileSize ( const std::string &  path,
unsigned int *  size 
)
static

Get the size of a file.

在文件 system_utility.cc44 行定义.

44 {
45 boost::filesystem::path p(path);
46 if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) {
47 *size = static_cast<unsigned int>(boost::filesystem::file_size(p));
48 return true;
49 }
50
51 return false;
52}

◆ GetFoldersInFolder()

void apollo::localization::msf::system::GetFoldersInFolder ( const std::string &  folder,
std::vector< std::string > *  ret 
)
static

Get list of folders in folder.

在文件 system_utility.cc117 行定义.

118 {
119 ret->clear();
120 namespace fs = boost::filesystem;
121 if (!fs::exists(folder) || !fs::is_directory(folder)) {
122 return;
123 }
124
125 fs::directory_iterator it(folder);
126 fs::directory_iterator endit;
127
128 while (it != endit) {
129 if (fs::is_directory(*it)) {
130 ret->push_back(it->path().string());
131 }
132 ++it;
133 }
134 std::sort(ret->begin(), ret->end());
135}

◆ IsDirectory()

bool apollo::localization::msf::system::IsDirectory ( const std::string &  path)
static

Determine if the path is a directory.

在文件 system_utility.cc34 行定义.

34 {
35 boost::filesystem::path p(path);
36 return boost::filesystem::is_directory(p);
37}

◆ IsExists()

bool apollo::localization::msf::system::IsExists ( const std::string &  path)
static

Determine if the file or directory exists.

在文件 system_utility.cc29 行定义.

29 {
30 boost::filesystem::path p(path);
31 return boost::filesystem::exists(p);
32}

该类的文档由以下文件生成: