Lines Matching refs:path

80 bool FileExists(const std::string& path, bool follow_symlinks) {  in FileExists()  argument
82 return (follow_symlinks ? stat : lstat)(path.c_str(), &st) == 0; in FileExists()
85 Result<dev_t> FileDeviceId(const std::string& path) { in FileDeviceId() argument
88 stat(path.c_str(), &out) == 0, in FileDeviceId()
91 path, strerror(errno)); in FileDeviceId()
101 Result<ino_t> FileInodeNumber(const std::string& path) { in FileInodeNumber() argument
104 stat(path.c_str(), &out) == 0, in FileInodeNumber()
107 path, strerror(errno)); in FileInodeNumber()
145 bool FileHasContent(const std::string& path) { in FileHasContent() argument
146 return FileSize(path) > 0; in FileHasContent()
149 Result<std::vector<std::string>> DirectoryContents(const std::string& path) { in DirectoryContents() argument
151 std::unique_ptr<DIR, int(*)(DIR*)> dir(opendir(path.c_str()), closedir); in DirectoryContents()
152 CF_EXPECTF(dir != nullptr, "Could not read from dir \"{}\"", path); in DirectoryContents()
160 bool DirectoryExists(const std::string& path, bool follow_symlinks) { in DirectoryExists() argument
162 if ((follow_symlinks ? stat : lstat)(path.c_str(), &st) == -1) { in DirectoryExists()
204 Result<void> ChangeGroup(const std::string& path, in ChangeGroup() argument
212 if (chown(path.c_str(), -1, groupId) != 0) { in ChangeGroup()
214 << path << ", " << group_name << ", " << strerror(errno)); in ChangeGroup()
220 bool CanAccess(const std::string& path, const int mode) { in CanAccess() argument
221 return access(path.c_str(), mode) == 0; in CanAccess()
224 bool IsDirectoryEmpty(const std::string& path) { in IsDirectoryEmpty() argument
225 auto direc = ::opendir(path.c_str()); in IsDirectoryEmpty()
227 LOG(ERROR) << "IsDirectoryEmpty test failed with " << path in IsDirectoryEmpty()
237 LOG(ERROR) << "IsDirectoryEmpty test failed with " << path in IsDirectoryEmpty()
245 Result<void> RecursivelyRemoveDirectory(const std::string& path) { in RecursivelyRemoveDirectory() argument
277 if (nftw(path.c_str(), callback, 128, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) < 0) { in RecursivelyRemoveDirectory()
279 << path << "\": " << strerror(errno)); in RecursivelyRemoveDirectory()
368 std::string AbsolutePath(const std::string& path) { in AbsolutePath() argument
369 if (path.empty()) { in AbsolutePath()
372 if (path[0] == '/') { in AbsolutePath()
373 return path; in AbsolutePath()
375 if (path[0] == '~') { in AbsolutePath()
376 LOG(WARNING) << "Tilde expansion in path " << path <<" is not supported"; in AbsolutePath()
386 return std::string{buffer.data()} + "/" + path; in AbsolutePath()
389 off_t FileSize(const std::string& path) { in FileSize() argument
391 if (stat(path.c_str(), &st) == -1) { in FileSize()
397 bool MakeFileExecutable(const std::string& path) { in MakeFileExecutable() argument
398 LOG(DEBUG) << "Making " << path << " executable"; in MakeFileExecutable()
399 return chmod(path.c_str(), S_IRWXU) == 0; in MakeFileExecutable()
403 std::chrono::system_clock::time_point FileModificationTime(const std::string& path) { in FileModificationTime() argument
405 if (stat(path.c_str(), &st) == -1) { in FileModificationTime()
480 FileSizes SparseFileSizes(const std::string& path) { in SparseFileSizes() argument
481 auto fd = SharedFD::Open(path, O_RDONLY); in SparseFileSizes()
483 LOG(ERROR) << "Could not open \"" << path << "\": " << fd->StrError(); in SparseFileSizes()
489 LOG(ERROR) << "Could not lseek in \"" << path << "\": " << fd->StrError(); in SparseFileSizes()
501 LOG(ERROR) << "Could not lseek in \"" << path << "\": " << fd->StrError(); in SparseFileSizes()
517 LOG(ERROR) << "Could not lseek in \"" << path << "\": " << fd->StrError(); in SparseFileSizes()
538 bool FileIsSocket(const std::string& path) { in FileIsSocket() argument
540 return stat(path.c_str(), &st) == 0 && S_ISSOCK(st.st_mode); in FileIsSocket()
543 int GetDiskUsage(const std::string& path) { in GetDiskUsage() argument
548 du_cmd.AddParameter(path); in GetDiskUsage()
579 std::string FindFile(const std::string& path, const std::string& target_name) { in FindFile() argument
581 WalkDirectory(path, in FindFile()
614 InotifyWatcher(int inotify, const std::string& path, int watch_mode) in InotifyWatcher() argument
616 watch_ = inotify_add_watch(inotify_, path.c_str(), watch_mode); in InotifyWatcher()
625 static Result<void> WaitForFileInternal(const std::string& path, int timeoutSec, in WaitForFileInternal() argument
627 CF_EXPECT_NE(path, "", "Path is empty"); in WaitForFileInternal()
629 if (FileExists(path, true)) { in WaitForFileInternal()
636 const auto parentPath = cpp_dirname(path); in WaitForFileInternal()
637 const auto filename = cpp_basename(path); in WaitForFileInternal()
644 if (FileExists(path, true)) { in WaitForFileInternal()
692 auto WaitForFile(const std::string& path, int timeoutSec) in WaitForFile() argument
693 -> decltype(WaitForFileInternal(path, timeoutSec, 0)) { in WaitForFile()
696 CF_EXPECT(WaitForFileInternal(path, timeoutSec, inotify.get())); in WaitForFile()
701 Result<void> WaitForUnixSocket(const std::string& path, int timeoutSec) { in WaitForUnixSocket() argument
705 CF_EXPECT(WaitForFile(path, timeoutSec), in WaitForUnixSocket()
707 CF_EXPECT(FileIsSocket(path), "Specified path is not a socket"); in WaitForUnixSocket()
720 SharedFD::SocketLocalClient(path, false, SOCK_STREAM, timeRemain); in WaitForUnixSocket()
732 Result<void> WaitForUnixSocketListeningWithoutConnect(const std::string& path, in WaitForUnixSocketListeningWithoutConnect() argument
737 CF_EXPECT(WaitForFile(path, timeoutSec), in WaitForUnixSocketListeningWithoutConnect()
739 CF_EXPECT(FileIsSocket(path), "Specified path is not a socket"); in WaitForUnixSocketListeningWithoutConnect()
752 lsof.AddParameter(path); in WaitForUnixSocketListeningWithoutConnect()
796 const auto& path = path_info.path_to_convert; in CalculatePrefix() local
804 if (path == "~" || android::base::StartsWith(path, "~/")) { in CalculatePrefix()
808 } else if (!android::base::StartsWith(path, "/")) { in CalculatePrefix()
817 const auto& path = path_info.path_to_convert; in EmulateAbsolutePath() local
827 if (path.empty()) { in EmulateAbsolutePath()
835 auto tokens = android::base::Tokenize(path, "/"); in EmulateAbsolutePath()