Delete FilesystemInterface::CopyFile.
Only use of this method was to implement the cross-device case of MoveFile on unix systems. In turn, only use of the MoveFile method is in FileRotatingStream::RotateFiles. Since file rotation should never involve any copying of log data, the MoveFile fallback to copying can be deleted. BUG=webrtc:6424 Review-Url: https://codereview.webrtc.org/2747373003 Cr-Commit-Position: refs/heads/master@{#17364}
This commit is contained in:
parent
1523865cc3
commit
7b3ce5b872
@ -118,15 +118,8 @@ class FilesystemInterface {
|
||||
// This moves a file from old_path to new_path, where "old_path" is a
|
||||
// plain file. This DCHECKs and returns false if old_path points to a
|
||||
// directory, and returns true if the function succeeds.
|
||||
// If the new path is on a different volume than the old path, this function
|
||||
// will attempt to copy and, if that succeeds, delete the old path.
|
||||
virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path) = 0;
|
||||
|
||||
// This copies a file from old_path to new_path. This method DCHECKs and
|
||||
// returns false if old_path is a folder, and returns true if the copy
|
||||
// succeeds.
|
||||
virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path) = 0;
|
||||
|
||||
// Returns true if pathname refers to a directory
|
||||
virtual bool IsFolder(const Pathname& pathname) = 0;
|
||||
|
||||
@ -230,10 +223,6 @@ class Filesystem {
|
||||
return EnsureDefaultFilesystem()->MoveFile(old_path, new_path);
|
||||
}
|
||||
|
||||
static bool CopyFile(const Pathname &old_path, const Pathname &new_path) {
|
||||
return EnsureDefaultFilesystem()->CopyFile(old_path, new_path);
|
||||
}
|
||||
|
||||
static bool IsFolder(const Pathname& pathname) {
|
||||
return EnsureDefaultFilesystem()->IsFolder(pathname);
|
||||
}
|
||||
|
||||
@ -204,12 +204,7 @@ bool UnixFilesystem::MoveFile(const Pathname &old_path,
|
||||
LOG(LS_VERBOSE) << "Moving " << old_path.pathname()
|
||||
<< " to " << new_path.pathname();
|
||||
if (rename(old_path.pathname().c_str(), new_path.pathname().c_str()) != 0) {
|
||||
if (errno != EXDEV)
|
||||
return false;
|
||||
if (!CopyFile(old_path, new_path))
|
||||
return false;
|
||||
if (!DeleteFile(old_path))
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -221,31 +216,6 @@ bool UnixFilesystem::IsFolder(const Pathname &path) {
|
||||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
bool UnixFilesystem::CopyFile(const Pathname &old_path,
|
||||
const Pathname &new_path) {
|
||||
LOG(LS_VERBOSE) << "Copying " << old_path.pathname()
|
||||
<< " to " << new_path.pathname();
|
||||
char buf[256];
|
||||
size_t len;
|
||||
|
||||
StreamInterface *source = OpenFile(old_path, "rb");
|
||||
if (!source)
|
||||
return false;
|
||||
|
||||
StreamInterface *dest = OpenFile(new_path, "wb");
|
||||
if (!dest) {
|
||||
delete source;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (source->Read(buf, sizeof(buf), &len, nullptr) == SR_SUCCESS)
|
||||
dest->Write(buf, len, nullptr, nullptr);
|
||||
|
||||
delete source;
|
||||
delete dest;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnixFilesystem::IsTemporaryPath(const Pathname& pathname) {
|
||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC)
|
||||
RTC_DCHECK(provided_app_temp_folder_ != nullptr);
|
||||
|
||||
@ -62,11 +62,6 @@ class UnixFilesystem : public FilesystemInterface {
|
||||
// Returns true if function succeeds.
|
||||
bool MoveFile(const Pathname& old_path, const Pathname& new_path) override;
|
||||
|
||||
// This copies a file from old_path to _new_path where "file" can be a plain
|
||||
// file or directory, which will be copied recursively.
|
||||
// Returns true if function succeeds
|
||||
bool CopyFile(const Pathname& old_path, const Pathname& new_path) override;
|
||||
|
||||
// Returns true if a pathname is a directory
|
||||
bool IsFolder(const Pathname& pathname) override;
|
||||
|
||||
|
||||
@ -160,12 +160,6 @@ bool Win32Filesystem::IsAbsent(const Pathname& path) {
|
||||
return (ERROR_FILE_NOT_FOUND == err || ERROR_PATH_NOT_FOUND == err);
|
||||
}
|
||||
|
||||
bool Win32Filesystem::CopyFile(const Pathname &old_path,
|
||||
const Pathname &new_path) {
|
||||
return ::CopyFile(ToUtf16(old_path.pathname()).c_str(),
|
||||
ToUtf16(new_path.pathname()).c_str(), TRUE) != 0;
|
||||
}
|
||||
|
||||
bool Win32Filesystem::IsTemporaryPath(const Pathname& pathname) {
|
||||
TCHAR buffer[MAX_PATH + 1];
|
||||
if (!::GetTempPath(arraysize(buffer), buffer))
|
||||
|
||||
@ -41,10 +41,6 @@ class Win32Filesystem : public FilesystemInterface {
|
||||
// Returns true if the file is successfully moved
|
||||
virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path);
|
||||
|
||||
// This copies a file from old_path to _new_path
|
||||
// Returns true if function succeeds
|
||||
virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path);
|
||||
|
||||
// Returns true if a pathname is a directory
|
||||
virtual bool IsFolder(const Pathname& pathname);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user