#gamedev #cargo #filesystem #tools

copy_to_output

A small rust library to copy files/folders from the project directory to the output directory

4 stable releases

new 2.1.0 Mar 26, 2023
2.0.1 Mar 18, 2023
2.0.0 Jul 7, 2022
1.0.0 Jun 21, 2022

#241 in Filesystem

Download history 43/week @ 2022-12-05 8/week @ 2022-12-12 8/week @ 2022-12-19 45/week @ 2022-12-26 16/week @ 2023-01-02 18/week @ 2023-01-09 30/week @ 2023-01-16 188/week @ 2023-01-23 84/week @ 2023-01-30 205/week @ 2023-02-06 331/week @ 2023-02-13 145/week @ 2023-02-20 102/week @ 2023-02-27 73/week @ 2023-03-06 131/week @ 2023-03-13 126/week @ 2023-03-20

438 downloads per month

MIT/Apache

7KB

copy_to_output

A small rust library to copy files/folders from the project directory to the output directory

Copy file/folder

copy_to_output("path name", "build profile");

When building

You can use a build.rs file to copy a file/folder to the output directory when running cargo build

Example build.rs

 use std::env;  
 use copy_to_output::copy_to_output;  
   
 fn main() {  
     // Re-runs script if any files in res are changed  
     println!("cargo:rerun-if-changed=res/*");  
     copy_to_output("res", &env::var("PROFILE").unwrap()).expect("Could not copy");  
 }

where 'res' is the name of the directory to copy to the output directory

Example Cargo.toml

[package]
name = "test_crate"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
copy_to_output = "2.1.0"
glob = "0.3""

glob provides the * wildcard operator for the println!() line in build.rs

Both of these examples are in the example_files folder in this repo

Dependencies

~225KB