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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc

Issue 660353003: [NaCl SDK] nacl_io: Fix utime() on directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return error; 98 return error;
99 node->SetMode(mode); 99 node->SetMode(mode);
100 100
101 error = parent->AddChild(path.Basename(), node); 101 error = parent->AddChild(path.Basename(), node);
102 if (error) 102 if (error)
103 return error; 103 return error;
104 104
105 } else { 105 } else {
106 // Opening an existing file. 106 // Opening an existing file.
107 107
108 // Directories can only be opened read-only.
109 if (node->IsaDir() && (open_flags & 3) != O_RDONLY)
110 return EISDIR;
111
112 // If we were expected to create it exclusively, fail 108 // If we were expected to create it exclusively, fail
113 if (open_flags & O_EXCL) 109 if (open_flags & O_EXCL)
114 return EEXIST; 110 return EEXIST;
115 111
116 if (open_flags & O_TRUNC) 112 if (open_flags & O_TRUNC)
117 node->FTruncate(0); 113 node->FTruncate(0);
118 } 114 }
119 115
120 *out_node = node; 116 *out_node = node;
121 return 0; 117 return 0;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (file_only && child->IsaDir()) 263 if (file_only && child->IsaDir())
268 return EISDIR; 264 return EISDIR;
269 265
270 if (remove_dir && child->ChildCount() > 0) 266 if (remove_dir && child->ChildCount() > 0)
271 return ENOTEMPTY; 267 return ENOTEMPTY;
272 268
273 return parent->RemoveChild(path.Basename()); 269 return parent->RemoveChild(path.Basename());
274 } 270 }
275 271
276 } // namespace nacl_io 272 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc ('k') | native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698