« first day (1627 days earlier)      last day (1844 days later) » 

7:17 AM
It seems like the file.metadata().creation_time() does not work for unix:
https://www.reddit.com/r/rust/comments/3o50mz/get_file_creation_date/

Do you have any idea how to get file creation time on Unix platform?
There is an API like ctime() in unix metadata but I am not sure that it works for all the unix platforms?
 
@AkinerAlkan your reddit post is 3 years old. Are you sure it's still correct?
 
@hellow, This is why I am asking here ^^ I think you are probably more up to date than this reddit post
 
why don't your try it ;) the playground runs on linux
 
@hellow hmm wise idea :D
 
creation_time is a windows only function btw.. :/
Err(Custom { kind: Other, error: StringError("creation time is not available on this platform currently") })
:(
it's time for you @AkinerAlkan to open a PR and fix that ;)
 
7:32 AM
yes but this is not the unix metadata
 
hmm
But it seems ctime() will be updated to get the creation time in the future I think
Seems like writing the code with ctime() instead of metadata.modified() will be more convenient I guess
 
There's usually no creation time for files on linux (depends on the FS, I think). That's not a Rust problem
 
MAC times are pieces of file system metadata which record when certain events pertaining to a computer file occurred most recently. The events are usually described as "modification" (the data in the file was modified), "access" (some part of the file was read), and "metadata change" (the file's permissions or ownership were modified), although the acronym is derived from the "mtime", "atime", and "ctime" structures maintained by Unix file systems. Windows file systems do not update ctime when a file's metadata is changed, instead using the field to record the time when a file was first created...
 
On ext4 I think the real creation time is kept but hard to read
 
7:42 AM
yes
would it be worth to extend it?
 
elaborate
 
Creation time is a fuzzy notion, and it's usually not supported on linux
 
102
Q: How to find creation date of file?

ÖzzeshI want to find out the creation date of particular file, not modification date or access date. I have tried with ls -ltrh and stat filename.

 
what should happen if you empty a file then fill it? If you move it back and forth?
 
7:44 AM
what happens on windows?
 
I guess it depends on how you do it
 
x)
 
You can move a file byte per byte and then decide to put the date of the source or not. Those informations are writable anyway
 
@AkinerAlkan I think it's nothing you should rely on
only windows can give you the creation time, all other OSes won't
 
I what context would you use this information ?
 
7:48 AM
Well okay this creation time is shown in the Frontend to the user for the file
I guess the best option currently to use ctime on linux environments instead showing no time at all :)
 
 
1 hour later…
9:14 AM
I have some mindfuckup right now. I want to find a number so such x * a ≥ b where a and b are given. Keep in mind that I have integer arithmic and I want to avoid division, because it's expensive on my arm
pub fn find_x(a: u32, b: u32) -> u32 {
    let mut ret = a / b;
    if (ret * b) < a {
        ret += 1;
    }
    ret
}
my approach, but I don't like it ^^
also it has a division :|
 
Any x, or minimal x?
 
minimal please ^^
 
What about out of bounds? Should return Option?
 
also I fucked up the example...
let me clean it up real quick
 
u32
 
9:18 AM
no Option
pub fn find_x(binary_size: u32, block_size: u32) -> u32 {
    let mut ret = binary_size / block_size;
    if (ret * block_size) < binary_size {
        ret += 1;
    }
    ret
}

#[test]
fn t() {
    assert_eq!(3, find_x(5, 2));
    assert_eq!(3, find_x(6, 2));
    assert_eq!(4, find_x(7, 2));
    assert_eq!(1, find_x(1, 2));
}
there we go ^^
some background: I want to write a binary to flash and need to compute the amount of cells I need, so i have a binary with given size and the size of one block/cell
 
```
pub fn find_x(binary_size: u32, block_size: u32) -> u32 {
(1..).find(|x| x * block_size >= binary_size).expect("Out of bounds")
}
```
And it's only O(n) - pretty good huh
 
ah, of course.. multiplication ^^
the other one is O(1) ^^ but I really don't like the division there
let me try it
 
You can make it O(log n) with interval bisection
I'm not sure what is wrong with the O(1) solution with division though!
 
I thought of some binary tricks with shifts
have you ever looked up __aeabi_uidiv? It's a beast!
 
no I haven't
 
9:27 AM
thanks peter, I take the find approach
rust can optimize very good ^^
 
9:44 AM
Ok. I actually posted that not entirely seriously...
 
x) it works, it fits, it's easy
and because there's always an answer I can use unwrap 0:)
 
I guess it's ok if you also know that the number will always be small
Still not sure why you can't use division!
 
I could, but I would like to not use it
in this specific case
you decide ;)
two adds and one compare
pretty good
 
10:01 AM
I'm not sure that I understand what that output means
 
10:16 AM
@hellow and a loop...
I prefer
pub fn two(binary_size: u32, block_size: u32) -> u32 {
    let x = binary_size / block_size;
    if (x * block_size) < binary_size {
        x + 1
    }
    else {
        x
    }
}
or maybe:
pub fn find_x(binary_size: u32, block_size: u32) -> u32 {
    let x = binary_size / block_size;
    if (binary_size % block_size) != 0 {
        x + 1
    } else {
        x
    }
}
note that the compiler write the same assembly for both ^^
oh not exactly
 
11:18 AM
Hey,
I am trying to give a static method reference and type argument for the Box::new and could not managed to compile it.

Any ideas how can I implement it?
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3ad1fc8e1186bec80b734ffe0d0b4506
 
11:35 AM
Strange, Clippy's unnecessary_cast lint isn't working.
 
11:45 AM
 
12:02 PM
@AkinerAlkan good question !
 
@Stargateur Thanks
 
@AkinerAlkan your question is good-ish... I mean, you only can construct MyStructs from your vec, why do you want a Box<MyTrait> afterwards?
 
@hellow Because it is not a complete scenario
Trying to keep it minimal
The real code does not have such like vec![MyStruct] for sure
It is constructed from the outside and I am trying to convert it on my side
lets assume it like this for now ;)
 
okay :)
 
12:48 PM
Sven's suggestion seems better but I think there needs still some improvement since I had to do type casting with as
There is also possibility to specify return type in closure too like:
.into_iter().map(|x| -> Box<MyTrait> { Box::new(x) });
but still this is not what I am exactly looking for :(
 
@AkinerAlkan not bad
@AkinerAlkan I don't think there is a solution
 
In any case, going to wait untill tomorrow
If there is no better answer, gonna accept it afterwards
 
 
4 hours later…
4:36 PM
Just noticed an old open Rust question that is just a typo. stackoverflow.com/q/38152638/1233251
 
 
3 hours later…
8:04 PM
@DenysSéguret Looks like someone else wanted more out of terminal UIs, incl. mouse events and portability: users.rust-lang.org/t/termit-attack-on-tui/26728
I'll have to try it on windows maybe sometime this weekend
 
I saw that... but it's not cross platform
I'm discussing with the crossterm authors
They're working on event parsing.
They unfortunately focus on async handling, which leds to busy loops
I've written in a fork a working implementation of a blocking event iterator... and I tested it in broot (partial tests only). I'll see if they're OK to go this way or if they really want to force people use their async threaded solution
seems like they like my thing
 
Ah. Yeah, I don't particularly want a spinloop in the background. If I wanted to eat a core, I can do that on my own. And control how much.
 
tokio has real async system
I'm really impress by this lib
 
yes but when you use another system orchestrating the threads, or when you build yours, you don't want to use a library managing its own threads. that's why I think a sync blocking solution must be given
 
Yeah, exactly. I don't want a required thread or threadpool. I'll call one up myself if I want one. I might use something like tokio. But I want the choice.
 
 
2 hours later…
10:31 PM
 

« first day (1627 days earlier)      last day (1844 days later) »