OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 if (flags & PLATFORM_FILE_CREATE_ALWAYS) { | 23 if (flags & PLATFORM_FILE_CREATE_ALWAYS) { |
24 DCHECK(!open_flags); | 24 DCHECK(!open_flags); |
25 open_flags = O_CREAT | O_TRUNC; | 25 open_flags = O_CREAT | O_TRUNC; |
26 } | 26 } |
27 | 27 |
28 if (!open_flags && !(flags & PLATFORM_FILE_OPEN) && | 28 if (!open_flags && !(flags & PLATFORM_FILE_OPEN) && |
29 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { | 29 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { |
30 NOTREACHED(); | 30 NOTREACHED(); |
31 errno = ENOTSUP; | 31 errno = ENOTSUP; |
32 return INVALID_HANDLE_VALUE; | 32 return kInvalidPlatformFileValue; |
33 } | 33 } |
34 | 34 |
35 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { | 35 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { |
36 open_flags |= O_RDWR; | 36 open_flags |= O_RDWR; |
37 } else if (flags & PLATFORM_FILE_WRITE) { | 37 } else if (flags & PLATFORM_FILE_WRITE) { |
38 open_flags |= O_WRONLY; | 38 open_flags |= O_WRONLY; |
39 } else if (!(flags & PLATFORM_FILE_READ)) { | 39 } else if (!(flags & PLATFORM_FILE_READ)) { |
40 NOTREACHED(); | 40 NOTREACHED(); |
41 } | 41 } |
42 | 42 |
(...skipping 12 matching lines...) Expand all Loading... |
55 S_IRUSR | S_IWUSR); | 55 S_IRUSR | S_IWUSR); |
56 if (created && descriptor > 0) | 56 if (created && descriptor > 0) |
57 *created = true; | 57 *created = true; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 return descriptor; | 61 return descriptor; |
62 } | 62 } |
63 | 63 |
64 } // namespace base | 64 } // namespace base |
OLD | NEW |