OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
viettrungluu
2015/12/18 22:10:38
This file lg to me. I'll leave it to zra to review
| |
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 "services/files/directory_impl.h" | 5 #include "services/files/directory_impl.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 if (!(open_flags & kOpenFlagWrite)) { | 255 if (!(open_flags & kOpenFlagWrite)) { |
256 callback.Run(Error::UNIMPLEMENTED); | 256 callback.Run(Error::UNIMPLEMENTED); |
257 return; | 257 return; |
258 } | 258 } |
259 | 259 |
260 if ((open_flags & kOpenFlagCreate)) { | 260 if ((open_flags & kOpenFlagCreate)) { |
261 if (mkdirat(dir_fd_.get(), path.get().c_str(), 0700) != 0) { | 261 if (mkdirat(dir_fd_.get(), path.get().c_str(), 0700) != 0) { |
262 // Allow |EEXIST| if |kOpenFlagExclusive| is not set. Note, however, that | 262 // Allow |EEXIST| if |kOpenFlagExclusive| is not set. Note, however, that |
263 // it does not guarantee that |path| is a directory. | 263 // it does not guarantee that |path| is a directory. |
264 // TODO(vtl): Hrm, ponder if we should check that |path| is a directory. | 264 // TODO(vtl): Hrm, ponder if we should check that |path| is a directory. |
265 if (errno != EEXIST || !(open_flags & kOpenFlagExclusive)) { | 265 if ((errno != EEXIST) || (open_flags & kOpenFlagExclusive)) { |
viettrungluu
2015/12/18 22:10:38
D'oh. I guess I should write a test for this case.
| |
266 callback.Run(ErrnoToError(errno)); | 266 callback.Run(ErrnoToError(errno)); |
267 return; | 267 return; |
268 } | 268 } |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 base::ScopedFD new_dir_fd( | 272 base::ScopedFD new_dir_fd( |
273 HANDLE_EINTR(openat(dir_fd_.get(), path.get().c_str(), O_DIRECTORY, 0))); | 273 HANDLE_EINTR(openat(dir_fd_.get(), path.get().c_str(), O_DIRECTORY, 0))); |
274 if (!new_dir_fd.is_valid()) { | 274 if (!new_dir_fd.is_valid()) { |
275 callback.Run(ErrnoToError(errno)); | 275 callback.Run(ErrnoToError(errno)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 if (unlinkat(dir_fd_.get(), path.get().c_str(), AT_REMOVEDIR) == 0) { | 353 if (unlinkat(dir_fd_.get(), path.get().c_str(), AT_REMOVEDIR) == 0) { |
354 callback.Run(Error::OK); | 354 callback.Run(Error::OK); |
355 return; | 355 return; |
356 } | 356 } |
357 | 357 |
358 callback.Run(ErrnoToError(errno)); | 358 callback.Run(ErrnoToError(errno)); |
359 } | 359 } |
360 | 360 |
361 } // namespace files | 361 } // namespace files |
362 } // namespace mojo | 362 } // namespace mojo |
OLD | NEW |