| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 file_info->atime->nanoseconds = static_cast<int32_t>(buf.st_atime_nsec); | 43 file_info->atime->nanoseconds = static_cast<int32_t>(buf.st_atime_nsec); |
| 44 file_info->mtime->seconds = static_cast<int64_t>(buf.st_mtime); | 44 file_info->mtime->seconds = static_cast<int64_t>(buf.st_mtime); |
| 45 file_info->mtime->nanoseconds = static_cast<int32_t>(buf.st_mtime_nsec); | 45 file_info->mtime->nanoseconds = static_cast<int32_t>(buf.st_mtime_nsec); |
| 46 #else | 46 #else |
| 47 file_info->atime->seconds = static_cast<int64_t>(buf.st_atim.tv_sec); | 47 file_info->atime->seconds = static_cast<int64_t>(buf.st_atim.tv_sec); |
| 48 file_info->atime->nanoseconds = static_cast<int32_t>(buf.st_atim.tv_nsec); | 48 file_info->atime->nanoseconds = static_cast<int32_t>(buf.st_atim.tv_nsec); |
| 49 file_info->mtime->seconds = static_cast<int64_t>(buf.st_mtim.tv_sec); | 49 file_info->mtime->seconds = static_cast<int64_t>(buf.st_mtim.tv_sec); |
| 50 file_info->mtime->nanoseconds = static_cast<int32_t>(buf.st_mtim.tv_nsec); | 50 file_info->mtime->nanoseconds = static_cast<int32_t>(buf.st_mtim.tv_nsec); |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 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 Error error = TimespecOrNowToStandardTimespec(atime.get(), ×[0]); | 63 Error error = TimespecOrNowToStandardTimespec(atime.get(), ×[0]); |
| 64 if (error != ERROR_OK) { | 64 if (error != Error::OK) { |
| 65 callback.Run(error); | 65 callback.Run(error); |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 | 68 |
| 69 error = TimespecOrNowToStandardTimespec(mtime.get(), ×[1]); | 69 error = TimespecOrNowToStandardTimespec(mtime.get(), ×[1]); |
| 70 if (error != ERROR_OK) { | 70 if (error != Error::OK) { |
| 71 callback.Run(error); | 71 callback.Run(error); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (futimens(fd, times) != 0) { | 75 if (futimens(fd, times) != 0) { |
| 76 callback.Run(ErrnoToError(errno)); | 76 callback.Run(ErrnoToError(errno)); |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 | 79 |
| 80 callback.Run(ERROR_OK); | 80 callback.Run(Error::OK); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace files | 83 } // namespace files |
| 84 } // namespace mojo | 84 } // namespace mojo |
| OLD | NEW |