Repository: ogham/exa
File: src/fs/file.rs (Rust)

Code before:
    pub fn changed_time(&self) -> Option<SystemTime> {
        let (mut sec, mut nanosec) = (self.metadata.ctime(), self.metadata.ctime_nsec());

        if sec < 0 {
            if nanosec > 0 {
                sec += 1;
                nanosec -= 1_000_000_000;
            }

            let duration = Duration::new(sec.abs() as u64, nanosec.abs() as u32);
            Some(UNIX_EPOCH - duration)
        }
        else {
            let duration = Duration::new(sec as u64, nanosec as u32);
            Some(UNIX_EPOCH + duration)
        }
    }

    #[cfg(windows)]
    pub fn changed_time(&self) -> Option<SystemTime> {
        return self.modified_time()
    }

    /// This file’s last accessed timestamp, if available on this platform.
    pub fn accessed_time(&self) -> Option<SystemTime> {
        self.metadata.accessed().ok()
    }

    /// This file’s created timestamp, if available on this platform.
    pub fn created_time(&self) -> Option<SystemTime> {
        self.metadata.created().ok()
    }

    /// This file’s ‘type’.
    ///
    /// This is used a the leftmost character of the permissions column.
    /// The file type can usually be guessed from the colour of the file, but
    /// ls puts this character there.
    #[cfg(unix)]
    pub fn type_char(&self) -> f::Type {
        if self.is_file() {
            f::Type::File
        }
        else if self.is_directory() {
            f::Type::Directory
        }
        else if self.is_pipe() {
            f::Type::Pipe
        }
        else if self.is_link() {
            f::Type::Link

Review comment (suggestion):
I don't quite understand the difference between `changed_time` & `modified_time`. Nor do I know if `changed_time` exists on Windows. So I just did this.

Code after:
        self.metadata.modified().ok()
    }

    /// This file’s last changed timestamp, if available on this platform.
    #[cfg(unix)]
    pub fn changed_time(&self) -> Option<SystemTime> {
        let (mut sec, mut nanosec) = (self.metadata.ctime(), self.metadata.ctime_nsec());

        if sec < 0 {
            if nanosec > 0 {
                sec += 1;
                nanosec -= 1_000_000_000;
            }

            let duration = Duration::new(sec.abs() as u64, nanosec.abs() as u32);
            Some(UNIX_EPOCH - duration)
        }
        else {
            let duration = Duration::new(sec as u64, nanosec as u32);
            Some(UNIX_EPOCH + duration)
        }
    }

    #[cfg(windows)]
    pub fn changed_time(&self) -> Option<SystemTime> {
        return self.modified_time()
    }

    /// This file’s last accessed timestamp, if available on this platform.
    pub fn accessed_time(&self) -> Option<SystemTime> {
        self.metadata.accessed().ok()
    }

    /// This file’s created timestamp, if available on this platform.
    pub fn created_time(&self) -> Option<SystemTime> {
        self.metadata.created().ok()
    }

    /// This file’s ‘type’.
    ///
    /// This is used a the leftmost character of the permissions column.
    /// The file type can usually be guessed from the colour of the file, but
    /// ls puts this character there.
    #[cfg(unix)]
    pub fn type_char(&self) -> f::Type {
        if self.is_file() {
            f::Type::File
        }
        else if self.is_directory() {
            f::Type::Directory
        }