Lines Matching refs:base
32 base::FilePath* file_path, in CreateFile()
33 base::File* file) { in CreateFile()
34 if (!base::CreateTemporaryFile(file_path)) in CreateFile()
37 if (base::WriteFile(*file_path, content.data(), content.size()) == -1) in CreateFile()
40 *file = base::File( in CreateFile()
41 *file_path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); in CreateFile()
58 base::FilePath test_dir(FILE_PATH_LITERAL("/test")); in VirtualFileSystem()
59 base::FilePath foo_txt_path = test_dir.Append(FILE_PATH_LITERAL("foo.txt")); in VirtualFileSystem()
61 base::FilePath file_path; in VirtualFileSystem()
62 base::File file; in VirtualFileSystem()
67 base::FilePath bar_dir = test_dir.Append(FILE_PATH_LITERAL("bar")); in VirtualFileSystem()
68 base::FilePath bar1_txt_path = in VirtualFileSystem()
74 base::FilePath bar2_txt_path = in VirtualFileSystem()
90 std::vector<base::File> OpenFilesForReading( in OpenFilesForReading()
91 const std::vector<base::FilePath>& paths) override { in OpenFilesForReading()
92 std::vector<base::File> files; in OpenFilesForReading()
95 files.push_back(iter == files_.end() ? base::File() in OpenFilesForReading()
101 bool DirectoryExists(const base::FilePath& file) override { in DirectoryExists()
106 const base::FilePath& dir) override { in ListDirectoryContent()
115 base::Time GetLastModifiedTime(const base::FilePath& path) override { in GetLastModifiedTime()
116 return base::Time::FromDoubleT(172097977); // Some random date. in GetLastModifiedTime()
119 std::map<base::FilePath, std::vector<DirectoryContentEntry>> file_tree_;
120 std::map<base::FilePath, base::File> files_;
144 base::FilePath zip_path(test_dir_); in SetUp()
156 zip_file_list_.push_back(base::FilePath(FILE_PATH_LITERAL("foo.txt"))); in SetUp()
158 base::FilePath(FILE_PATH_LITERAL("foo/bar/quux.txt"))); in SetUp()
160 base::FilePath(FILE_PATH_LITERAL("foo/bar/.hidden"))); in SetUp()
167 bool GetTestDataDirectory(base::FilePath* path) { in GetTestDataDirectory()
168 bool success = base::PathService::Get(base::DIR_SOURCE_ROOT, path); in GetTestDataDirectory()
180 void TestUnzipFile(const base::FilePath::StringType& filename, in TestUnzipFile()
182 base::FilePath test_dir; in TestUnzipFile()
187 void TestUnzipFile(const base::FilePath& path, bool expect_hidden_files) { in TestUnzipFile()
188 ASSERT_TRUE(base::PathExists(path)) << "no file " << path.value(); in TestUnzipFile()
191 base::FilePath original_dir; in TestUnzipFile()
195 base::FileEnumerator files(test_dir_, true, in TestUnzipFile()
196 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); in TestUnzipFile()
197 base::FilePath unzipped_entry_path = files.Next(); in TestUnzipFile()
204 if (base::PathExists(unzipped_entry_path) && in TestUnzipFile()
205 !base::DirectoryExists(unzipped_entry_path)) { in TestUnzipFile()
209 base::FilePath relative_path; in TestUnzipFile()
217 base::FilePath original_path = original_dir.Append(relative_path); in TestUnzipFile()
221 << base::ContentsEqual(original_path, unzipped_entry_path); in TestUnzipFile()
230 for (std::set<base::FilePath>::iterator iter = zip_contents_.begin(); in TestUnzipFile()
248 base::ScopedTempDir temp_dir; in TestTimeStamp()
251 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip"); in TestTimeStamp()
252 base::FilePath src_dir = temp_dir.GetPath().AppendASCII("input"); in TestTimeStamp()
253 base::FilePath out_dir = temp_dir.GetPath().AppendASCII("output"); in TestTimeStamp()
255 base::FilePath src_file = src_dir.AppendASCII("test.txt"); in TestTimeStamp()
256 base::FilePath out_file = out_dir.AppendASCII("test.txt"); in TestTimeStamp()
258 EXPECT_TRUE(base::CreateDirectory(src_dir)); in TestTimeStamp()
259 EXPECT_TRUE(base::CreateDirectory(out_dir)); in TestTimeStamp()
261 base::Time test_mtime; in TestTimeStamp()
262 ASSERT_TRUE(base::Time::FromString(date_time, &test_mtime)); in TestTimeStamp()
267 base::Time::Exploded now_parts; in TestTimeStamp()
268 base::Time::Now().LocalExplode(&now_parts); in TestTimeStamp()
271 base::Time now_time; in TestTimeStamp()
272 EXPECT_TRUE(base::Time::FromLocalExploded(now_parts, &now_time)); in TestTimeStamp()
274 EXPECT_EQ(1, base::WriteFile(src_file, "1", 1)); in TestTimeStamp()
275 EXPECT_TRUE(base::TouchFile(src_file, base::Time::Now(), test_mtime)); in TestTimeStamp()
280 base::File::Info file_info; in TestTimeStamp()
281 EXPECT_TRUE(base::GetFileInfo(out_file, &file_info)); in TestTimeStamp()
293 base::FilePath test_dir_;
295 base::ScopedTempDir temp_dir_;
298 std::set<base::FilePath> zip_contents_;
301 std::vector<base::FilePath> zip_file_list_;
313 base::FilePath path; in TEST_F()
319 base::FilePath output_dir = test_dir_.AppendASCII("out"); in TEST_F()
321 base::FilePath evil_file = output_dir; in TEST_F()
324 ASSERT_FALSE(base::PathExists(evil_file)); in TEST_F()
328 base::FilePath path; in TEST_F()
334 base::FilePath output_dir = test_dir_.AppendASCII("out"); in TEST_F()
337 base::FilePath evil_file = output_dir; in TEST_F()
339 ASSERT_FALSE(base::PathExists(evil_file)); in TEST_F()
343 auto filter = base::BindRepeating([](const base::FilePath& path) { in TEST_F()
346 base::FilePath path; in TEST_F()
358 ASSERT_TRUE(base::PathExists(test_dir_.AppendASCII("foo.txt"))); in TEST_F()
359 base::FileEnumerator extractedFiles( in TEST_F()
362 base::FileEnumerator::FileType::FILES); in TEST_F()
368 base::FileEnumerator extractedDirs( in TEST_F()
371 base::FileEnumerator::FileType::DIRECTORIES); in TEST_F()
380 base::BindRepeating([](const base::FilePath& path) { return true; }); in TEST_F()
381 auto dir_creator = base::BindRepeating( in TEST_F()
382 [](const base::FilePath& extract_dir, const base::FilePath& entry_path) { in TEST_F()
383 return base::CreateDirectory(extract_dir.Append(entry_path)); in TEST_F()
386 auto writer = base::BindRepeating( in TEST_F()
387 [](const base::FilePath& extract_dir, const base::FilePath& entry_path) in TEST_F()
393 base::FilePath path; in TEST_F()
395 base::File file(path.AppendASCII("test.zip"), in TEST_F()
396 base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); in TEST_F()
399 base::FilePath dir = test_dir_; in TEST_F()
400 base::FilePath dir_foo = dir.AppendASCII("foo"); in TEST_F()
401 base::FilePath dir_foo_bar = dir_foo.AppendASCII("bar"); in TEST_F()
402 ASSERT_TRUE(base::PathExists(dir.AppendASCII("foo.txt"))); in TEST_F()
403 ASSERT_TRUE(base::PathExists(dir_foo)); in TEST_F()
404 ASSERT_TRUE(base::PathExists(dir_foo.AppendASCII("bar.txt"))); in TEST_F()
405 ASSERT_TRUE(base::PathExists(dir_foo_bar)); in TEST_F()
406 ASSERT_TRUE(base::PathExists(dir_foo_bar.AppendASCII(".hidden"))); in TEST_F()
407 ASSERT_TRUE(base::PathExists(dir_foo_bar.AppendASCII("baz.txt"))); in TEST_F()
408 ASSERT_TRUE(base::PathExists(dir_foo_bar.AppendASCII("quux.txt"))); in TEST_F()
412 base::FilePath src_dir; in TEST_F()
416 base::ScopedTempDir temp_dir; in TEST_F()
418 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip"); in TEST_F()
425 base::FilePath src_dir; in TEST_F()
429 base::ScopedTempDir temp_dir; in TEST_F()
431 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out.zip"); in TEST_F()
438 base::FilePath src_dir; in TEST_F()
442 base::ScopedTempDir temp_dir; in TEST_F()
445 base::FilePath src_dir_russian = temp_dir.GetPath().Append( in TEST_F()
446 base::FilePath::FromUTF8Unsafe("\xD0\xA2\xD0\xB5\xD1\x81\xD1\x82")); in TEST_F()
447 base::CopyDirectory(src_dir, src_dir_russian, true); in TEST_F()
448 base::FilePath zip_file = temp_dir.GetPath().AppendASCII("out_russian.zip"); in TEST_F()
478 base::FilePath src_dir; in TEST_F()
482 base::ScopedTempDir temp_dir; in TEST_F()
484 base::FilePath zip_name = temp_dir.GetPath().AppendASCII("out.zip"); in TEST_F()
486 base::File zip_file(zip_name, in TEST_F()
487 base::File::FLAG_CREATE | base::File::FLAG_WRITE); in TEST_F()
507 base::FilePath test_data_folder; in TEST_F()
514 base::FilePath test_zip_file = in TEST_F()
517 base::ScopedTempDir scoped_temp_dir; in TEST_F()
519 const base::FilePath& temp_dir = scoped_temp_dir.GetPath(); in TEST_F()
522 EXPECT_TRUE(base::DirectoryExists(temp_dir.AppendASCII("d"))); in TEST_F()
525 SCOPED_TRACE(base::StringPrintf("Processing %d.txt", i)); in TEST_F()
526 base::FilePath file_path = temp_dir.AppendASCII( in TEST_F()
527 base::StringPrintf("%d.txt", i)); in TEST_F()
529 EXPECT_TRUE(base::GetFileSize(file_path, &file_size)); in TEST_F()
535 base::FilePath zip_file; in TEST_F()
536 ASSERT_TRUE(base::CreateTemporaryFile(&zip_file)); in TEST_F()
537 zip::ZipParams params(base::FilePath(FILE_PATH_LITERAL("/test")), zip_file); in TEST_F()
541 base::ScopedTempDir scoped_temp_dir; in TEST_F()
543 const base::FilePath& temp_dir = scoped_temp_dir.GetPath(); in TEST_F()
545 base::FilePath bar_dir = temp_dir.Append(FILE_PATH_LITERAL("bar")); in TEST_F()
546 EXPECT_TRUE(base::DirectoryExists(bar_dir)); in TEST_F()
548 EXPECT_TRUE(base::ReadFileToString( in TEST_F()
551 EXPECT_TRUE(base::ReadFileToString( in TEST_F()
554 EXPECT_TRUE(base::ReadFileToString( in TEST_F()