Lines Matching refs:path
57 rust::String RustExcludeTrailingPathDelimiter(const rust::String& path)
59 std::string tmpPath = std::string(path);
63 rust::String RustIncludeTrailingPathDelimiter(const rust::String& path)
65 std::string tmpPath = std::string(path);
69 bool RustPathToRealPath(const rust::String& path, rust::String& realPath)
71 std::string tmpPath = std::string(path);
82 void RustGetDirFiles(const rust::String& path, rust::vec<rust::String>& files)
84 std::string tmpPath(path);
128 string ExcludeTrailingPathDelimiter(const std::string& path)
130 if (path.rfind("/") != path.size() - 1) {
131 return path;
134 if (!path.empty()) {
135 return path.substr(0, (int)path.size() - 1);
138 return path;
141 string IncludeTrailingPathDelimiter(const std::string& path)
143 if (path.empty()) {
146 if (path.rfind("/") != path.size() - 1) {
147 return path + "/";
150 return path;
153 void GetDirFiles(const string& path, vector<string>& files)
155 DIR *dir = opendir(path.c_str());
157 UTILS_LOGD("Failed to open root dir: %{public}s: %{public}s ", path.c_str(), strerror(errno));
161 string currentPath = ExcludeTrailingPathDelimiter(path);
206 bool ForceCreateDirectory(const string& path)
211 index = path.find('/', index + 1);
213 subPath = path;
215 subPath = path.substr(0, index);
225 return access(path.c_str(), F_OK) == 0;
234 bool ForceRemoveDirectory(const string& path)
238 DIR *dir = opendir(path.c_str());
240 UTILS_LOGE("Failed to open root dir: %{public}s: %{public}s ", path.c_str(), strerror(errno));
306 UTILS_LOGD("Failed to remove some subfile under path: %{public}s", path.c_str());
318 if (faccessat(AT_FDCWD, path.c_str(), F_OK, AT_SYMLINK_NOFOLLOW) == 0) {
319 if (remove(path.c_str()) != 0) {
320 UTILS_LOGE("Failed to remove root dir: %{public}s: %{public}s ", path.c_str(), strerror(errno));
324 return faccessat(AT_FDCWD, path.c_str(), F_OK, AT_SYMLINK_NOFOLLOW) != 0;
336 bool IsEmptyFolder(const string& path)
339 GetDirFiles(path, files);
343 uint64_t GetFolderSize(const string& path)
347 GetDirFiles(path, files);
373 bool ChangeModeDirectory(const string& path, const mode_t& mode)
377 DIR *dir = opendir(path.c_str());
392 subPath = IncludeTrailingPathDelimiter(path) + string(ptr->d_name);
406 string currentPath = ExcludeTrailingPathDelimiter(path);
416 bool PathToRealPath(const string& path, string& realPath)
418 if (path.empty()) {
419 UTILS_LOGD("path is empty!");
423 if ((path.length() >= PATH_MAX)) {
424 UTILS_LOGD("path len is error, the len is: [%{public}zu]", path.length());
429 if (realpath(path.c_str(), tmpPath) == nullptr) {
430 UTILS_LOGE("path (%{public}s) to realpath error: %{public}s", path.c_str(), strerror(errno));