OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/files/shared_impl.h" | 5 #include "services/files/shared_impl.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <time.h> | 10 #include <time.h> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 callback.Run(ERROR_OK, file_info.Pass()); | 53 callback.Run(ERROR_OK, file_info.Pass()); |
54 } | 54 } |
55 | 55 |
56 void TouchFD(int fd, | 56 void TouchFD(int fd, |
57 TimespecOrNowPtr atime, | 57 TimespecOrNowPtr atime, |
58 TimespecOrNowPtr mtime, | 58 TimespecOrNowPtr mtime, |
59 const TouchFDCallback& callback) { | 59 const TouchFDCallback& callback) { |
60 DCHECK_NE(fd, -1); | 60 DCHECK_NE(fd, -1); |
61 | 61 |
62 struct timespec times[2]; | 62 struct timespec times[2]; |
63 if (Error error = TimespecOrNowToStandardTimespec(atime.get(), ×[0])) { | 63 Error error = TimespecOrNowToStandardTimespec(atime.get(), ×[0]); |
| 64 if (error != ERROR_OK) { |
64 callback.Run(error); | 65 callback.Run(error); |
65 return; | 66 return; |
66 } | 67 } |
67 if (Error error = TimespecOrNowToStandardTimespec(mtime.get(), ×[1])) { | 68 |
| 69 error = TimespecOrNowToStandardTimespec(mtime.get(), ×[1]); |
| 70 if (error != ERROR_OK) { |
68 callback.Run(error); | 71 callback.Run(error); |
69 return; | 72 return; |
70 } | 73 } |
71 | 74 |
72 if (futimens(fd, times) != 0) { | 75 if (futimens(fd, times) != 0) { |
73 callback.Run(ErrnoToError(errno)); | 76 callback.Run(ErrnoToError(errno)); |
74 return; | 77 return; |
75 } | 78 } |
76 | 79 |
77 callback.Run(ERROR_OK); | 80 callback.Run(ERROR_OK); |
78 } | 81 } |
79 | 82 |
80 } // namespace files | 83 } // namespace files |
81 } // namespace mojo | 84 } // namespace mojo |
OLD | NEW |