OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "nacl_io/memfs/mem_fs.h" | 5 #include "nacl_io/memfs/mem_fs.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Directories can only be opened read-only. | 108 // Directories can only be opened read-only. |
109 if (node->IsaDir() && (open_flags & 3) != O_RDONLY) | 109 if (node->IsaDir() && (open_flags & 3) != O_RDONLY) |
110 return EISDIR; | 110 return EISDIR; |
111 | 111 |
112 // If we were expected to create it exclusively, fail | 112 // If we were expected to create it exclusively, fail |
113 if (open_flags & O_EXCL) | 113 if (open_flags & O_EXCL) |
114 return EEXIST; | 114 return EEXIST; |
115 | 115 |
116 if (open_flags & O_TRUNC) | 116 if (open_flags & O_TRUNC) |
117 static_cast<MemFsNode*>(node.get())->Resize(0); | 117 node->FTruncate(0); |
118 } | 118 } |
119 | 119 |
120 *out_node = node; | 120 *out_node = node; |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 | 123 |
124 Error MemFs::Mkdir(const Path& path, int mode) { | 124 Error MemFs::Mkdir(const Path& path, int mode) { |
125 // We expect a Filesystem "absolute" path | 125 // We expect a Filesystem "absolute" path |
126 if (!path.IsAbsolute()) | 126 if (!path.IsAbsolute()) |
127 return ENOENT; | 127 return ENOENT; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (file_only && child->IsaDir()) | 267 if (file_only && child->IsaDir()) |
268 return EISDIR; | 268 return EISDIR; |
269 | 269 |
270 if (remove_dir && child->ChildCount() > 0) | 270 if (remove_dir && child->ChildCount() > 0) |
271 return ENOTEMPTY; | 271 return ENOTEMPTY; |
272 | 272 |
273 return parent->RemoveChild(path.Basename()); | 273 return parent->RemoveChild(path.Basename()); |
274 } | 274 } |
275 | 275 |
276 } // namespace nacl_io | 276 } // namespace nacl_io |
OLD | NEW |