Browse Source

initial commit

master
Makefile_dot_in 10 months ago
commit
4c335da271
4 changed files with 51 additions and 0 deletions
  1. +1
    -0
      .gitignore
  2. +23
    -0
      Cargo.lock
  3. +10
    -0
      Cargo.toml
  4. +17
    -0
      src/main.rs

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
/target

+ 23
- 0
Cargo.lock View File

@ -0,0 +1,23 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "get_btime"
version = "0.1.0"
dependencies = [
"statx-sys",
]
[[package]]
name = "libc"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae"
[[package]]
name = "statx-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5a504e8172a2e4966e0f445e18bdc95984fe553b2a9482ab6874be7bae5649"
dependencies = [
"libc",
]

+ 10
- 0
Cargo.toml View File

@ -0,0 +1,10 @@
[package]
name = "get_btime"
version = "0.1.0"
authors = ["Makefile_dot_in <makefile.dot.am@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
statx-sys = "0.2.0"

+ 17
- 0
src/main.rs View File

@ -0,0 +1,17 @@
use statx_sys::{statx, STATX_BTIME};
use std::env;
use std::ffi::CString;
use std::mem::MaybeUninit;
fn main() {
let filearg: String = env::args().skip(1).next().expect("um... where's the file?");
let filename = CString::new(filearg).expect("error: filename contains null (seriously?)");
// did I mention I suck at rust?
let res = unsafe {
let mut unsafe_res = MaybeUninit::<statx>::uninit();
statx(0, filename.as_ptr(), 0, STATX_BTIME, unsafe_res.as_mut_ptr());
unsafe_res.assume_init()
};
println!("{}", res.stx_btime.tv_sec);
}

Loading…
Cancel
Save