Lines Matching refs:path
34 std::string GetTmpFilePath(const std::string& path) { in GetTmpFilePath() argument
35 return android::base::StringPrintf("%s%s", path.c_str(), kTmpFileSuffix); in GetTmpFilePath()
38 std::string GetBackupFilePath(const std::string& path) { in GetBackupFilePath() argument
39 return android::base::StringPrintf("%s%s", path.c_str(), kBackupFileSuffix); in GetBackupFilePath()
42 void UnlinkPossiblyNonExistingFile(const std::string& path) { in UnlinkPossiblyNonExistingFile() argument
43 if (unlink(path.c_str()) < 0) { in UnlinkPossiblyNonExistingFile()
45 PLOG(ERROR) << "Cannot unlink: " << path; in UnlinkPossiblyNonExistingFile()
51 bool FileExists(const std::string& path) { in FileExists() argument
53 return ::stat(path.c_str(), &st) == 0; in FileExists()
63 RestorableFile::RestorableFile(int value, const std::string& path) : unique_file_(value, path) { in RestorableFile() argument
75 std::string path(unique_file_.path()); in reset() local
77 if (!path.empty()) { in reset()
78 UnlinkPossiblyNonExistingFile(GetTmpFilePath(path)); in reset()
83 if (path().empty() || !FileExists(path())) { in CreateBackupFile()
86 std::string backup = GetBackupFilePath(path()); in CreateBackupFile()
88 if (rename(path().c_str(), backup.c_str()) < 0) { in CreateBackupFile()
89 PLOG(ERROR) << "Cannot rename " << path() << " to " << backup; in CreateBackupFile()
96 std::string path(unique_file_.path()); in CommitWorkFile() local
98 unique_file_.reset(-1, path); in CommitWorkFile()
99 if (!path.empty()) { in CommitWorkFile()
100 if (rename(GetTmpFilePath(path).c_str(), path.c_str()) < 0) { in CommitWorkFile()
101 PLOG(ERROR) << "Cannot rename " << GetTmpFilePath(path) << " to " << path; in CommitWorkFile()
103 UnlinkPossiblyNonExistingFile(path); in CommitWorkFile()
104 UnlinkPossiblyNonExistingFile(GetTmpFilePath(path)); in CommitWorkFile()
113 std::string backup = GetBackupFilePath(path()); in RestoreBackupFile()
114 if (path().empty() || !FileExists(backup)) { in RestoreBackupFile()
117 UnlinkPossiblyNonExistingFile(path()); in RestoreBackupFile()
118 if (rename(backup.c_str(), path().c_str()) < 0) { in RestoreBackupFile()
119 PLOG(ERROR) << "Cannot rename " << backup << " to " << path(); in RestoreBackupFile()
126 UnlinkPossiblyNonExistingFile(GetBackupFilePath(path())); in RemoveBackupFile()
134 std::string path(unique_file_.path()); in ResetAndRemoveAllFiles() local
136 RemoveAllFiles(path); in ResetAndRemoveAllFiles()
139 RestorableFile RestorableFile::CreateWritableFile(const std::string& path, int permissions) { in CreateWritableFile() argument
140 std::string tmp_file_path = GetTmpFilePath(path); in CreateWritableFile()
144 if (!path.empty()) { in CreateWritableFile()
150 RestorableFile rf(fd, path); in CreateWritableFile()
154 void RestorableFile::RemoveAllFiles(const std::string& path) { in RemoveAllFiles() argument
155 UnlinkPossiblyNonExistingFile(GetTmpFilePath(path)); in RemoveAllFiles()
156 UnlinkPossiblyNonExistingFile(GetBackupFilePath(path)); in RemoveAllFiles()
157 UnlinkPossiblyNonExistingFile(path); in RemoveAllFiles()