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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DWORD res = ::GetFileAttributes(path16.c_str()); | 44 DWORD res = ::GetFileAttributes(path16.c_str()); |
45 if (res != INVALID_FILE_ATTRIBUTES) { | 45 if (res != INVALID_FILE_ATTRIBUTES) { |
46 // Something exists at this location, check if it is a directory | 46 // Something exists at this location, check if it is a directory |
47 return ((res & FILE_ATTRIBUTE_DIRECTORY) != 0); | 47 return ((res & FILE_ATTRIBUTE_DIRECTORY) != 0); |
48 } else if ((GetLastError() != ERROR_FILE_NOT_FOUND) | 48 } else if ((GetLastError() != ERROR_FILE_NOT_FOUND) |
49 && (GetLastError() != ERROR_PATH_NOT_FOUND)) { | 49 && (GetLastError() != ERROR_PATH_NOT_FOUND)) { |
50 // Unexpected error | 50 // Unexpected error |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 // Directory doesn't exist, look up one directory level | |
55 if (!pathname.parent_folder().empty()) { | |
56 Pathname parent(pathname); | |
57 parent.SetFolder(pathname.parent_folder()); | |
58 if (!CreateFolder(parent)) { | |
59 return false; | |
60 } | |
61 } | |
62 | |
63 return (::CreateDirectory(path16.c_str(), nullptr) != 0); | 54 return (::CreateDirectory(path16.c_str(), nullptr) != 0); |
64 } | 55 } |
65 | 56 |
66 bool Win32Filesystem::DeleteFile(const Pathname &filename) { | 57 bool Win32Filesystem::DeleteFile(const Pathname &filename) { |
67 LOG(LS_INFO) << "Deleting file " << filename.pathname(); | 58 LOG(LS_INFO) << "Deleting file " << filename.pathname(); |
68 if (!IsFile(filename)) { | 59 if (!IsFile(filename)) { |
69 RTC_DCHECK(IsFile(filename)); | 60 RTC_DCHECK(IsFile(filename)); |
70 return false; | 61 return false; |
71 } | 62 } |
72 return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0; | 63 return ::DeleteFile(ToUtf16(filename.pathname()).c_str()) != 0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { | 114 bool Win32Filesystem::GetFileSize(const Pathname &pathname, size_t *size) { |
124 WIN32_FILE_ATTRIBUTE_DATA data = {0}; | 115 WIN32_FILE_ATTRIBUTE_DATA data = {0}; |
125 if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), | 116 if (::GetFileAttributesEx(ToUtf16(pathname.pathname()).c_str(), |
126 GetFileExInfoStandard, &data) == 0) | 117 GetFileExInfoStandard, &data) == 0) |
127 return false; | 118 return false; |
128 *size = data.nFileSizeLow; | 119 *size = data.nFileSizeLow; |
129 return true; | 120 return true; |
130 } | 121 } |
131 | 122 |
132 } // namespace rtc | 123 } // namespace rtc |
OLD | NEW |