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

Side by Side Diff: base/files/file_unittest.cc

Issue 314023002: Require FLAG_WRITE when FLAG_CREATE_ALWAYS is specified (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Require FLAG_WRITE on Windows too Created 6 years, 6 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
« no previous file with comments | « base/files/file_posix.cc ('k') | base/files/file_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file.h" 6 #include "base/files/file.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Create a file that exists. 71 // Create a file that exists.
72 File file(file_path, base::File::FLAG_CREATE | base::File::FLAG_READ); 72 File file(file_path, base::File::FLAG_CREATE | base::File::FLAG_READ);
73 EXPECT_FALSE(file.IsValid()); 73 EXPECT_FALSE(file.IsValid());
74 EXPECT_FALSE(file.created()); 74 EXPECT_FALSE(file.created());
75 EXPECT_EQ(base::File::FILE_ERROR_EXISTS, file.error_details()); 75 EXPECT_EQ(base::File::FILE_ERROR_EXISTS, file.error_details());
76 } 76 }
77 77
78 { 78 {
79 // Create or overwrite a file. 79 // Create or overwrite a file.
80 File file(file_path, 80 File file(file_path,
81 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_READ); 81 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
82 EXPECT_TRUE(file.IsValid()); 82 EXPECT_TRUE(file.IsValid());
83 EXPECT_TRUE(file.created()); 83 EXPECT_TRUE(file.created());
84 EXPECT_EQ(base::File::FILE_OK, file.error_details()); 84 EXPECT_EQ(base::File::FILE_OK, file.error_details());
85 } 85 }
86 86
87 { 87 {
88 // Create a delete-on-close file. 88 // Create a delete-on-close file.
89 file_path = temp_dir.path().AppendASCII("create_file_2"); 89 file_path = temp_dir.path().AppendASCII("create_file_2");
90 File file(file_path, 90 File file(file_path,
91 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ | 91 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 NULL)); 442 NULL));
443 ASSERT_TRUE(dir.IsValid()); 443 ASSERT_TRUE(dir.IsValid());
444 444
445 base::File::Info info; 445 base::File::Info info;
446 EXPECT_TRUE(dir.GetInfo(&info)); 446 EXPECT_TRUE(dir.GetInfo(&info));
447 EXPECT_TRUE(info.is_directory); 447 EXPECT_TRUE(info.is_directory);
448 EXPECT_FALSE(info.is_symbolic_link); 448 EXPECT_FALSE(info.is_symbolic_link);
449 EXPECT_EQ(0, info.size); 449 EXPECT_EQ(0, info.size);
450 } 450 }
451 #endif // defined(OS_WIN) 451 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « base/files/file_posix.cc ('k') | base/files/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698