[][src]Crate filetime

Timestamps for files in Rust

This library provides platform-agnostic inspection of the various timestamps present in the standard fs::Metadata structure.

Installation

Add this to your Cargo.toml:

[dependencies]
filetime = "0.2"

Usage

use std::fs;
use filetime::FileTime;

let metadata = fs::metadata("foo.txt").unwrap();

let mtime = FileTime::from_last_modification_time(&metadata);
println!("{}", mtime);

let atime = FileTime::from_last_access_time(&metadata);
assert!(mtime < atime);

// Inspect values that can be interpreted across platforms
println!("{}", mtime.unix_seconds());
println!("{}", mtime.nanoseconds());

// Print the platform-specific value of seconds
println!("{}", mtime.seconds());

Structs

FileTime

A helper structure to represent a timestamp for a file.

Functions

set_file_atime

Set the last access time for a file on the filesystem.

set_file_handle_times

Set the last access and modification times for a file handle.

set_file_mtime

Set the last modification time for a file on the filesystem.

set_file_times

Set the last access and modification times for a file on the filesystem.

set_symlink_file_times

Set the last access and modification times for a file on the filesystem. This function does not follow symlink.