mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
introduce copy file utility
PiperOrigin-RevId: 683707504
This commit is contained in:
committed by
Copybara-Service
parent
a70d4b096f
commit
117b13d099
@@ -105,4 +105,14 @@ bool CreateHardLink(const std::filesystem::path& target,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CopyFileSafely(const std::filesystem::path& old_path,
|
||||
const std::filesystem::path& new_path) {
|
||||
std::error_code error_code;
|
||||
std::filesystem::copy(old_path, new_path, error_code);
|
||||
if (error_code) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace nearby::sharing
|
||||
|
||||
@@ -56,6 +56,11 @@ bool CreateDirectories(const std::filesystem::path& path);
|
||||
bool CreateHardLink(const std::filesystem::path& target,
|
||||
const std::filesystem::path& link_path);
|
||||
|
||||
// Copies the file at old_path to new_path.
|
||||
// Returns true on success.
|
||||
bool CopyFileSafely(const std::filesystem::path& old_path,
|
||||
const std::filesystem::path& new_path);
|
||||
|
||||
} // namespace nearby::sharing
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_BASE_FILES_H_
|
||||
|
||||
Reference in New Issue
Block a user