OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <winioctl.h> | 9 #include <winioctl.h> |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 return static_cast<int>(files_.size()); | 155 return static_cast<int>(files_.size()); |
156 } | 156 } |
157 | 157 |
158 private: | 158 private: |
159 std::set<FilePath::StringType> files_; | 159 std::set<FilePath::StringType> files_; |
160 }; | 160 }; |
161 | 161 |
162 // Simple function to dump some text into a new file. | 162 // Simple function to dump some text into a new file. |
163 void CreateTextFile(const FilePath& filename, | 163 void CreateTextFile(const FilePath& filename, |
164 const std::wstring& contents) { | 164 const std::wstring& contents) { |
165 std::ofstream file; | 165 std::wofstream file; |
wtc
2011/03/25 17:35:42
IMPORTANT: this seems like a bug fix. Since there
| |
166 file.open(filename.value().c_str()); | 166 file.open(filename.value().c_str()); |
167 ASSERT_TRUE(file.is_open()); | 167 ASSERT_TRUE(file.is_open()); |
168 file << contents; | 168 file << contents; |
169 file.close(); | 169 file.close(); |
170 } | 170 } |
171 | 171 |
172 // Simple function to take out some text from a file. | 172 // Simple function to take out some text from a file. |
173 std::wstring ReadTextFile(const FilePath& filename) { | 173 std::wstring ReadTextFile(const FilePath& filename) { |
174 wchar_t contents[64]; | 174 wchar_t contents[64]; |
175 std::wifstream file; | 175 std::wifstream file; |
176 file.open(filename.value().c_str()); | 176 file.open(filename.value().c_str()); |
177 EXPECT_TRUE(file.is_open()); | 177 EXPECT_TRUE(file.is_open()); |
178 file.getline(contents, 64); | 178 file.getline(contents, 64); |
wtc
2011/03/25 17:35:42
Nit: we should replace 64 with arraysize(contents)
| |
179 file.close(); | 179 file.close(); |
180 return std::wstring(contents); | 180 return std::wstring(contents); |
181 } | 181 } |
182 | 182 |
183 #if defined(OS_WIN) | 183 #if defined(OS_WIN) |
184 uint64 FileTimeAsUint64(const FILETIME& ft) { | 184 uint64 FileTimeAsUint64(const FILETIME& ft) { |
185 ULARGE_INTEGER u; | 185 ULARGE_INTEGER u; |
186 u.LowPart = ft.dwLowDateTime; | 186 u.LowPart = ft.dwLowDateTime; |
187 u.HighPart = ft.dwHighDateTime; | 187 u.HighPart = ft.dwHighDateTime; |
188 return u.QuadPart; | 188 return u.QuadPart; |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1807 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); | 1807 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); |
1808 | 1808 |
1809 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); | 1809 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); |
1810 std::string bar("baz"); | 1810 std::string bar("baz"); |
1811 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); | 1811 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); |
1812 | 1812 |
1813 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); | 1813 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); |
1814 } | 1814 } |
1815 | 1815 |
1816 } // namespace | 1816 } // namespace |
OLD | NEW |