2
0

mod.rs 719 B

123456789101112131415161718192021222324252627282930
  1. //! utime implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/utime.h.html
  2. use crate::{
  3. c_str::CStr,
  4. header::time::timespec,
  5. platform::{types::*, Pal, Sys},
  6. };
  7. #[repr(C)]
  8. #[derive(Clone)]
  9. pub struct utimbuf {
  10. pub actime: time_t,
  11. pub modtime: time_t,
  12. }
  13. #[no_mangle]
  14. pub unsafe extern "C" fn utime(filename: *const c_char, times: *const utimbuf) -> c_int {
  15. let filename = CStr::from_ptr(filename);
  16. let times_spec = [
  17. timespec {
  18. tv_sec: (*times).actime,
  19. tv_nsec: 0,
  20. },
  21. timespec {
  22. tv_sec: (*times).modtime,
  23. tv_nsec: 0,
  24. },
  25. ];
  26. Sys::utimens(filename, times_spec.as_ptr())
  27. }