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

Unified Diff: base/files/file_util_unittest.cc

Issue 639253004: Allow POSIX callers to specify a new file's mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return bool instead of int, to accord with in-progress refactoring. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: base/files/file_util_unittest.cc
diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc
index bd4839aad50771e4784594ea526900d857b2ab48..1182ed61c2026483f4d91e223d51a7df799c40cf 100644
--- a/base/files/file_util_unittest.cc
+++ b/base/files/file_util_unittest.cc
@@ -2122,6 +2122,28 @@ TEST_F(FileUtilTest, TouchFile) {
file_info.last_modified.ToInternalValue());
}
+#if defined(OS_POSIX)
+TEST_F(FileUtilTest, WriteFileMode) {
+ FilePath data_dir =
+ temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest"));
+
+ // Create a fresh, empty copy of this directory.
+ if (PathExists(data_dir)) {
+ ASSERT_TRUE(DeleteFile(data_dir, true));
+ }
+ ASSERT_TRUE(CreateDirectory(data_dir));
+
+ FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt")));
+ std::string data("hello");
+ mode_t mode = 0644;
+ ASSERT_TRUE(WriteFileMode(foobar, data.c_str(), data.length(), mode));
+
+ struct stat status;
+ ASSERT_EQ(0, stat(foobar.value().c_str(), &status));
+ ASSERT_EQ(mode, status.st_mode & 0777);
+}
+#endif
+
TEST_F(FileUtilTest, IsDirectoryEmpty) {
FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir"));

Powered by Google App Engine
This is Rietveld 408576698