Metadata
struct Metadata
Return the last access time (std.time.DateTime) of the file.
Return the last access time (std.time.DateTime) of the file.
Return the last access time (std.time.DateTime) of the file.
If the file system does not support last access time, return nil.
use std.fs;
fn main() throws {
let meta = try fs.metadata("foo.txt");
meta.accessed()?.to_string(); // => "2023-04-13T09:45:26+08:00"
}
Return the created time (std.time.DateTime) of the file.
Return the created time (std.time.DateTime) of the file.
Return the created time (std.time.DateTime) of the file.
If the file system does not support created time, return nil.
use std.fs;
fn main() throws {
let meta = try fs.metadata("foo.txt");
meta.created()?.to_string(); // => "2023-04-13T09:45:26+08:00"
}
Return true if is a dir
Return true if is a dir
Return true if is a dir
use std.fs;
fn main() throws {
try fs.metadata("foo.txt").is_dir(); // false
try fs.metadata("foo/bar/").is_dir(); // true
}
Return true if is a file
Return true if is a file
Return true if is a file
use std.fs;
fn main() throws {
try fs.metadata("foo.txt").is_file(); // true
try fs.metadata("foo/bar/").is_file(); // false
}
is_symlink
pub fn is_symlink(self): bool
Return true if is a symlink
is_symlink
pub fn is_symlink(self): bool
Return true if is a symlink
Return true if is a symlink
use std.fs;
fn main() throws {
try fs.metadata("foo.txt").is_symlink(); // false
try fs.metadata("foo/bar/").is_symlink(); // false
}
Return the file size in bytes.
Return the file size in bytes.
Return the file size in bytes.
use std.fs;
fn main() throws {
let meta = try fs.metadata("foo.txt");
meta.len(); // 11123
}
Return the last modified time (std.time.DateTime) of the file.
Return the last modified time (std.time.DateTime) of the file.
Return the last modified time (std.time.DateTime) of the file.
If the file system does not support last modified time, return nil.
use std.fs;
fn main() throws {
let meta = try fs.metadata("foo.txt");
meta.modified()?.to_string(); // => "2023-04-13T09:45:26+08:00"
}