Reland "Delete Filesystem::TempFilename."

This is a reland of 6de95f06d0512049553f8120547ab78675e3a76a
Original change's description:
> Delete Filesystem::TempFilename.
>
> Also delete a few unused private members of UnixFilesystem.
>
> Bug: webrtc:6424
> Change-Id: Ib52f2d877690159d197fe767fd04a0d1ade7eb1a
> Reviewed-on: https://webrtc-review.googlesource.com/30301
> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#21148}

Bug: webrtc:6424
Tbr: deadbeef@webrtc.org
Change-Id: Ieda7bd26af51ef2bcc00e4b3197e122e005aacd5
Reviewed-on: https://webrtc-review.googlesource.com/31221
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21273}
This commit is contained in:
Niels Möller
2017-12-06 16:57:23 +01:00
committed by Commit Bot
parent 33fe1dfd3a
commit 408ee5f2c9
5 changed files with 0 additions and 67 deletions

View File

@ -96,9 +96,6 @@ class FilesystemInterface {
// Returns true if pathname refers to a file
virtual bool IsFile(const Pathname& pathname) = 0;
virtual std::string TempFilename(const Pathname &dir,
const std::string &prefix) = 0;
// Determines the size of the file indicated by path.
virtual bool GetFileSize(const Pathname& path, size_t* size) = 0;
};
@ -137,11 +134,6 @@ class Filesystem {
return EnsureDefaultFilesystem()->IsFile(pathname);
}
static std::string TempFilename(const Pathname &dir,
const std::string &prefix) {
return EnsureDefaultFilesystem()->TempFilename(dir, prefix);
}
static bool GetFileSize(const Pathname& path, size_t* size) {
return EnsureDefaultFilesystem()->GetFileSize(path, size);
}

View File

@ -67,22 +67,6 @@ bool UnixFilesystem::DeleteFile(const Pathname &filename) {
return ::unlink(filename.pathname().c_str()) == 0;
}
std::string UnixFilesystem::TempFilename(const Pathname &dir,
const std::string &prefix) {
int len = dir.pathname().size() + prefix.size() + 2 + 6;
char *tempname = new char[len];
snprintf(tempname, len, "%s/%sXXXXXX", dir.pathname().c_str(),
prefix.c_str());
int fd = ::mkstemp(tempname);
if (fd != -1)
::close(fd);
std::string ret(tempname);
delete[] tempname;
return ret;
}
bool UnixFilesystem::MoveFile(const Pathname &old_path,
const Pathname &new_path) {
if (!IsFile(old_path)) {
@ -119,18 +103,6 @@ bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t *size) {
return true;
}
char* UnixFilesystem::CopyString(const std::string& str) {
size_t size = str.length() + 1;
char* buf = new char[size];
if (!buf) {
return nullptr;
}
strcpyn(buf, size, str.c_str());
return buf;
}
} // namespace rtc
#if defined(__native_client__)

View File

@ -37,20 +37,7 @@ class UnixFilesystem : public FilesystemInterface {
// Returns true of pathname represents an existing file
bool IsFile(const Pathname& pathname) override;
std::string TempFilename(const Pathname& dir,
const std::string& prefix) override;
bool GetFileSize(const Pathname& path, size_t* size) override;
private:
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC)
static char* provided_app_data_folder_;
static char* provided_app_temp_folder_;
#else
static char* app_temp_path_;
#endif
static char* CopyString(const std::string& str);
};
} // namespace rtc

View File

@ -42,16 +42,6 @@ bool Win32Filesystem::DeleteFile(const Pathname &filename) {
return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0;
}
std::string Win32Filesystem::TempFilename(const Pathname &dir,
const std::string &prefix) {
wchar_t filename[MAX_PATH];
if (::GetTempFileName(ToUtf16(dir.pathname()).c_str(),
ToUtf16(prefix).c_str(), 0, filename) != 0)
return ToUtf8(filename);
RTC_NOTREACHED();
return "";
}
bool Win32Filesystem::MoveFile(const Pathname &old_path,
const Pathname &new_path) {
if (!IsFile(old_path)) {

View File

@ -33,14 +33,6 @@ class Win32Filesystem : public FilesystemInterface {
// Returns true if a file exists at path
bool IsFile(const Pathname& path) override;
// All of the following functions set pathname and return true if successful.
// Returned paths always include a trailing backslash.
// If create is true, the path will be recursively created.
// If append is non-null, it will be appended (and possibly created).
std::string TempFilename(const Pathname& dir,
const std::string& prefix) override;
bool GetFileSize(const Pathname& path, size_t* size) override;
};