| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 bool Win32Filesystem::IsAbsent(const Pathname& path) { | 154 bool Win32Filesystem::IsAbsent(const Pathname& path) { |
| 155 WIN32_FILE_ATTRIBUTE_DATA data = {0}; | 155 WIN32_FILE_ATTRIBUTE_DATA data = {0}; |
| 156 if (0 != ::GetFileAttributesEx(ToUtf16(path.pathname()).c_str(), | 156 if (0 != ::GetFileAttributesEx(ToUtf16(path.pathname()).c_str(), |
| 157 GetFileExInfoStandard, &data)) | 157 GetFileExInfoStandard, &data)) |
| 158 return false; | 158 return false; |
| 159 DWORD err = ::GetLastError(); | 159 DWORD err = ::GetLastError(); |
| 160 return (ERROR_FILE_NOT_FOUND == err || ERROR_PATH_NOT_FOUND == err); | 160 return (ERROR_FILE_NOT_FOUND == err || ERROR_PATH_NOT_FOUND == err); |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool Win32Filesystem::IsTemporaryPath(const Pathname& pathname) { | |
| 164 TCHAR buffer[MAX_PATH + 1]; | |
| 165 if (!::GetTempPath(arraysize(buffer), buffer)) | |
| 166 return false; | |
| 167 if (!IsCurrentProcessLowIntegrity() && | |
| 168 !::GetLongPathName(buffer, buffer, arraysize(buffer))) | |
| 169 return false; | |
| 170 return (::strnicmp(ToUtf16(pathname.pathname()).c_str(), | |
| 171 buffer, strlen(buffer)) == 0); | |
| 172 } | |
| 173 | |
| 174 bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { | 163 bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { |
| 175 WIN32_FILE_ATTRIBUTE_DATA data = {0}; | 164 WIN32_FILE_ATTRIBUTE_DATA data = {0}; |
| 176 if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), | 165 if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), |
| 177 GetFileExInfoStandard, &data) == 0) | 166 GetFileExInfoStandard, &data) == 0) |
| 178 return false; | 167 return false; |
| 179 *size = data.nFileSizeLow; | 168 *size = data.nFileSizeLow; |
| 180 return true; | 169 return true; |
| 181 } | 170 } |
| 182 | 171 |
| 183 bool Win32Filesystem::GetFileTime(const Pathname& path, FileTimeType which, | 172 bool Win32Filesystem::GetFileTime(const Pathname& path, FileTimeType which, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 203 } | 192 } |
| 204 | 193 |
| 205 bool Win32Filesystem::GetAppPathname(Pathname* path) { | 194 bool Win32Filesystem::GetAppPathname(Pathname* path) { |
| 206 TCHAR buffer[MAX_PATH + 1]; | 195 TCHAR buffer[MAX_PATH + 1]; |
| 207 if (0 == ::GetModuleFileName(nullptr, buffer, arraysize(buffer))) | 196 if (0 == ::GetModuleFileName(nullptr, buffer, arraysize(buffer))) |
| 208 return false; | 197 return false; |
| 209 path->SetPathname(ToUtf8(buffer)); | 198 path->SetPathname(ToUtf8(buffer)); |
| 210 return true; | 199 return true; |
| 211 } | 200 } |
| 212 | 201 |
| 213 bool Win32Filesystem::GetAppTempFolder(Pathname* path) { | |
| 214 if (!GetAppPathname(path)) | |
| 215 return false; | |
| 216 std::string filename(path->filename()); | |
| 217 return GetTemporaryFolder(*path, true, &filename); | |
| 218 } | |
| 219 | |
| 220 } // namespace rtc | 202 } // namespace rtc |
| OLD | NEW |