int impl_fuse_context::set_file_time(PCWSTR file_name, const FILETIME* creation_time, const FILETIME* last_access_time, const FILETIME* last_write_time, PDOKAN_FILE_INFO dokan_file_info) { if (!ops_.utimens && !ops_.utime) return -EINVAL; if (!ops_.getattr) return -EINVAL; std::string fname=unixify(wchar_to_utf8_cstr(file_name)); CHECKED(check_and_resolve(&fname)); struct FUSE_STAT st={0}; CHECKED(ops_.getattr(fname.c_str(),&st)); if (ops_.utimens) { struct timespec tv[2]={{0,},}; //TODO: support nanosecond resolution //Access time CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(tv[0].tv_sec))); //Modification time CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(tv[1].tv_sec))); return ops_.utimens(fname.c_str(),tv); } else { struct utimbuf ut={0}; //Access time CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(ut.actime))); //Modification time CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(ut.modtime))); return ops_.utime(fname.c_str(),&ut); } }
int impl_fuse_context::set_file_time(PCWSTR file_name, const FILETIME *creation_time, const FILETIME *last_access_time, const FILETIME *last_write_time, PDOKAN_FILE_INFO dokan_file_info) { if (!ops_.utimens && !ops_.utime && !ops_.win_set_times) return -EINVAL; if (ops_.win_set_times) { std::string fname = unixify(wchar_to_utf8_cstr(file_name)); CHECKED(check_and_resolve(&fname)); impl_file_handle *hndl = reinterpret_cast<impl_file_handle *>(dokan_file_info->Context); if (!hndl) return ops_.win_set_times(fname.c_str(), NULL, creation_time, last_access_time, last_write_time); if (hndl->is_dir()) return -EACCES; fuse_file_info finfo(hndl->make_finfo()); return ops_.win_set_times(fname.c_str(), &finfo, creation_time, last_access_time, last_write_time); } if (!ops_.getattr) return -EINVAL; std::string fname = unixify(wchar_to_utf8_cstr(file_name)); CHECKED(check_and_resolve(&fname)); struct FUSE_STAT st = {0}; CHECKED(ops_.getattr(fname.c_str(), &st)); if (ops_.utimens) { struct timespec tv[2] = {0}; // TODO: support nanosecond resolution // Access time CHECKED(helper_set_time_struct(last_access_time, st.st_atim.tv_sec, &(tv[0].tv_sec))); // Modification time CHECKED(helper_set_time_struct(last_write_time, st.st_mtim.tv_sec, &(tv[1].tv_sec))); return ops_.utimens(fname.c_str(), tv); } else { struct utimbuf ut = {0}; // Access time CHECKED(helper_set_time_struct(last_access_time, st.st_atim.tv_sec, &(ut.actime))); // Modification time CHECKED(helper_set_time_struct(last_write_time, st.st_mtim.tv_sec, &(ut.modtime))); return ops_.utime(fname.c_str(), &ut); } }