Created
May 29, 2012 01:35
-
-
Save killerswan/2822066 to your computer and use it in GitHub Desktop.
where is libc::stat, anyways?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn chmod(filepath: str, mode: i32) -> i32 { | |
| import libc::types::os::arch::posix88::mode_t; | |
| ret str::as_c_str(filepath, {|fp| libc::chmod(fp, mode as mode_t) }); | |
| } | |
| fn cp(src: str, dest: str) { | |
| // What I'd like to do is something like so, | |
| // but where's the stat function? | |
| // | |
| //let st = libc::stat(src); | |
| //let mm = st.mode; | |
| let mm = 493_i32; /* octal 755 */ | |
| os::copy_file(src, dest); | |
| chmod(dest, mm); | |
| } | |
| fn main() { | |
| cp("./dir/a", "./dir2/a"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment