OLD | NEW |
---|---|
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/platform_file.h" | 5 #include "base/platform_file.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 *error = PLATFORM_FILE_ERROR_FAILED; | 74 *error = PLATFORM_FILE_ERROR_FAILED; |
75 return kInvalidPlatformFileValue; | 75 return kInvalidPlatformFileValue; |
76 } | 76 } |
77 | 77 |
78 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { | 78 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { |
79 open_flags |= O_RDWR; | 79 open_flags |= O_RDWR; |
80 } else if (flags & PLATFORM_FILE_WRITE) { | 80 } else if (flags & PLATFORM_FILE_WRITE) { |
81 open_flags |= O_WRONLY; | 81 open_flags |= O_WRONLY; |
82 } else if (!(flags & PLATFORM_FILE_READ) && | 82 } else if (!(flags & PLATFORM_FILE_READ) && |
83 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && | 83 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && |
84 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 84 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { |
jar (doing other things)
2013/05/31 16:33:50
Are some of these "effective assertions" going to
teravest
2013/05/31 17:04:08
Nice catch! I updated the test to take this path,
| |
85 NOTREACHED(); | 85 NOTREACHED(); |
86 } | 86 } |
87 | 87 |
88 if (flags & PLATFORM_FILE_TERMINAL_DEVICE) | 88 if (flags & PLATFORM_FILE_TERMINAL_DEVICE) |
89 open_flags |= O_NOCTTY | O_NDELAY; | 89 open_flags |= O_NOCTTY | O_NDELAY; |
90 | 90 |
91 if (flags & PLATFORM_FILE_APPEND && flags & PLATFORM_FILE_READ) | |
92 open_flags |= O_APPEND | O_RDWR; | |
93 else if (flags & PLATFORM_FILE_APPEND) | |
94 open_flags |= O_APPEND | O_WRONLY; | |
95 | |
91 COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero); | 96 COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero); |
92 | 97 |
93 int mode = S_IRUSR | S_IWUSR; | 98 int mode = S_IRUSR | S_IWUSR; |
94 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
95 mode |= S_IRGRP | S_IROTH; | 100 mode |= S_IRGRP | S_IROTH; |
96 #endif | 101 #endif |
97 | 102 |
98 int descriptor = | 103 int descriptor = |
99 HANDLE_EINTR(open(name.value().c_str(), open_flags, mode)); | 104 HANDLE_EINTR(open(name.value().c_str(), open_flags, mode)); |
100 | 105 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 default: | 334 default: |
330 #if !defined(OS_NACL) // NaCl build has no metrics code. | 335 #if !defined(OS_NACL) // NaCl build has no metrics code. |
331 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Posix", | 336 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Posix", |
332 saved_errno); | 337 saved_errno); |
333 #endif | 338 #endif |
334 return PLATFORM_FILE_ERROR_FAILED; | 339 return PLATFORM_FILE_ERROR_FAILED; |
335 } | 340 } |
336 } | 341 } |
337 | 342 |
338 } // namespace base | 343 } // namespace base |
OLD | NEW |