Lines Matching full:path
57 std::wstring path; in mkstemp() local
58 CHECK(android::base::UTF8ToWide(name_template, &path)) in mkstemp()
59 << "path can't be converted to wchar: " << name_template; in mkstemp()
60 if (_wmktemp_s(path.data(), path.size() + 1) != 0) { in mkstemp()
66 int fd = _wopen(path.c_str(), O_CREAT | O_EXCL | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR); in mkstemp()
72 CHECK(android::base::WideToUTF8(path, &path_utf8)) << "path can't be converted to utf8"; in mkstemp()
74 << "utf8 path can't be assigned back to name_template"; in mkstemp()
80 std::wstring path; in mkdtemp() local
81 CHECK(android::base::UTF8ToWide(name_template, &path)) in mkdtemp()
82 << "path can't be converted to wchar: " << name_template; in mkdtemp()
84 if (_wmktemp_s(path.data(), path.size() + 1) != 0) { in mkdtemp()
88 if (_wmkdir(path.c_str()) != 0) { in mkdtemp()
93 CHECK(android::base::WideToUTF8(path, &path_utf8)) << "path can't be converted to utf8"; in mkdtemp()
95 << "utf8 path can't be assigned back to name_template"; in mkdtemp()
115 CHECK_LT(result, std::size(tmp_dir_w)) << "path truncated to: " << result; in GetSystemTempDir()
117 // GetTempPath() returns a path with a trailing slash, but init() in GetSystemTempDir()
124 CHECK(android::base::WideToUTF8(tmp_dir_w, &tmp_dir)) << "path can't be converted to utf8"; in GetSystemTempDir()
149 unlink(path); in ~TemporaryFile()
160 snprintf(path, sizeof(path), "%s%cTemporaryFile-XXXXXX", tmp_dir.c_str(), OS_PATH_SEPARATOR); in init()
162 fd = mkstemp(path, sizeof(path)); in init()
164 fd = mkstemp(path); in init()
200 nftw(path, callback, 128, FTW_DEPTH | FTW_MOUNT | FTW_PHYS); in ~TemporaryDir()
204 snprintf(path, sizeof(path), "%s%cTemporaryDir-XXXXXX", tmp_dir.c_str(), OS_PATH_SEPARATOR); in init()
206 return (mkdtemp(path, sizeof(path)) != nullptr); in init()
208 return (mkdtemp(path) != nullptr); in init()
247 bool ReadFileToString(const std::string& path, std::string* content, bool follow_symlinks) { in ReadFileToString() argument
251 android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), flags))); in ReadFileToString()
272 static bool CleanUpAfterFailedWrite(const std::string& path) { in CleanUpAfterFailedWrite() argument
275 unlink(path.c_str()); in CleanUpAfterFailedWrite()
281 bool WriteStringToFile(const std::string& content, const std::string& path, in WriteStringToFile() argument
286 android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), flags, mode))); in WriteStringToFile()
296 return CleanUpAfterFailedWrite(path); in WriteStringToFile()
300 return CleanUpAfterFailedWrite(path); in WriteStringToFile()
304 return CleanUpAfterFailedWrite(path); in WriteStringToFile()
310 bool WriteStringToFile(const std::string& content, const std::string& path, in WriteStringToFile() argument
314 android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), flags, 0666))); in WriteStringToFile()
318 return WriteStringToFd(content, fd) || CleanUpAfterFailedWrite(path); in WriteStringToFile()
412 bool RemoveFileIfExists(const std::string& path, std::string* err) { in RemoveFileIfExists() argument
416 int result = stat(path.c_str(), &st); in RemoveFileIfExists()
419 int result = lstat(path.c_str(), &st); in RemoveFileIfExists()
435 if (unlink(path.c_str()) == -1) { in RemoveFileIfExists()
446 bool Readlink(const std::string& path, std::string* result) { in Readlink() argument
455 ssize_t size = readlink(path.c_str(), &buf[0], buf.size()); in Readlink()
470 bool Realpath(const std::string& path, std::string* result) { in Realpath() argument
476 realpath_buf = realpath(path.c_str(), nullptr); in Realpath()
490 std::string path; in GetExecutablePath() local
491 android::base::Readlink("/proc/self/exe", &path); in GetExecutablePath()
492 return path; in GetExecutablePath()
494 char path[PATH_MAX + 1]; in GetExecutablePath()
495 uint32_t path_len = sizeof(path); in GetExecutablePath()
496 int rc = _NSGetExecutablePath(path, &path_len); in GetExecutablePath()
502 return path; in GetExecutablePath()
504 char path[PATH_MAX + 1]; in GetExecutablePath()
505 DWORD result = GetModuleFileName(NULL, path, sizeof(path) - 1); in GetExecutablePath()
506 if (result == 0 || result == sizeof(path) - 1) return ""; in GetExecutablePath()
507 path[PATH_MAX - 1] = 0; in GetExecutablePath()
508 return path; in GetExecutablePath()
521 std::string Basename(std::string_view path) { in Basename() argument
524 // Copy path because basename may modify the string passed in. in Basename()
525 std::string result(path); in Basename()
536 // the storage for 'path'. in Basename()
547 static int _basename_r(const char* path, size_t path_size, char* buffer, size_t buffer_size) { in _basename_r() argument
554 if (path == nullptr || path_size == 0) { in _basename_r()
561 endp = path + path_size - 1; in _basename_r()
562 while (endp > path && *endp == '/') { in _basename_r()
567 if (endp == path && *endp == '/') { in _basename_r()
575 while (startp > path && *(startp - 1) != '/') { in _basename_r()
598 std::string Basename(std::string_view path) { in Basename() argument
600 const auto size = _basename_r(path.data(), path.size(), buf, sizeof(buf)); in Basename()
606 std::string Dirname(std::string_view path) { in Dirname() argument
609 // Copy path because dirname may modify the string passed in. in Dirname()
610 std::string result(path); in Dirname()
621 // the storage for 'path'. in Dirname()
632 static int _dirname_r(const char* path, size_t path_size, char* buffer, size_t buffer_size) { in _dirname_r() argument
638 if (path == nullptr || path_size == 0) { in _dirname_r()
639 path = "."; in _dirname_r()
645 endp = path + path_size - 1; in _dirname_r()
646 while (endp > path && *endp == '/') { in _dirname_r()
651 while (endp > path && *endp != '/') { in _dirname_r()
656 if (endp == path) { in _dirname_r()
657 path = (*endp == '/') ? "/" : "."; in _dirname_r()
664 } while (endp > path && *endp == '/'); in _dirname_r()
666 len = endp - path + 1; in _dirname_r()
685 memcpy(buffer, path, len); in _dirname_r()
690 std::string Dirname(std::string_view path) { in Dirname() argument
692 const auto size = _dirname_r(path.data(), path.size(), buf, sizeof(buf)); in Dirname()