| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 bool Win32Filesystem::DeleteFile(const Pathname &filename) { | 66 bool Win32Filesystem::DeleteFile(const Pathname &filename) { |
| 67 LOG(LS_INFO) << "Deleting file " << filename.pathname(); | 67 LOG(LS_INFO) << "Deleting file " << filename.pathname(); |
| 68 if (!IsFile(filename)) { | 68 if (!IsFile(filename)) { |
| 69 RTC_DCHECK(IsFile(filename)); | 69 RTC_DCHECK(IsFile(filename)); |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0; | 72 return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool Win32Filesystem::GetTemporaryFolder(Pathname &pathname, bool create, | |
| 76 const std::string *append) { | |
| 77 wchar_t buffer[MAX_PATH + 1]; | |
| 78 if (!::GetTempPath(arraysize(buffer), buffer)) | |
| 79 return false; | |
| 80 if (!IsCurrentProcessLowIntegrity() && | |
| 81 !::GetLongPathName(buffer, buffer, arraysize(buffer))) | |
| 82 return false; | |
| 83 size_t len = strlen(buffer); | |
| 84 if ((len > 0) && (buffer[len-1] != '\\')) { | |
| 85 len += strcpyn(buffer + len, arraysize(buffer) - len, L"\\"); | |
| 86 } | |
| 87 if (len >= arraysize(buffer) - 1) | |
| 88 return false; | |
| 89 pathname.clear(); | |
| 90 pathname.SetFolder(ToUtf8(buffer)); | |
| 91 if (append != nullptr) { | |
| 92 RTC_DCHECK(!append->empty()); | |
| 93 pathname.AppendFolder(*append); | |
| 94 } | |
| 95 return !create || CreateFolder(pathname); | |
| 96 } | |
| 97 | |
| 98 std::string Win32Filesystem::TempFilename(const Pathname &dir, | 75 std::string Win32Filesystem::TempFilename(const Pathname &dir, |
| 99 const std::string &prefix) { | 76 const std::string &prefix) { |
| 100 wchar_t filename[MAX_PATH]; | 77 wchar_t filename[MAX_PATH]; |
| 101 if (::GetTempFileName(ToUtf16(dir.pathname()).c_str(), | 78 if (::GetTempFileName(ToUtf16(dir.pathname()).c_str(), |
| 102 ToUtf16(prefix).c_str(), 0, filename) != 0) | 79 ToUtf16(prefix).c_str(), 0, filename) != 0) |
| 103 return ToUtf8(filename); | 80 return ToUtf8(filename); |
| 104 RTC_NOTREACHED(); | 81 RTC_NOTREACHED(); |
| 105 return ""; | 82 return ""; |
| 106 } | 83 } |
| 107 | 84 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { | 123 bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { |
| 147 WIN32_FILE_ATTRIBUTE_DATA data = {0}; | 124 WIN32_FILE_ATTRIBUTE_DATA data = {0}; |
| 148 if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), | 125 if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), |
| 149 GetFileExInfoStandard, &data) == 0) | 126 GetFileExInfoStandard, &data) == 0) |
| 150 return false; | 127 return false; |
| 151 *size = data.nFileSizeLow; | 128 *size = data.nFileSizeLow; |
| 152 return true; | 129 return true; |
| 153 } | 130 } |
| 154 | 131 |
| 155 } // namespace rtc | 132 } // namespace rtc |
| OLD | NEW |