• Home
  • Raw
  • Download

Lines Matching refs:base

33                 base::FilePath* file_path,  in CreateFile()
34 base::File* file) { in CreateFile()
35 if (!base::CreateTemporaryFile(file_path)) in CreateFile()
38 if (base::WriteFile(*file_path, content.data(), content.size()) == -1) in CreateFile()
41 *file = base::File( in CreateFile()
42 *file_path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); in CreateFile()
59 base::FilePath test_dir(FILE_PATH_LITERAL("/test")); in VirtualFileSystem()
60 base::FilePath foo_txt_path = test_dir.Append(FILE_PATH_LITERAL("foo.txt")); in VirtualFileSystem()
62 base::FilePath file_path; in VirtualFileSystem()
63 base::File file; in VirtualFileSystem()
68 base::FilePath bar_dir = test_dir.Append(FILE_PATH_LITERAL("bar")); in VirtualFileSystem()
69 base::FilePath bar1_txt_path = in VirtualFileSystem()
75 base::FilePath bar2_txt_path = in VirtualFileSystem()
91 std::vector<base::File> OpenFilesForReading( in OpenFilesForReading()
92 const std::vector<base::FilePath>& paths) override { in OpenFilesForReading()
93 std::vector<base::File> files; in OpenFilesForReading()
96 files.push_back(iter == files_.end() ? base::File() in OpenFilesForReading()
102 bool DirectoryExists(const base::FilePath& file) override { in DirectoryExists()
107 const base::FilePath& dir) override { in ListDirectoryContent()
116 base::Time GetLastModifiedTime(const base::FilePath& path) override { in GetLastModifiedTime()
117 return base::Time::FromDoubleT(172097977); // Some random date. in GetLastModifiedTime()
120 std::map<base::FilePath, std::vector<DirectoryContentEntry>> file_tree_;
121 std::map<base::FilePath, base::File> files_;
145 base::FilePath zip_path(test_dir_); in SetUp()
157 zip_file_list_.push_back(base::FilePath(FILE_PATH_LITERAL("foo.txt"))); in SetUp()
159 base::FilePath(FILE_PATH_LITERAL("foo/bar/quux.txt"))); in SetUp()
161 base::FilePath(FILE_PATH_LITERAL("foo/bar/.hidden"))); in SetUp()
168 bool GetTestDataDirectory(base::FilePath* path) { in GetTestDataDirectory()
169 bool success = base::PathService::Get(base::DIR_SOURCE_ROOT, path); in GetTestDataDirectory()
181 void TestUnzipFile(const base::FilePath::StringType& filename, in TestUnzipFile()
183 base::FilePath test_dir; in TestUnzipFile()
188 void TestUnzipFile(const base::FilePath& path, bool expect_hidden_files) { in TestUnzipFile()
189 ASSERT_TRUE(base::PathExists(path)) << "no file " << path.value(); in TestUnzipFile()
192 base::FilePath original_dir; in TestUnzipFile()
196 base::FileEnumerator files(test_dir_, true, in TestUnzipFile()
197 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); in TestUnzipFile()
198 base::FilePath unzipped_entry_path = files.Next(); in TestUnzipFile()
205 if (base::PathExists(unzipped_entry_path) && in TestUnzipFile()
206 !base::DirectoryExists(unzipped_entry_path)) { in TestUnzipFile()
210 base::FilePath relative_path; in TestUnzipFile()
218 base::FilePath original_path = original_dir.Append(relative_path); in TestUnzipFile()
222 << base::ContentsEqual(original_path, unzipped_entry_path); in TestUnzipFile()
231 for (std::set<base::FilePath>::iterator iter = zip_contents_.begin(); in TestUnzipFile()
249 base::ScopedTempDir temp_dir; in TestTimeStamp()
252 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip"); in TestTimeStamp()
253 base::FilePath src_dir = temp_dir.GetPath().AppendASCII("input"); in TestTimeStamp()
254 base::FilePath out_dir = temp_dir.GetPath().AppendASCII("output"); in TestTimeStamp()
256 base::FilePath src_file = src_dir.AppendASCII("test.txt"); in TestTimeStamp()
257 base::FilePath out_file = out_dir.AppendASCII("test.txt"); in TestTimeStamp()
259 EXPECT_TRUE(base::CreateDirectory(src_dir)); in TestTimeStamp()
260 EXPECT_TRUE(base::CreateDirectory(out_dir)); in TestTimeStamp()
262 base::Time test_mtime; in TestTimeStamp()
263 ASSERT_TRUE(base::Time::FromString(date_time, &test_mtime)); in TestTimeStamp()
268 base::Time::Exploded now_parts; in TestTimeStamp()
269 base::Time::Now().LocalExplode(&now_parts); in TestTimeStamp()
272 base::Time now_time; in TestTimeStamp()
273 EXPECT_TRUE(base::Time::FromLocalExploded(now_parts, &now_time)); in TestTimeStamp()
275 EXPECT_EQ(1, base::WriteFile(src_file, "1", 1)); in TestTimeStamp()
276 EXPECT_TRUE(base::TouchFile(src_file, base::Time::Now(), test_mtime)); in TestTimeStamp()
281 base::File::Info file_info; in TestTimeStamp()
282 EXPECT_TRUE(base::GetFileInfo(out_file, &file_info)); in TestTimeStamp()
294 base::FilePath test_dir_;
296 base::ScopedTempDir temp_dir_;
299 std::set<base::FilePath> zip_contents_;
302 std::vector<base::FilePath> zip_file_list_;
314 base::FilePath path; in TEST_F()
320 base::FilePath output_dir = test_dir_.AppendASCII("out"); in TEST_F()
322 base::FilePath evil_file = output_dir; in TEST_F()
325 ASSERT_FALSE(base::PathExists(evil_file)); in TEST_F()
329 base::FilePath path; in TEST_F()
335 base::FilePath output_dir = test_dir_.AppendASCII("out"); in TEST_F()
338 base::FilePath evil_file = output_dir; in TEST_F()
340 ASSERT_FALSE(base::PathExists(evil_file)); in TEST_F()
344 auto filter = base::BindRepeating([](const base::FilePath& path) { in TEST_F()
347 base::FilePath path; in TEST_F()
359 ASSERT_TRUE(base::PathExists(test_dir_.AppendASCII("foo.txt"))); in TEST_F()
360 base::FileEnumerator extractedFiles( in TEST_F()
363 base::FileEnumerator::FileType::FILES); in TEST_F()
369 base::FileEnumerator extractedDirs( in TEST_F()
372 base::FileEnumerator::FileType::DIRECTORIES); in TEST_F()
381 base::BindRepeating([](const base::FilePath& path) { return true; }); in TEST_F()
382 auto dir_creator = base::BindRepeating( in TEST_F()
383 [](const base::FilePath& extract_dir, const base::FilePath& entry_path) { in TEST_F()
384 return base::CreateDirectory(extract_dir.Append(entry_path)); in TEST_F()
387 auto writer = base::BindRepeating( in TEST_F()
388 [](const base::FilePath& extract_dir, const base::FilePath& entry_path) in TEST_F()
394 base::FilePath path; in TEST_F()
396 base::File file(path.AppendASCII("test.zip"), in TEST_F()
397 base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); in TEST_F()
400 base::FilePath dir = test_dir_; in TEST_F()
401 base::FilePath dir_foo = dir.AppendASCII("foo"); in TEST_F()
402 base::FilePath dir_foo_bar = dir_foo.AppendASCII("bar"); in TEST_F()
403 ASSERT_TRUE(base::PathExists(dir.AppendASCII("foo.txt"))); in TEST_F()
404 ASSERT_TRUE(base::PathExists(dir_foo)); in TEST_F()
405 ASSERT_TRUE(base::PathExists(dir_foo.AppendASCII("bar.txt"))); in TEST_F()
406 ASSERT_TRUE(base::PathExists(dir_foo_bar)); in TEST_F()
407 ASSERT_TRUE(base::PathExists(dir_foo_bar.AppendASCII(".hidden"))); in TEST_F()
408 ASSERT_TRUE(base::PathExists(dir_foo_bar.AppendASCII("baz.txt"))); in TEST_F()
409 ASSERT_TRUE(base::PathExists(dir_foo_bar.AppendASCII("quux.txt"))); in TEST_F()
413 base::FilePath src_dir; in TEST_F()
417 base::ScopedTempDir temp_dir; in TEST_F()
419 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip"); in TEST_F()
426 base::FilePath src_dir; in TEST_F()
430 base::ScopedTempDir temp_dir; in TEST_F()
432 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip"); in TEST_F()
439 base::FilePath src_dir; in TEST_F()
443 base::ScopedTempDir temp_dir; in TEST_F()
446 base::FilePath src_dir_russian = temp_dir.GetPath().Append( in TEST_F()
447 base::FilePath::FromUTF8Unsafe("\xD0\xA2\xD0\xB5\xD1\x81\xD1\x82")); in TEST_F()
448 base::CopyDirectory(src_dir, src_dir_russian, true); in TEST_F()
449 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out_russian.zip"); in TEST_F()
479 base::FilePath src_dir; in TEST_F()
483 base::ScopedTempDir temp_dir; in TEST_F()
485 base::FilePath zip_name = temp_dir.GetPath().AppendASCII("out.zip"); in TEST_F()
487 base::File zip_file(zip_name, in TEST_F()
488 base::File::FLAG_CREATE | base::File::FLAG_WRITE); in TEST_F()
508 base::FilePath test_data_folder; in TEST_F()
515 base::FilePath test_zip_file = in TEST_F()
518 base::ScopedTempDir scoped_temp_dir; in TEST_F()
520 const base::FilePath& temp_dir = scoped_temp_dir.GetPath(); in TEST_F()
523 EXPECT_TRUE(base::DirectoryExists(temp_dir.AppendASCII("d"))); in TEST_F()
526 SCOPED_TRACE(base::StringPrintf("Processing %d.txt", i)); in TEST_F()
527 base::FilePath file_path = temp_dir.AppendASCII( in TEST_F()
528 base::StringPrintf("%d.txt", i)); in TEST_F()
530 EXPECT_TRUE(base::GetFileSize(file_path, &file_size)); in TEST_F()
536 base::FilePath zip_file; in TEST_F()
537 ASSERT_TRUE(base::CreateTemporaryFile(&zip_file)); in TEST_F()
538 zip::ZipParams params(base::FilePath(FILE_PATH_LITERAL("/test")), zip_file); in TEST_F()
542 base::ScopedTempDir scoped_temp_dir; in TEST_F()
544 const base::FilePath& temp_dir = scoped_temp_dir.GetPath(); in TEST_F()
546 base::FilePath bar_dir = temp_dir.Append(FILE_PATH_LITERAL("bar")); in TEST_F()
547 EXPECT_TRUE(base::DirectoryExists(bar_dir)); in TEST_F()
549 EXPECT_TRUE(base::ReadFileToString( in TEST_F()
552 EXPECT_TRUE(base::ReadFileToString( in TEST_F()
555 EXPECT_TRUE(base::ReadFileToString( in TEST_F()