Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Side by Side Diff: base/file_util_unittest.cc

Issue 6126002: Remove base/scoped_handle_win.h stub and fix up all callers to use the new location and namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: linux_view fix Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 #include <tchar.h> 12 #include <tchar.h>
13
14 #include "base/win/scoped_handle.h"
brettw 2011/01/07 18:03:46 This shouldn't go here above the rest of the heade
tfarina 2011/01/07 20:11:13 I tried to follow the rule here: http://google-sty
tfarina 2011/01/07 22:23:08 Done.
13 #endif 15 #endif
14 16
15 #include <fstream> 17 #include <fstream>
16 #include <set> 18 #include <set>
17 19
18 #include "base/base_paths.h" 20 #include "base/base_paths.h"
19 #include "base/file_path.h" 21 #include "base/file_path.h"
20 #include "base/file_util.h" 22 #include "base/file_util.h"
21 #include "base/path_service.h" 23 #include "base/path_service.h"
22 #include "base/scoped_handle.h"
23 #include "base/scoped_temp_dir.h" 24 #include "base/scoped_temp_dir.h"
24 #include "base/threading/platform_thread.h" 25 #include "base/threading/platform_thread.h"
25 #include "base/time.h" 26 #include "base/time.h"
26 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "testing/platform_test.h" 29 #include "testing/platform_test.h"
29 30
30 // This macro helps avoid wrapped lines in the test structs. 31 // This macro helps avoid wrapped lines in the test structs.
31 #define FPL(x) FILE_PATH_LITERAL(x) 32 #define FPL(x) FILE_PATH_LITERAL(x)
32 33
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 477
477 FilePath sub_long = deep_file.DirName(); 478 FilePath sub_long = deep_file.DirName();
478 ASSERT_TRUE(file_util::CreateDirectory(sub_long)); 479 ASSERT_TRUE(file_util::CreateDirectory(sub_long));
479 CreateTextFile(deep_file, bogus_content); 480 CreateTextFile(deep_file, bogus_content);
480 481
481 FilePath base_b = temp_dir_.path().Append(FPL("base_b")); 482 FilePath base_b = temp_dir_.path().Append(FPL("base_b"));
482 ASSERT_TRUE(file_util::CreateDirectory(base_b)); 483 ASSERT_TRUE(file_util::CreateDirectory(base_b));
483 484
484 FilePath to_sub_a = base_b.Append(FPL("to_sub_a")); 485 FilePath to_sub_a = base_b.Append(FPL("to_sub_a"));
485 ASSERT_TRUE(file_util::CreateDirectory(to_sub_a)); 486 ASSERT_TRUE(file_util::CreateDirectory(to_sub_a));
486 ScopedHandle reparse_to_sub_a( 487 base::win::ScopedHandle reparse_to_sub_a(
487 ::CreateFile(to_sub_a.value().c_str(), 488 ::CreateFile(to_sub_a.value().c_str(),
488 FILE_ALL_ACCESS, 489 FILE_ALL_ACCESS,
489 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 490 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
490 NULL, 491 NULL,
491 OPEN_EXISTING, 492 OPEN_EXISTING,
492 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. 493 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
493 NULL)); 494 NULL));
494 ASSERT_TRUE(reparse_to_sub_a.IsValid()); 495 ASSERT_TRUE(reparse_to_sub_a.IsValid());
495 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_a, sub_a)); 496 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_a, sub_a));
496 497
497 FilePath to_base_b = base_b.Append(FPL("to_base_b")); 498 FilePath to_base_b = base_b.Append(FPL("to_base_b"));
498 ASSERT_TRUE(file_util::CreateDirectory(to_base_b)); 499 ASSERT_TRUE(file_util::CreateDirectory(to_base_b));
499 ScopedHandle reparse_to_base_b( 500 base::win::ScopedHandle reparse_to_base_b(
500 ::CreateFile(to_base_b.value().c_str(), 501 ::CreateFile(to_base_b.value().c_str(),
501 FILE_ALL_ACCESS, 502 FILE_ALL_ACCESS,
502 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 503 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
503 NULL, 504 NULL,
504 OPEN_EXISTING, 505 OPEN_EXISTING,
505 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. 506 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
506 NULL)); 507 NULL));
507 ASSERT_TRUE(reparse_to_base_b.IsValid()); 508 ASSERT_TRUE(reparse_to_base_b.IsValid());
508 ASSERT_TRUE(SetReparsePoint(reparse_to_base_b, base_b)); 509 ASSERT_TRUE(SetReparsePoint(reparse_to_base_b, base_b));
509 510
510 FilePath to_sub_long = base_b.Append(FPL("to_sub_long")); 511 FilePath to_sub_long = base_b.Append(FPL("to_sub_long"));
511 ASSERT_TRUE(file_util::CreateDirectory(to_sub_long)); 512 ASSERT_TRUE(file_util::CreateDirectory(to_sub_long));
512 ScopedHandle reparse_to_sub_long( 513 base::win::ScopedHandle reparse_to_sub_long(
513 ::CreateFile(to_sub_long.value().c_str(), 514 ::CreateFile(to_sub_long.value().c_str(),
514 FILE_ALL_ACCESS, 515 FILE_ALL_ACCESS,
515 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 516 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
516 NULL, 517 NULL,
517 OPEN_EXISTING, 518 OPEN_EXISTING,
518 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. 519 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
519 NULL)); 520 NULL));
520 ASSERT_TRUE(reparse_to_sub_long.IsValid()); 521 ASSERT_TRUE(reparse_to_sub_long.IsValid());
521 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_long, sub_long)); 522 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_long, sub_long));
522 523
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); 1817 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir));
1817 1818
1818 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); 1819 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt")));
1819 std::string bar("baz"); 1820 std::string bar("baz");
1820 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); 1821 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length()));
1821 1822
1822 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); 1823 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir));
1823 } 1824 }
1824 1825
1825 } // namespace 1826 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698