fallback to stat
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				BlockStorage/repertory/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	BlockStorage/repertory/pipeline/head This commit looks good
				
			This commit is contained in:
		@@ -180,27 +180,32 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
 | 
				
			|||||||
        std::string{path}.c_str(), GENERIC_READ,
 | 
					        std::string{path}.c_str(), GENERIC_READ,
 | 
				
			||||||
        FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
 | 
					        FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
 | 
				
			||||||
        OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
 | 
					        OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
 | 
				
			||||||
    if (file_handle == INVALID_HANDLE_VALUE) {
 | 
					    if (file_handle != INVALID_HANDLE_VALUE) {
 | 
				
			||||||
      throw std::runtime_error("failed to open file to get file times|" +
 | 
					 | 
				
			||||||
                               std::string{path} + '|' +
 | 
					 | 
				
			||||||
                               std::to_string(utils::get_last_error_code()));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      std::array<FILETIME, 3U> times{};
 | 
					      std::array<FILETIME, 3U> times{};
 | 
				
			||||||
    auto res =
 | 
					      auto res = ::GetFileTime(file_handle, ×.at(0U), ×.at(1U),
 | 
				
			||||||
        ::GetFileTime(file_handle, ×.at(0U), ×.at(1U), ×.at(2U));
 | 
					                               ×.at(2U));
 | 
				
			||||||
      ::CloseHandle(file_handle);
 | 
					      ::CloseHandle(file_handle);
 | 
				
			||||||
 | 
					      if (res) {
 | 
				
			||||||
    if (not res) {
 | 
					        ret.accessed =
 | 
				
			||||||
      throw std::runtime_error("failed to get file times|" + std::string{path} +
 | 
					            utils::time::windows_file_time_to_unix_time(times.at(1U));
 | 
				
			||||||
                               '|' +
 | 
					        ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U));
 | 
				
			||||||
                               std::to_string(utils::get_last_error_code()));
 | 
					        ret.modified =
 | 
				
			||||||
 | 
					            utils::time::windows_file_time_to_unix_time(times.at(2U));
 | 
				
			||||||
 | 
					        ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U));
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ret.accessed = utils::time::windows_file_time_to_unix_time(times.at(1U));
 | 
					    struct _stat64 st {};
 | 
				
			||||||
    ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U));
 | 
					    if (_stat64(std::string{path}.c_str(), &st) != 0) {
 | 
				
			||||||
    ret.modified = utils::time::windows_file_time_to_unix_time(times.at(2U));
 | 
					      throw std::runtime_error("failed to get file times|" + std::string{path} +
 | 
				
			||||||
    ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U));
 | 
					                               '|' + std::to_string(errno));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ret.accessed = utils::time::windows_time_t_to_unix_time(st.st_atime);
 | 
				
			||||||
 | 
					    ret.created = utils::time::windows_time_t_to_unix_time(st.st_ctime);
 | 
				
			||||||
 | 
					    ret.modified = utils::time::windows_time_t_to_unix_time(st.st_mtime);
 | 
				
			||||||
 | 
					    ret.written = utils::time::windows_time_t_to_unix_time(st.st_mtime);
 | 
				
			||||||
#else // !defined(_WIN32)
 | 
					#else // !defined(_WIN32)
 | 
				
			||||||
    struct stat64 st {};
 | 
					    struct stat64 st {};
 | 
				
			||||||
    if (stat64(std::string{path}.c_str(), &st) != 0) {
 | 
					    if (stat64(std::string{path}.c_str(), &st) != 0) {
 | 
				
			||||||
@@ -220,6 +225,7 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
 | 
				
			|||||||
    ret.written = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) +
 | 
					    ret.written = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) +
 | 
				
			||||||
                  static_cast<std::uint64_t>(st.st_mtim.tv_sec) *
 | 
					                  static_cast<std::uint64_t>(st.st_mtim.tv_sec) *
 | 
				
			||||||
                      utils::time::NANOS_PER_SECOND;
 | 
					                      utils::time::NANOS_PER_SECOND;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // defined(_WIN32)
 | 
					#endif // defined(_WIN32)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ret;
 | 
					    return ret;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user