[INFO] fetching crate yok 0.1.9...
[INFO] testing yok-0.1.9 against 1.75.0 for beta-1.76-1
[INFO] extracting crate yok 0.1.9 into /workspace/builds/worker-0-tc1/source
[INFO] validating manifest of crates.io crate yok 0.1.9 on toolchain 1.75.0
[INFO] running `Command { std: CARGO_HOME="/workspace/cargo-home" RUSTUP_HOME="/workspace/rustup-home" "/workspace/cargo-home/bin/cargo" "+1.75.0" "metadata" "--manifest-path" "Cargo.toml" "--no-deps", kill_on_drop: false }`
[INFO] started tweaking crates.io crate yok 0.1.9
[INFO] finished tweaking crates.io crate yok 0.1.9
[INFO] tweaked toml for crates.io crate yok 0.1.9 written to /workspace/builds/worker-0-tc1/source/Cargo.toml
[INFO] crate crates.io crate yok 0.1.9 already has a lockfile, it will not be regenerated
[INFO] running `Command { std: CARGO_HOME="/workspace/cargo-home" RUSTUP_HOME="/workspace/rustup-home" "/workspace/cargo-home/bin/cargo" "+1.75.0" "fetch" "--manifest-path" "Cargo.toml", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+1.75.0" "metadata" "--no-deps" "--format-version=1", kill_on_drop: false }`
[INFO] [stdout] 49e771e3efb33357eac4e968d1c66ae0321063567d962ed916e36918a228316c
[INFO] running `Command { std: "docker" "start" "-a" "49e771e3efb33357eac4e968d1c66ae0321063567d962ed916e36918a228316c", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "inspect" "49e771e3efb33357eac4e968d1c66ae0321063567d962ed916e36918a228316c", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "49e771e3efb33357eac4e968d1c66ae0321063567d962ed916e36918a228316c", kill_on_drop: false }`
[INFO] [stdout] 49e771e3efb33357eac4e968d1c66ae0321063567d962ed916e36918a228316c
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=warn" "-e" "RUSTDOCFLAGS=--cap-lints=warn" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+1.75.0" "build" "--frozen" "--message-format=json", kill_on_drop: false }`
[INFO] [stdout] f8034361c192b7bd45078ad223f8e68fa0ec0a96d60a1069575a06346e45889b
[INFO] running `Command { std: "docker" "start" "-a" "f8034361c192b7bd45078ad223f8e68fa0ec0a96d60a1069575a06346e45889b", kill_on_drop: false }`
[INFO] [stderr]    Compiling yok v0.1.9 (/opt/rustwide/workdir)
[INFO] [stderr]     Finished dev [unoptimized + debuginfo] target(s) in 0.84s
[INFO] running `Command { std: "docker" "inspect" "f8034361c192b7bd45078ad223f8e68fa0ec0a96d60a1069575a06346e45889b", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "f8034361c192b7bd45078ad223f8e68fa0ec0a96d60a1069575a06346e45889b", kill_on_drop: false }`
[INFO] [stdout] f8034361c192b7bd45078ad223f8e68fa0ec0a96d60a1069575a06346e45889b
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=warn" "-e" "RUSTDOCFLAGS=--cap-lints=warn" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+1.75.0" "test" "--frozen" "--no-run" "--message-format=json", kill_on_drop: false }`
[INFO] [stdout] e8cea60cc08847cdca9c16985917c8c787ee76241ff5ce257a8cf94de7f37950
[INFO] running `Command { std: "docker" "start" "-a" "e8cea60cc08847cdca9c16985917c8c787ee76241ff5ce257a8cf94de7f37950", kill_on_drop: false }`
[INFO] [stderr]    Compiling yok v0.1.9 (/opt/rustwide/workdir)
[INFO] [stderr]     Finished test [unoptimized + debuginfo] target(s) in 0.46s
[INFO] running `Command { std: "docker" "inspect" "e8cea60cc08847cdca9c16985917c8c787ee76241ff5ce257a8cf94de7f37950", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "e8cea60cc08847cdca9c16985917c8c787ee76241ff5ce257a8cf94de7f37950", kill_on_drop: false }`
[INFO] [stdout] e8cea60cc08847cdca9c16985917c8c787ee76241ff5ce257a8cf94de7f37950
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc1/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=warn" "-e" "RUSTDOCFLAGS=--cap-lints=warn" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+1.75.0" "test" "--frozen", kill_on_drop: false }`
[INFO] [stdout] 1cc21dcfd01a057855765def32c85c4c8e53cc4757453cd08d6b3fcb783a8f60
[INFO] running `Command { std: "docker" "start" "-a" "1cc21dcfd01a057855765def32c85c4c8e53cc4757453cd08d6b3fcb783a8f60", kill_on_drop: false }`
[INFO] [stderr]    Compiling yok v0.1.9 (/opt/rustwide/workdir)
[INFO] [stderr]     Finished test [unoptimized + debuginfo] target(s) in 0.47s
[INFO] [stderr]      Running unittests src/lib.rs (/opt/rustwide/target/debug/deps/yok-36a6e304c56dd187)
[INFO] [stdout] 
[INFO] [stdout] running 0 tests
[INFO] [stdout] 
[INFO] [stdout] test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[INFO] [stdout] 
[INFO] [stderr]      Running unittests src/main.rs (/opt/rustwide/target/debug/deps/yok-39a31bac2a621e79)
[INFO] [stdout] 
[INFO] [stdout] running 0 tests
[INFO] [stdout] 
[INFO] [stdout] test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[INFO] [stdout] 
[INFO] [stderr]    Doc-tests yok
[INFO] [stdout] 
[INFO] [stdout] running 3 tests
[INFO] [stdout] test src/lib.rs - DirEntry (line 10) ... FAILED
[INFO] [stdout] test src/lib.rs - include_dir (line 282) ... FAILED
[INFO] [stdout] test src/lib.rs - Dir::extract (line 218) ... FAILED
[INFO] [stdout] 
[INFO] [stdout] failures:
[INFO] [stdout] 
[INFO] [stdout] ---- src/lib.rs - DirEntry (line 10) stdout ----
[INFO] [stdout] Test executable failed (exit status: 101).
[INFO] [stdout] 
[INFO] [stdout] stdout:
[INFO] [stdout] use std::{mem, path::PathBuf, str::FromStr};
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct DirEntry {
[INFO] [stdout]     pub path: String,
[INFO] [stdout]     pub is_dir: bool,
[INFO] [stdout]     pub is_file: bool,
[INFO] [stdout]     pub contents: Vec<u8>,
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct Dir {
[INFO] [stdout]     pub data: Vec<DirEntry>,
[INFO] [stdout] }
[INFO] [stdout] pub trait Bytes {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn from_bytes(&self) -> Dir;
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn into_dir(&self) -> Dir;
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for [u8] {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for Dir {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement as_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         // Calculate the total size of the serialized data
[INFO] [stdout]         let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]             size += entry.path.as_bytes().len();
[INFO] [stdout]             size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]             size += entry.contents.len();
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]         // Write the length prefix
[INFO] [stdout]         bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             // Write the size prefix for this entry
[INFO] [stdout]             bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             // Write the entry data
[INFO] [stdout]             bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]             bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]             bytes.extend((entry.contents.len() as u32).to_le_bytes().iter());
[INFO] [stdout]             bytes.extend(entry.contents.iter());
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         bytes
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement from_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]         let mut cursor = 0;
[INFO] [stdout]         let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]         if bytes.len() < len_prefix_size {
[INFO] [stdout]             return None;
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let len = u32::from_le_bytes([
[INFO] [stdout]             bytes[cursor],
[INFO] [stdout]             bytes[cursor + 1],
[INFO] [stdout]             bytes[cursor + 2],
[INFO] [stdout]             bytes[cursor + 3],
[INFO] [stdout]         ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]         cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]         let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]         for _ in 0..len {
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let entry_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < end_pos {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]             cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + 2 {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let is_dir = bytes[cursor] != 0;
[INFO] [stdout]             let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]             cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let content_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + content_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let contents = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]             cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]             data.push(DirEntry {
[INFO] [stdout]                 path,
[INFO] [stdout]                 is_dir,
[INFO] [stdout]                 is_file,
[INFO] [stdout]                 contents,
[INFO] [stdout]             });
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         Some(Dir { data })
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] fn get_new_path(path: &str) -> String {
[INFO] [stdout]     let yok_path = match std::env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     let path = path.to_string().replace("\\", "/").to_string();
[INFO] [stdout]     if yok_path != "."{
[INFO] [stdout]         return path;
[INFO] [stdout]     }else {
[INFO] [stdout]         return path;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] 
[INFO] [stdout] impl Dir {
[INFO] [stdout]     /// include dir at compile time
[INFO] [stdout]     /// in default die path is current dir
[INFO] [stdout]     ///
[INFO] [stdout]     /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout]     ///
[INFO] [stdout]     /// you can also set YOK_PATH env before cargo run
[INFO] [stdout]     ///
[INFO] [stdout]     /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout]     /// ```rust
[INFO] [stdout]     ///   use yok::include_dir;
[INFO] [stdout]     ///   use yok::Dir;
[INFO] [stdout]     ///   use yok::DirEntry;
[INFO] [stdout]     ///   use yok::Bytes;
[INFO] [stdout]     ///   const DATA:&[u8] = include_dir();
[INFO] [stdout]     ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout]     ///   for entry in &dir.data{
[INFO] [stdout]     ///       if entry.is_file{
[INFO] [stdout]     ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]     ///       }else if entry.is_dir {
[INFO] [stdout]     ///           println!("{}",entry.path);
[INFO] [stdout]     ///       }
[INFO] [stdout]     ///   }
[INFO] [stdout]     ///   dir.extract("./demo");
[INFO] [stdout]     /// ```
[INFO] [stdout]     ///
[INFO] [stdout]     pub fn extract(&self, base_dir: impl ToString) ->std::io::Result<()>{
[INFO] [stdout]         std::fs::create_dir_all(base_dir.to_string()).expect("create to dir error");
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_dir {
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 std::fs::create_dir_all(path.clone()).expect("create to dir error");
[INFO] [stdout]                 if cfg!(target_os = "windows") {
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }else{
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_file {
[INFO] [stdout]                 use std::fs::{self, File, OpenOptions};
[INFO] [stdout]                 use std::io::prelude::*;
[INFO] [stdout]                 use std::os::unix::fs::OpenOptionsExt;
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 if !path.exists(){
[INFO] [stdout]                     let mut open_options = OpenOptions::new();
[INFO] [stdout]                     open_options.mode(0o777); // Set read/write permission for owner, read-only for others
[INFO] [stdout]                     let file = open_options.create(true).write(true).open(path).unwrap();
[INFO] [stdout]                     let mut file_writer = std::io::BufWriter::new(file);
[INFO] [stdout]                     file_writer.write_all(&entry.contents).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(())
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] pub const fn include_dir() -> &'static [u8] {
[INFO] [stdout]     include_bytes!("../../.yok")
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::include_dir;
[INFO] [stdout]     use yok::Bytes;
[INFO] [stdout]     use yok::Dir;
[INFO] [stdout]     use yok::DirEntry;
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             // println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             // println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] 
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] src
[INFO] [stdout] use std::{
[INFO] [stdout]     fs, io,
[INFO] [stdout]     path::{Path, PathBuf},
[INFO] [stdout] };
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     use std::mem;
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct DirEntry {
[INFO] [stdout]         path: String,
[INFO] [stdout]         is_dir: bool,
[INFO] [stdout]         is_file: bool,
[INFO] [stdout]         content: Vec<u8>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct Dir {
[INFO] [stdout]         data: Vec<DirEntry>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement as_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]             // Calculate the total size of the serialized data
[INFO] [stdout]             let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]                 size += entry.path.as_bytes().len();
[INFO] [stdout]                 size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]                 size += entry.content.len();
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]             // Write the length prefix
[INFO] [stdout]             bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 // Write the size prefix for this entry
[INFO] [stdout]                 bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]                 // Write the entry data
[INFO] [stdout]                 bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]                 bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]                 bytes.extend((entry.content.len() as u32).to_le_bytes().iter());
[INFO] [stdout]                 bytes.extend(entry.content.iter());
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             bytes
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement from_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         #[allow(warnings)]
[INFO] [stdout]         pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]             let mut cursor = 0;
[INFO] [stdout]             let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let len = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]             for _ in 0..len {
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let entry_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < end_pos {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]                 cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + 2 {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let is_dir = bytes[cursor] != 0;
[INFO] [stdout]                 let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]                 cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + content_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]                 cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]                 data.push(DirEntry {
[INFO] [stdout]                     path,
[INFO] [stdout]                     is_dir,
[INFO] [stdout]                     is_file,
[INFO] [stdout]                     content,
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             Some(Dir { data })
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     pub fn walk_dir(path: impl ToString) -> io::Result<Vec<PathBuf>> {
[INFO] [stdout]         let path = path.to_string();
[INFO] [stdout]         let dir = Path::new(&path);
[INFO] [stdout]         let mut files = Vec::new();
[INFO] [stdout]         for entry in fs::read_dir(dir)? {
[INFO] [stdout]             let entry = entry?;
[INFO] [stdout]             let newpath = entry.path();
[INFO] [stdout] 
[INFO] [stdout]             if newpath.is_dir() {
[INFO] [stdout]                 files.extend(walk_dir(&newpath.display())?);
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             } else {
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(files)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     use std::env;
[INFO] [stdout]     let yok_path = match env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     println!("cargo:rerun-if-env-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed=main.rs");
[INFO] [stdout]     println!("cargo:rerun-if-changed=lib.rs");
[INFO] [stdout]     let yok_path = std::path::Path::new(&yok_path);
[INFO] [stdout]     if yok_path.is_dir() {
[INFO] [stdout]         let mut res_dir: Vec<DirEntry> = vec![];
[INFO] [stdout]         let dir_list = walk_dir(yok_path.display()).expect("walk dir error");
[INFO] [stdout]         for dir in dir_list {
[INFO] [stdout]             if dir.is_file() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: false,
[INFO] [stdout]                     is_file: true,
[INFO] [stdout]                     content: std::fs::read(dir).expect("read dir error"),
[INFO] [stdout]                 });
[INFO] [stdout]             } else if dir.is_dir() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: true,
[INFO] [stdout]                     is_file: false,
[INFO] [stdout]                     content: vec![],
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         let all_dir: Dir = Dir { data: res_dir };
[INFO] [stdout]         let all_dir_bytes = all_dir.as_bytes();
[INFO] [stdout]         if let Ok(_) = std::fs::write(format!("../.yok"), all_dir_bytes){}
[INFO] [stdout]     } else {
[INFO] [stdout]         eprintln!("Environment variable 'YOK_PATH' not dir");
[INFO] [stdout]         return;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] categories = ["development-tools", "game-engines", "web-programming"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] keywords = ["include", "dir", "compile-time"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] name = "yok"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] rm -rf path
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] # yok
[INFO] [stdout] 
[INFO] [stdout] [![Crates.io](https://img.shields.io/crates/v/yok.svg)](https://crates.io/crates/yok)
[INFO] [stdout] [![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://gitlab.com/andrew_ryan/yok)
[INFO] [stdout] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/andrew_ryan/yok/-/raw/master/LICENSE)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] A crate for Embed the contents of a directory in your binary at compile time.
[INFO] [stdout] 
[INFO] [stdout] ## Getting Started
[INFO] [stdout] ```sh
[INFO] [stdout] cargo add yok
[INFO] [stdout] ```
[INFO] [stdout] ```rust
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::{Dir, Bytes,include_dir};
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] }
[INFO] [stdout] ```
[INFO] [stdout] ## Set YOK_PATH env and run or default path is cuttent dir
[INFO] [stdout] ```sh
[INFO] [stdout] # linux,macos
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] # windows cmd
[INFO] [stdout] set YOK_PATH="C:\path\to\your\directory"
[INFO] [stdout] # windows powershell
[INFO] [stdout] $env:YOK_PATH = "C:\path\to\your\directory"
[INFO] [stdout] 
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] ```
[INFO] [stdout] MIT License
[INFO] [stdout] 
[INFO] [stdout] Copyright (c) [year] [fullname]
[INFO] [stdout] 
[INFO] [stdout] Permission is hereby granted, free of charge, to any person obtaining a copy
[INFO] [stdout] of this software and associated documentation files (the "Software"), to deal
[INFO] [stdout] in the Software without restriction, including without limitation the rights
[INFO] [stdout] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[INFO] [stdout] copies of the Software, and to permit persons to whom the Software is
[INFO] [stdout] furnished to do so, subject to the following conditions:
[INFO] [stdout] 
[INFO] [stdout] The above copyright notice and this permission notice shall be included in all
[INFO] [stdout] copies or substantial portions of the Software.
[INFO] [stdout] 
[INFO] [stdout] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[INFO] [stdout] IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[INFO] [stdout] FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[INFO] [stdout] AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[INFO] [stdout] LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[INFO] [stdout] OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
[INFO] [stdout] SOFTWARE.
[INFO] [stdout] # This file is automatically @generated by Cargo.
[INFO] [stdout] # It is not intended for manual editing.
[INFO] [stdout] version = 3
[INFO] [stdout] 
[INFO] [stdout] [[package]]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] 
[INFO] [stdout] image: rustlang/rust:nightly
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] push:cargo:
[INFO] [stdout]   script:
[INFO] [stdout]     - rustc --version && cargo --version  
[INFO] [stdout]     - cargo publish --allow-dirty --token cioHYTp8cpgbRbBqcJvqGF7rUIjJQSlBvH3
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] keywords = ["include","dir","compile-time"]
[INFO] [stdout] categories = ["development-tools","game-engines","web-programming"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] use std::fs::File;
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] use std::io::{BufWriter, Write};
[INFO] [stdout] use std::path::Path;
[INFO] [stdout] use zip::write::FileOptions;
[INFO] [stdout] use zip::ZipWriter;
[INFO] [stdout] use std::io::Read;
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     // Path to the directory to compress
[INFO] [stdout]     let dir_path = Path::new(".");
[INFO] [stdout] 
[INFO] [stdout]     // Path to the output ZIP file
[INFO] [stdout]     let zip_path = Path::new("app.zip");
[INFO] [stdout] 
[INFO] [stdout]     // Create a new ZIP file
[INFO] [stdout]     let file = File::create(&zip_path).unwrap();
[INFO] [stdout]     let writer = BufWriter::new(file);
[INFO] [stdout]     let mut zip = ZipWriter::new(writer);
[INFO] [stdout] 
[INFO] [stdout]     // Recursively add all files and directories in the input directory to the ZIP file
[INFO] [stdout]     add_directory_to_zip(&mut zip, dir_path, "").unwrap();
[INFO] [stdout] 
[INFO] [stdout]     // Finalize the ZIP file
[INFO] [stdout]     zip.finish().unwrap();
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Recursively adds a directory (and all its contents) to a ZipWriter
[INFO] [stdout] fn add_directory_to_zip(zip: &mut ZipWriter<BufWriter<File>>, dir_path: &Path, base_path: &str) -> zip::result::ZipResult<()> {
[INFO] [stdout]     for entry in dir_path.read_dir()? {
[INFO] [stdout]         let path = entry?.path();
[INFO] [stdout] 
[INFO] [stdout]         if path.is_dir() {
[INFO] [stdout]             // Recursively add the subdirectory
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let new_base_path = format!("{}/{}", base_path, name);
[INFO] [stdout]             add_directory_to_zip(zip, &path, &new_base_path)?;
[INFO] [stdout]         } else {
[INFO] [stdout]             // Add the file to the ZIP archive
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let options = FileOptions::default()
[INFO] [stdout]                 .compression_method(zip::CompressionMethod::Deflated)
[INFO] [stdout]                 .unix_permissions(0o755); // Set appropriate permissions for the file
[INFO] [stdout]             zip.start_file(format!("{}/{}", base_path, name), options)?;
[INFO] [stdout]             let mut file = File::open(&path)?;
[INFO] [stdout]             let mut buffer = Vec::new();
[INFO] [stdout]             file.read_to_end(&mut buffer)?;
[INFO] [stdout]             zip.write_all(&buffer)?;
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     Ok(())
[INFO] [stdout] }
[INFO] [stdout] /target
[INFO] [stdout] Cargo.lock
[INFO] [stdout] .DS_Store
[INFO] [stdout] 
[INFO] [stdout] stderr:
[INFO] [stdout] thread 'main' panicked at /opt/rustwide/workdir/src/lib.rs:236:55:
[INFO] [stdout] create to dir error: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }
[INFO] [stdout] stack backtrace:
[INFO] [stdout]    0:     0x5637868a2acc - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
[INFO] [stdout]    1:     0x5637868a2acc - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[INFO] [stdout]    2:     0x5637868a2acc - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
[INFO] [stdout]    3:     0x5637868a2acc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
[INFO] [stdout]    4:     0x5637868c2670 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
[INFO] [stdout]    5:     0x5637868c2670 - core::fmt::write::h3a39390d8560d9c9
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
[INFO] [stdout]    6:     0x5637868a0d4f - std::io::Write::write_fmt::h5fc9997dfe05f882
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
[INFO] [stdout]    7:     0x5637868a28b4 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
[INFO] [stdout]    8:     0x5637868a28b4 - std::sys_common::backtrace::print::h23a2d212c6fff936
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
[INFO] [stdout]    9:     0x5637868a3dc7 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
[INFO] [stdout]   10:     0x5637868a3b2f - std::panicking::default_hook::h6038f2eba384e475
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
[INFO] [stdout]   11:     0x5637868a4248 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
[INFO] [stdout]   12:     0x5637868a412e - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
[INFO] [stdout]   13:     0x5637868a2f96 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
[INFO] [stdout]   14:     0x5637868a3e92 - rust_begin_unwind
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
[INFO] [stdout]   15:     0x56378687b365 - core::panicking::panic_fmt::hbf0e066aabfa482c
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
[INFO] [stdout]   16:     0x56378687b7c3 - core::result::unwrap_failed::hddb4fea594200c52
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
[INFO] [stdout]   17:     0x56378687e6e3 - core::result::Result<T,E>::expect::h8aa24a497a63022f
[INFO] [stdout]   18:     0x56378687d0da - yok::Dir::extract::h5481fc7038a67a5f
[INFO] [stdout]   19:     0x56378687f447 - rust_out::main::_doctest_main_src_lib_rs_10_0::h6e8a68f8f3a8e4f3
[INFO] [stdout]   20:     0x56378687f366 - rust_out::main::hc20c0d07e2402830
[INFO] [stdout]   21:     0x56378687de13 - core::ops::function::FnOnce::call_once::hbc459743598298c4
[INFO] [stdout]   22:     0x56378687be96 - std::sys_common::backtrace::__rust_begin_short_backtrace::h62debe7d3058b76a
[INFO] [stdout]   23:     0x56378687cef9 - std::rt::lang_start::{{closure}}::h8f486f3e1e6418b2
[INFO] [stdout]   24:     0x56378689d9d7 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hd95060ecd5e1ca24
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
[INFO] [stdout]   25:     0x56378689d9d7 - std::panicking::try::do_call::h6e8cf51db32a6e4b
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
[INFO] [stdout]   26:     0x56378689d9d7 - std::panicking::try::h3a52eefe24fe3c29
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
[INFO] [stdout]   27:     0x56378689d9d7 - std::panic::catch_unwind::h24c28c23c02c3841
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
[INFO] [stdout]   28:     0x56378689d9d7 - std::rt::lang_start_internal::{{closure}}::h705d3c9cbc06ef47
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
[INFO] [stdout]   29:     0x56378689d9d7 - std::panicking::try::do_call::ha21f52ba13158470
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
[INFO] [stdout]   30:     0x56378689d9d7 - std::panicking::try::h5581346bf6aeb1f8
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
[INFO] [stdout]   31:     0x56378689d9d7 - std::panic::catch_unwind::h7919645a6b72e25b
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
[INFO] [stdout]   32:     0x56378689d9d7 - std::rt::lang_start_internal::h12de51168669836e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
[INFO] [stdout]   33:     0x56378687ced7 - std::rt::lang_start::h2c48f91a7bf85629
[INFO] [stdout]   34:     0x56378687f675 - main
[INFO] [stdout]   35:     0x7fb3cf3c7d90 - <unknown>
[INFO] [stdout]   36:     0x7fb3cf3c7e40 - __libc_start_main
[INFO] [stdout]   37:     0x56378687ba85 - _start
[INFO] [stdout]   38:                0x0 - <unknown>
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] ---- src/lib.rs - include_dir (line 282) stdout ----
[INFO] [stdout] Test executable failed (exit status: 101).
[INFO] [stdout] 
[INFO] [stdout] stdout:
[INFO] [stdout] use std::{mem, path::PathBuf, str::FromStr};
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct DirEntry {
[INFO] [stdout]     pub path: String,
[INFO] [stdout]     pub is_dir: bool,
[INFO] [stdout]     pub is_file: bool,
[INFO] [stdout]     pub contents: Vec<u8>,
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct Dir {
[INFO] [stdout]     pub data: Vec<DirEntry>,
[INFO] [stdout] }
[INFO] [stdout] pub trait Bytes {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn from_bytes(&self) -> Dir;
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn into_dir(&self) -> Dir;
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for [u8] {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for Dir {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement as_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         // Calculate the total size of the serialized data
[INFO] [stdout]         let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]             size += entry.path.as_bytes().len();
[INFO] [stdout]             size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]             size += entry.contents.len();
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]         // Write the length prefix
[INFO] [stdout]         bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             // Write the size prefix for this entry
[INFO] [stdout]             bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             // Write the entry data
[INFO] [stdout]             bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]             bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]             bytes.extend((entry.contents.len() as u32).to_le_bytes().iter());
[INFO] [stdout]             bytes.extend(entry.contents.iter());
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         bytes
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement from_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]         let mut cursor = 0;
[INFO] [stdout]         let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]         if bytes.len() < len_prefix_size {
[INFO] [stdout]             return None;
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let len = u32::from_le_bytes([
[INFO] [stdout]             bytes[cursor],
[INFO] [stdout]             bytes[cursor + 1],
[INFO] [stdout]             bytes[cursor + 2],
[INFO] [stdout]             bytes[cursor + 3],
[INFO] [stdout]         ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]         cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]         let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]         for _ in 0..len {
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let entry_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < end_pos {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]             cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + 2 {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let is_dir = bytes[cursor] != 0;
[INFO] [stdout]             let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]             cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let content_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + content_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let contents = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]             cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]             data.push(DirEntry {
[INFO] [stdout]                 path,
[INFO] [stdout]                 is_dir,
[INFO] [stdout]                 is_file,
[INFO] [stdout]                 contents,
[INFO] [stdout]             });
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         Some(Dir { data })
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] fn get_new_path(path: &str) -> String {
[INFO] [stdout]     let yok_path = match std::env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     let path = path.to_string().replace("\\", "/").to_string();
[INFO] [stdout]     if yok_path != "."{
[INFO] [stdout]         return path;
[INFO] [stdout]     }else {
[INFO] [stdout]         return path;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] 
[INFO] [stdout] impl Dir {
[INFO] [stdout]     /// include dir at compile time
[INFO] [stdout]     /// in default die path is current dir
[INFO] [stdout]     ///
[INFO] [stdout]     /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout]     ///
[INFO] [stdout]     /// you can also set YOK_PATH env before cargo run
[INFO] [stdout]     ///
[INFO] [stdout]     /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout]     /// ```rust
[INFO] [stdout]     ///   use yok::include_dir;
[INFO] [stdout]     ///   use yok::Dir;
[INFO] [stdout]     ///   use yok::DirEntry;
[INFO] [stdout]     ///   use yok::Bytes;
[INFO] [stdout]     ///   const DATA:&[u8] = include_dir();
[INFO] [stdout]     ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout]     ///   for entry in &dir.data{
[INFO] [stdout]     ///       if entry.is_file{
[INFO] [stdout]     ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]     ///       }else if entry.is_dir {
[INFO] [stdout]     ///           println!("{}",entry.path);
[INFO] [stdout]     ///       }
[INFO] [stdout]     ///   }
[INFO] [stdout]     ///   dir.extract("./demo");
[INFO] [stdout]     /// ```
[INFO] [stdout]     ///
[INFO] [stdout]     pub fn extract(&self, base_dir: impl ToString) ->std::io::Result<()>{
[INFO] [stdout]         std::fs::create_dir_all(base_dir.to_string()).expect("create to dir error");
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_dir {
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 std::fs::create_dir_all(path.clone()).expect("create to dir error");
[INFO] [stdout]                 if cfg!(target_os = "windows") {
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }else{
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_file {
[INFO] [stdout]                 use std::fs::{self, File, OpenOptions};
[INFO] [stdout]                 use std::io::prelude::*;
[INFO] [stdout]                 use std::os::unix::fs::OpenOptionsExt;
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 if !path.exists(){
[INFO] [stdout]                     let mut open_options = OpenOptions::new();
[INFO] [stdout]                     open_options.mode(0o777); // Set read/write permission for owner, read-only for others
[INFO] [stdout]                     let file = open_options.create(true).write(true).open(path).unwrap();
[INFO] [stdout]                     let mut file_writer = std::io::BufWriter::new(file);
[INFO] [stdout]                     file_writer.write_all(&entry.contents).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(())
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] pub const fn include_dir() -> &'static [u8] {
[INFO] [stdout]     include_bytes!("../../.yok")
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::include_dir;
[INFO] [stdout]     use yok::Bytes;
[INFO] [stdout]     use yok::Dir;
[INFO] [stdout]     use yok::DirEntry;
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             // println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             // println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] 
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] src
[INFO] [stdout] use std::{
[INFO] [stdout]     fs, io,
[INFO] [stdout]     path::{Path, PathBuf},
[INFO] [stdout] };
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     use std::mem;
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct DirEntry {
[INFO] [stdout]         path: String,
[INFO] [stdout]         is_dir: bool,
[INFO] [stdout]         is_file: bool,
[INFO] [stdout]         content: Vec<u8>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct Dir {
[INFO] [stdout]         data: Vec<DirEntry>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement as_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]             // Calculate the total size of the serialized data
[INFO] [stdout]             let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]                 size += entry.path.as_bytes().len();
[INFO] [stdout]                 size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]                 size += entry.content.len();
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]             // Write the length prefix
[INFO] [stdout]             bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 // Write the size prefix for this entry
[INFO] [stdout]                 bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]                 // Write the entry data
[INFO] [stdout]                 bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]                 bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]                 bytes.extend((entry.content.len() as u32).to_le_bytes().iter());
[INFO] [stdout]                 bytes.extend(entry.content.iter());
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             bytes
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement from_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         #[allow(warnings)]
[INFO] [stdout]         pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]             let mut cursor = 0;
[INFO] [stdout]             let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let len = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]             for _ in 0..len {
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let entry_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < end_pos {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]                 cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + 2 {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let is_dir = bytes[cursor] != 0;
[INFO] [stdout]                 let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]                 cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + content_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]                 cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]                 data.push(DirEntry {
[INFO] [stdout]                     path,
[INFO] [stdout]                     is_dir,
[INFO] [stdout]                     is_file,
[INFO] [stdout]                     content,
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             Some(Dir { data })
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     pub fn walk_dir(path: impl ToString) -> io::Result<Vec<PathBuf>> {
[INFO] [stdout]         let path = path.to_string();
[INFO] [stdout]         let dir = Path::new(&path);
[INFO] [stdout]         let mut files = Vec::new();
[INFO] [stdout]         for entry in fs::read_dir(dir)? {
[INFO] [stdout]             let entry = entry?;
[INFO] [stdout]             let newpath = entry.path();
[INFO] [stdout] 
[INFO] [stdout]             if newpath.is_dir() {
[INFO] [stdout]                 files.extend(walk_dir(&newpath.display())?);
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             } else {
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(files)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     use std::env;
[INFO] [stdout]     let yok_path = match env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     println!("cargo:rerun-if-env-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed=main.rs");
[INFO] [stdout]     println!("cargo:rerun-if-changed=lib.rs");
[INFO] [stdout]     let yok_path = std::path::Path::new(&yok_path);
[INFO] [stdout]     if yok_path.is_dir() {
[INFO] [stdout]         let mut res_dir: Vec<DirEntry> = vec![];
[INFO] [stdout]         let dir_list = walk_dir(yok_path.display()).expect("walk dir error");
[INFO] [stdout]         for dir in dir_list {
[INFO] [stdout]             if dir.is_file() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: false,
[INFO] [stdout]                     is_file: true,
[INFO] [stdout]                     content: std::fs::read(dir).expect("read dir error"),
[INFO] [stdout]                 });
[INFO] [stdout]             } else if dir.is_dir() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: true,
[INFO] [stdout]                     is_file: false,
[INFO] [stdout]                     content: vec![],
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         let all_dir: Dir = Dir { data: res_dir };
[INFO] [stdout]         let all_dir_bytes = all_dir.as_bytes();
[INFO] [stdout]         if let Ok(_) = std::fs::write(format!("../.yok"), all_dir_bytes){}
[INFO] [stdout]     } else {
[INFO] [stdout]         eprintln!("Environment variable 'YOK_PATH' not dir");
[INFO] [stdout]         return;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] categories = ["development-tools", "game-engines", "web-programming"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] keywords = ["include", "dir", "compile-time"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] name = "yok"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] rm -rf path
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] # yok
[INFO] [stdout] 
[INFO] [stdout] [![Crates.io](https://img.shields.io/crates/v/yok.svg)](https://crates.io/crates/yok)
[INFO] [stdout] [![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://gitlab.com/andrew_ryan/yok)
[INFO] [stdout] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/andrew_ryan/yok/-/raw/master/LICENSE)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] A crate for Embed the contents of a directory in your binary at compile time.
[INFO] [stdout] 
[INFO] [stdout] ## Getting Started
[INFO] [stdout] ```sh
[INFO] [stdout] cargo add yok
[INFO] [stdout] ```
[INFO] [stdout] ```rust
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::{Dir, Bytes,include_dir};
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] }
[INFO] [stdout] ```
[INFO] [stdout] ## Set YOK_PATH env and run or default path is cuttent dir
[INFO] [stdout] ```sh
[INFO] [stdout] # linux,macos
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] # windows cmd
[INFO] [stdout] set YOK_PATH="C:\path\to\your\directory"
[INFO] [stdout] # windows powershell
[INFO] [stdout] $env:YOK_PATH = "C:\path\to\your\directory"
[INFO] [stdout] 
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] ```
[INFO] [stdout] MIT License
[INFO] [stdout] 
[INFO] [stdout] Copyright (c) [year] [fullname]
[INFO] [stdout] 
[INFO] [stdout] Permission is hereby granted, free of charge, to any person obtaining a copy
[INFO] [stdout] of this software and associated documentation files (the "Software"), to deal
[INFO] [stdout] in the Software without restriction, including without limitation the rights
[INFO] [stdout] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[INFO] [stdout] copies of the Software, and to permit persons to whom the Software is
[INFO] [stdout] furnished to do so, subject to the following conditions:
[INFO] [stdout] 
[INFO] [stdout] The above copyright notice and this permission notice shall be included in all
[INFO] [stdout] copies or substantial portions of the Software.
[INFO] [stdout] 
[INFO] [stdout] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[INFO] [stdout] IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[INFO] [stdout] FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[INFO] [stdout] AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[INFO] [stdout] LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[INFO] [stdout] OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
[INFO] [stdout] SOFTWARE.
[INFO] [stdout] # This file is automatically @generated by Cargo.
[INFO] [stdout] # It is not intended for manual editing.
[INFO] [stdout] version = 3
[INFO] [stdout] 
[INFO] [stdout] [[package]]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] 
[INFO] [stdout] image: rustlang/rust:nightly
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] push:cargo:
[INFO] [stdout]   script:
[INFO] [stdout]     - rustc --version && cargo --version  
[INFO] [stdout]     - cargo publish --allow-dirty --token cioHYTp8cpgbRbBqcJvqGF7rUIjJQSlBvH3
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] keywords = ["include","dir","compile-time"]
[INFO] [stdout] categories = ["development-tools","game-engines","web-programming"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] use std::fs::File;
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] use std::io::{BufWriter, Write};
[INFO] [stdout] use std::path::Path;
[INFO] [stdout] use zip::write::FileOptions;
[INFO] [stdout] use zip::ZipWriter;
[INFO] [stdout] use std::io::Read;
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     // Path to the directory to compress
[INFO] [stdout]     let dir_path = Path::new(".");
[INFO] [stdout] 
[INFO] [stdout]     // Path to the output ZIP file
[INFO] [stdout]     let zip_path = Path::new("app.zip");
[INFO] [stdout] 
[INFO] [stdout]     // Create a new ZIP file
[INFO] [stdout]     let file = File::create(&zip_path).unwrap();
[INFO] [stdout]     let writer = BufWriter::new(file);
[INFO] [stdout]     let mut zip = ZipWriter::new(writer);
[INFO] [stdout] 
[INFO] [stdout]     // Recursively add all files and directories in the input directory to the ZIP file
[INFO] [stdout]     add_directory_to_zip(&mut zip, dir_path, "").unwrap();
[INFO] [stdout] 
[INFO] [stdout]     // Finalize the ZIP file
[INFO] [stdout]     zip.finish().unwrap();
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Recursively adds a directory (and all its contents) to a ZipWriter
[INFO] [stdout] fn add_directory_to_zip(zip: &mut ZipWriter<BufWriter<File>>, dir_path: &Path, base_path: &str) -> zip::result::ZipResult<()> {
[INFO] [stdout]     for entry in dir_path.read_dir()? {
[INFO] [stdout]         let path = entry?.path();
[INFO] [stdout] 
[INFO] [stdout]         if path.is_dir() {
[INFO] [stdout]             // Recursively add the subdirectory
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let new_base_path = format!("{}/{}", base_path, name);
[INFO] [stdout]             add_directory_to_zip(zip, &path, &new_base_path)?;
[INFO] [stdout]         } else {
[INFO] [stdout]             // Add the file to the ZIP archive
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let options = FileOptions::default()
[INFO] [stdout]                 .compression_method(zip::CompressionMethod::Deflated)
[INFO] [stdout]                 .unix_permissions(0o755); // Set appropriate permissions for the file
[INFO] [stdout]             zip.start_file(format!("{}/{}", base_path, name), options)?;
[INFO] [stdout]             let mut file = File::open(&path)?;
[INFO] [stdout]             let mut buffer = Vec::new();
[INFO] [stdout]             file.read_to_end(&mut buffer)?;
[INFO] [stdout]             zip.write_all(&buffer)?;
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     Ok(())
[INFO] [stdout] }
[INFO] [stdout] /target
[INFO] [stdout] Cargo.lock
[INFO] [stdout] .DS_Store
[INFO] [stdout] 
[INFO] [stdout] stderr:
[INFO] [stdout] thread 'main' panicked at /opt/rustwide/workdir/src/lib.rs:236:55:
[INFO] [stdout] create to dir error: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }
[INFO] [stdout] stack backtrace:
[INFO] [stdout]    0:     0x557317d92acc - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
[INFO] [stdout]    1:     0x557317d92acc - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[INFO] [stdout]    2:     0x557317d92acc - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
[INFO] [stdout]    3:     0x557317d92acc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
[INFO] [stdout]    4:     0x557317db2670 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
[INFO] [stdout]    5:     0x557317db2670 - core::fmt::write::h3a39390d8560d9c9
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
[INFO] [stdout]    6:     0x557317d90d4f - std::io::Write::write_fmt::h5fc9997dfe05f882
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
[INFO] [stdout]    7:     0x557317d928b4 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
[INFO] [stdout]    8:     0x557317d928b4 - std::sys_common::backtrace::print::h23a2d212c6fff936
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
[INFO] [stdout]    9:     0x557317d93dc7 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
[INFO] [stdout]   10:     0x557317d93b2f - std::panicking::default_hook::h6038f2eba384e475
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
[INFO] [stdout]   11:     0x557317d94248 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
[INFO] [stdout]   12:     0x557317d9412e - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
[INFO] [stdout]   13:     0x557317d92f96 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
[INFO] [stdout]   14:     0x557317d93e92 - rust_begin_unwind
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
[INFO] [stdout]   15:     0x557317d6b365 - core::panicking::panic_fmt::hbf0e066aabfa482c
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
[INFO] [stdout]   16:     0x557317d6b7c3 - core::result::unwrap_failed::hddb4fea594200c52
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
[INFO] [stdout]   17:     0x557317d6e6e3 - core::result::Result<T,E>::expect::h8aa24a497a63022f
[INFO] [stdout]   18:     0x557317d6d0da - yok::Dir::extract::h5481fc7038a67a5f
[INFO] [stdout]   19:     0x557317d6f447 - rust_out::main::_doctest_main_src_lib_rs_282_0::hd07685a87e1ed4d5
[INFO] [stdout]   20:     0x557317d6f366 - rust_out::main::hc20c0d07e2402830
[INFO] [stdout]   21:     0x557317d6de13 - core::ops::function::FnOnce::call_once::hbc459743598298c4
[INFO] [stdout]   22:     0x557317d6be96 - std::sys_common::backtrace::__rust_begin_short_backtrace::h62debe7d3058b76a
[INFO] [stdout]   23:     0x557317d6cef9 - std::rt::lang_start::{{closure}}::h8f486f3e1e6418b2
[INFO] [stdout]   24:     0x557317d8d9d7 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hd95060ecd5e1ca24
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
[INFO] [stdout]   25:     0x557317d8d9d7 - std::panicking::try::do_call::h6e8cf51db32a6e4b
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
[INFO] [stdout]   26:     0x557317d8d9d7 - std::panicking::try::h3a52eefe24fe3c29
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
[INFO] [stdout]   27:     0x557317d8d9d7 - std::panic::catch_unwind::h24c28c23c02c3841
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
[INFO] [stdout]   28:     0x557317d8d9d7 - std::rt::lang_start_internal::{{closure}}::h705d3c9cbc06ef47
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
[INFO] [stdout]   29:     0x557317d8d9d7 - std::panicking::try::do_call::ha21f52ba13158470
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
[INFO] [stdout]   30:     0x557317d8d9d7 - std::panicking::try::h5581346bf6aeb1f8
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
[INFO] [stdout]   31:     0x557317d8d9d7 - std::panic::catch_unwind::h7919645a6b72e25b
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
[INFO] [stdout]   32:     0x557317d8d9d7 - std::rt::lang_start_internal::h12de51168669836e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
[INFO] [stdout]   33:     0x557317d6ced7 - std::rt::lang_start::h2c48f91a7bf85629
[INFO] [stdout]   34:     0x557317d6f675 - main
[INFO] [stdout]   35:     0x7fbf9c1e0d90 - <unknown>
[INFO] [stdout]   36:     0x7fbf9c1e0e40 - __libc_start_main
[INFO] [stdout]   37:     0x557317d6ba85 - _start
[INFO] [stdout]   38:                0x0 - <unknown>
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] ---- src/lib.rs - Dir::extract (line 218) stdout ----
[INFO] [stdout] Test executable failed (exit status: 101).
[INFO] [stdout] 
[INFO] [stdout] stdout:
[INFO] [stdout] use std::{mem, path::PathBuf, str::FromStr};
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct DirEntry {
[INFO] [stdout]     pub path: String,
[INFO] [stdout]     pub is_dir: bool,
[INFO] [stdout]     pub is_file: bool,
[INFO] [stdout]     pub contents: Vec<u8>,
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct Dir {
[INFO] [stdout]     pub data: Vec<DirEntry>,
[INFO] [stdout] }
[INFO] [stdout] pub trait Bytes {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn from_bytes(&self) -> Dir;
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn into_dir(&self) -> Dir;
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for [u8] {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for Dir {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement as_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         // Calculate the total size of the serialized data
[INFO] [stdout]         let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]             size += entry.path.as_bytes().len();
[INFO] [stdout]             size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]             size += entry.contents.len();
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]         // Write the length prefix
[INFO] [stdout]         bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             // Write the size prefix for this entry
[INFO] [stdout]             bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             // Write the entry data
[INFO] [stdout]             bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]             bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]             bytes.extend((entry.contents.len() as u32).to_le_bytes().iter());
[INFO] [stdout]             bytes.extend(entry.contents.iter());
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         bytes
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement from_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]         let mut cursor = 0;
[INFO] [stdout]         let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]         if bytes.len() < len_prefix_size {
[INFO] [stdout]             return None;
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let len = u32::from_le_bytes([
[INFO] [stdout]             bytes[cursor],
[INFO] [stdout]             bytes[cursor + 1],
[INFO] [stdout]             bytes[cursor + 2],
[INFO] [stdout]             bytes[cursor + 3],
[INFO] [stdout]         ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]         cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]         let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]         for _ in 0..len {
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let entry_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < end_pos {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]             cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + 2 {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let is_dir = bytes[cursor] != 0;
[INFO] [stdout]             let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]             cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let content_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + content_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let contents = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]             cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]             data.push(DirEntry {
[INFO] [stdout]                 path,
[INFO] [stdout]                 is_dir,
[INFO] [stdout]                 is_file,
[INFO] [stdout]                 contents,
[INFO] [stdout]             });
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         Some(Dir { data })
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] fn get_new_path(path: &str) -> String {
[INFO] [stdout]     let yok_path = match std::env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     let path = path.to_string().replace("\\", "/").to_string();
[INFO] [stdout]     if yok_path != "."{
[INFO] [stdout]         return path;
[INFO] [stdout]     }else {
[INFO] [stdout]         return path;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] 
[INFO] [stdout] impl Dir {
[INFO] [stdout]     /// include dir at compile time
[INFO] [stdout]     /// in default die path is current dir
[INFO] [stdout]     ///
[INFO] [stdout]     /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout]     ///
[INFO] [stdout]     /// you can also set YOK_PATH env before cargo run
[INFO] [stdout]     ///
[INFO] [stdout]     /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout]     /// ```rust
[INFO] [stdout]     ///   use yok::include_dir;
[INFO] [stdout]     ///   use yok::Dir;
[INFO] [stdout]     ///   use yok::DirEntry;
[INFO] [stdout]     ///   use yok::Bytes;
[INFO] [stdout]     ///   const DATA:&[u8] = include_dir();
[INFO] [stdout]     ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout]     ///   for entry in &dir.data{
[INFO] [stdout]     ///       if entry.is_file{
[INFO] [stdout]     ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]     ///       }else if entry.is_dir {
[INFO] [stdout]     ///           println!("{}",entry.path);
[INFO] [stdout]     ///       }
[INFO] [stdout]     ///   }
[INFO] [stdout]     ///   dir.extract("./demo");
[INFO] [stdout]     /// ```
[INFO] [stdout]     ///
[INFO] [stdout]     pub fn extract(&self, base_dir: impl ToString) ->std::io::Result<()>{
[INFO] [stdout]         std::fs::create_dir_all(base_dir.to_string()).expect("create to dir error");
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_dir {
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 std::fs::create_dir_all(path.clone()).expect("create to dir error");
[INFO] [stdout]                 if cfg!(target_os = "windows") {
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }else{
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_file {
[INFO] [stdout]                 use std::fs::{self, File, OpenOptions};
[INFO] [stdout]                 use std::io::prelude::*;
[INFO] [stdout]                 use std::os::unix::fs::OpenOptionsExt;
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 if !path.exists(){
[INFO] [stdout]                     let mut open_options = OpenOptions::new();
[INFO] [stdout]                     open_options.mode(0o777); // Set read/write permission for owner, read-only for others
[INFO] [stdout]                     let file = open_options.create(true).write(true).open(path).unwrap();
[INFO] [stdout]                     let mut file_writer = std::io::BufWriter::new(file);
[INFO] [stdout]                     file_writer.write_all(&entry.contents).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(())
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] pub const fn include_dir() -> &'static [u8] {
[INFO] [stdout]     include_bytes!("../../.yok")
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::include_dir;
[INFO] [stdout]     use yok::Bytes;
[INFO] [stdout]     use yok::Dir;
[INFO] [stdout]     use yok::DirEntry;
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             // println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             // println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] 
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] src
[INFO] [stdout] use std::{
[INFO] [stdout]     fs, io,
[INFO] [stdout]     path::{Path, PathBuf},
[INFO] [stdout] };
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     use std::mem;
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct DirEntry {
[INFO] [stdout]         path: String,
[INFO] [stdout]         is_dir: bool,
[INFO] [stdout]         is_file: bool,
[INFO] [stdout]         content: Vec<u8>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct Dir {
[INFO] [stdout]         data: Vec<DirEntry>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement as_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]             // Calculate the total size of the serialized data
[INFO] [stdout]             let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]                 size += entry.path.as_bytes().len();
[INFO] [stdout]                 size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]                 size += entry.content.len();
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]             // Write the length prefix
[INFO] [stdout]             bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 // Write the size prefix for this entry
[INFO] [stdout]                 bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]                 // Write the entry data
[INFO] [stdout]                 bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]                 bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]                 bytes.extend((entry.content.len() as u32).to_le_bytes().iter());
[INFO] [stdout]                 bytes.extend(entry.content.iter());
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             bytes
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement from_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         #[allow(warnings)]
[INFO] [stdout]         pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]             let mut cursor = 0;
[INFO] [stdout]             let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let len = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]             for _ in 0..len {
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let entry_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < end_pos {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]                 cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + 2 {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let is_dir = bytes[cursor] != 0;
[INFO] [stdout]                 let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]                 cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + content_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]                 cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]                 data.push(DirEntry {
[INFO] [stdout]                     path,
[INFO] [stdout]                     is_dir,
[INFO] [stdout]                     is_file,
[INFO] [stdout]                     content,
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             Some(Dir { data })
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     pub fn walk_dir(path: impl ToString) -> io::Result<Vec<PathBuf>> {
[INFO] [stdout]         let path = path.to_string();
[INFO] [stdout]         let dir = Path::new(&path);
[INFO] [stdout]         let mut files = Vec::new();
[INFO] [stdout]         for entry in fs::read_dir(dir)? {
[INFO] [stdout]             let entry = entry?;
[INFO] [stdout]             let newpath = entry.path();
[INFO] [stdout] 
[INFO] [stdout]             if newpath.is_dir() {
[INFO] [stdout]                 files.extend(walk_dir(&newpath.display())?);
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             } else {
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(files)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     use std::env;
[INFO] [stdout]     let yok_path = match env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     println!("cargo:rerun-if-env-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed=main.rs");
[INFO] [stdout]     println!("cargo:rerun-if-changed=lib.rs");
[INFO] [stdout]     let yok_path = std::path::Path::new(&yok_path);
[INFO] [stdout]     if yok_path.is_dir() {
[INFO] [stdout]         let mut res_dir: Vec<DirEntry> = vec![];
[INFO] [stdout]         let dir_list = walk_dir(yok_path.display()).expect("walk dir error");
[INFO] [stdout]         for dir in dir_list {
[INFO] [stdout]             if dir.is_file() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: false,
[INFO] [stdout]                     is_file: true,
[INFO] [stdout]                     content: std::fs::read(dir).expect("read dir error"),
[INFO] [stdout]                 });
[INFO] [stdout]             } else if dir.is_dir() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: true,
[INFO] [stdout]                     is_file: false,
[INFO] [stdout]                     content: vec![],
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         let all_dir: Dir = Dir { data: res_dir };
[INFO] [stdout]         let all_dir_bytes = all_dir.as_bytes();
[INFO] [stdout]         if let Ok(_) = std::fs::write(format!("../.yok"), all_dir_bytes){}
[INFO] [stdout]     } else {
[INFO] [stdout]         eprintln!("Environment variable 'YOK_PATH' not dir");
[INFO] [stdout]         return;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] categories = ["development-tools", "game-engines", "web-programming"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] keywords = ["include", "dir", "compile-time"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] name = "yok"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] rm -rf path
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] # yok
[INFO] [stdout] 
[INFO] [stdout] [![Crates.io](https://img.shields.io/crates/v/yok.svg)](https://crates.io/crates/yok)
[INFO] [stdout] [![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://gitlab.com/andrew_ryan/yok)
[INFO] [stdout] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/andrew_ryan/yok/-/raw/master/LICENSE)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] A crate for Embed the contents of a directory in your binary at compile time.
[INFO] [stdout] 
[INFO] [stdout] ## Getting Started
[INFO] [stdout] ```sh
[INFO] [stdout] cargo add yok
[INFO] [stdout] ```
[INFO] [stdout] ```rust
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::{Dir, Bytes,include_dir};
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] }
[INFO] [stdout] ```
[INFO] [stdout] ## Set YOK_PATH env and run or default path is cuttent dir
[INFO] [stdout] ```sh
[INFO] [stdout] # linux,macos
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] # windows cmd
[INFO] [stdout] set YOK_PATH="C:\path\to\your\directory"
[INFO] [stdout] # windows powershell
[INFO] [stdout] $env:YOK_PATH = "C:\path\to\your\directory"
[INFO] [stdout] 
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] ```
[INFO] [stdout] MIT License
[INFO] [stdout] 
[INFO] [stdout] Copyright (c) [year] [fullname]
[INFO] [stdout] 
[INFO] [stdout] Permission is hereby granted, free of charge, to any person obtaining a copy
[INFO] [stdout] of this software and associated documentation files (the "Software"), to deal
[INFO] [stdout] in the Software without restriction, including without limitation the rights
[INFO] [stdout] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[INFO] [stdout] copies of the Software, and to permit persons to whom the Software is
[INFO] [stdout] furnished to do so, subject to the following conditions:
[INFO] [stdout] 
[INFO] [stdout] The above copyright notice and this permission notice shall be included in all
[INFO] [stdout] copies or substantial portions of the Software.
[INFO] [stdout] 
[INFO] [stdout] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[INFO] [stdout] IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[INFO] [stdout] FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[INFO] [stdout] AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[INFO] [stdout] LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[INFO] [stdout] OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
[INFO] [stdout] SOFTWARE.
[INFO] [stdout] # This file is automatically @generated by Cargo.
[INFO] [stdout] # It is not intended for manual editing.
[INFO] [stdout] version = 3
[INFO] [stdout] 
[INFO] [stdout] [[package]]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] 
[INFO] [stdout] image: rustlang/rust:nightly
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] push:cargo:
[INFO] [stdout]   script:
[INFO] [stdout]     - rustc --version && cargo --version  
[INFO] [stdout]     - cargo publish --allow-dirty --token cioHYTp8cpgbRbBqcJvqGF7rUIjJQSlBvH3
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] keywords = ["include","dir","compile-time"]
[INFO] [stdout] categories = ["development-tools","game-engines","web-programming"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] use std::fs::File;
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] use std::io::{BufWriter, Write};
[INFO] [stdout] use std::path::Path;
[INFO] [stdout] use zip::write::FileOptions;
[INFO] [stderr] error: doctest failed, to rerun pass `--doc`
[INFO] [stdout] use zip::ZipWriter;
[INFO] [stdout] use std::io::Read;
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     // Path to the directory to compress
[INFO] [stdout]     let dir_path = Path::new(".");
[INFO] [stdout] 
[INFO] [stdout]     // Path to the output ZIP file
[INFO] [stdout]     let zip_path = Path::new("app.zip");
[INFO] [stdout] 
[INFO] [stdout]     // Create a new ZIP file
[INFO] [stdout]     let file = File::create(&zip_path).unwrap();
[INFO] [stdout]     let writer = BufWriter::new(file);
[INFO] [stdout]     let mut zip = ZipWriter::new(writer);
[INFO] [stdout] 
[INFO] [stdout]     // Recursively add all files and directories in the input directory to the ZIP file
[INFO] [stdout]     add_directory_to_zip(&mut zip, dir_path, "").unwrap();
[INFO] [stdout] 
[INFO] [stdout]     // Finalize the ZIP file
[INFO] [stdout]     zip.finish().unwrap();
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Recursively adds a directory (and all its contents) to a ZipWriter
[INFO] [stdout] fn add_directory_to_zip(zip: &mut ZipWriter<BufWriter<File>>, dir_path: &Path, base_path: &str) -> zip::result::ZipResult<()> {
[INFO] [stdout]     for entry in dir_path.read_dir()? {
[INFO] [stdout]         let path = entry?.path();
[INFO] [stdout] 
[INFO] [stdout]         if path.is_dir() {
[INFO] [stdout]             // Recursively add the subdirectory
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let new_base_path = format!("{}/{}", base_path, name);
[INFO] [stdout]             add_directory_to_zip(zip, &path, &new_base_path)?;
[INFO] [stdout]         } else {
[INFO] [stdout]             // Add the file to the ZIP archive
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let options = FileOptions::default()
[INFO] [stdout]                 .compression_method(zip::CompressionMethod::Deflated)
[INFO] [stdout]                 .unix_permissions(0o755); // Set appropriate permissions for the file
[INFO] [stdout]             zip.start_file(format!("{}/{}", base_path, name), options)?;
[INFO] [stdout]             let mut file = File::open(&path)?;
[INFO] [stdout]             let mut buffer = Vec::new();
[INFO] [stdout]             file.read_to_end(&mut buffer)?;
[INFO] [stdout]             zip.write_all(&buffer)?;
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     Ok(())
[INFO] [stdout] }
[INFO] [stdout] /target
[INFO] [stdout] Cargo.lock
[INFO] [stdout] .DS_Store
[INFO] [stdout] 
[INFO] [stdout] stderr:
[INFO] [stdout] thread 'main' panicked at /opt/rustwide/workdir/src/lib.rs:236:55:
[INFO] [stdout] create to dir error: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }
[INFO] [stdout] stack backtrace:
[INFO] [stdout]    0:     0x561cac282acc - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
[INFO] [stdout]    1:     0x561cac282acc - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[INFO] [stdout]    2:     0x561cac282acc - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
[INFO] [stdout]    3:     0x561cac282acc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
[INFO] [stdout]    4:     0x561cac2a2670 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
[INFO] [stdout]    5:     0x561cac2a2670 - core::fmt::write::h3a39390d8560d9c9
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
[INFO] [stdout]    6:     0x561cac280d4f - std::io::Write::write_fmt::h5fc9997dfe05f882
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
[INFO] [stdout]    7:     0x561cac2828b4 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
[INFO] [stdout]    8:     0x561cac2828b4 - std::sys_common::backtrace::print::h23a2d212c6fff936
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
[INFO] [stdout]    9:     0x561cac283dc7 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
[INFO] [stdout]   10:     0x561cac283b2f - std::panicking::default_hook::h6038f2eba384e475
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
[INFO] [stdout]   11:     0x561cac284248 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
[INFO] [stdout]   12:     0x561cac28412e - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
[INFO] [stdout]   13:     0x561cac282f96 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
[INFO] [stdout]   14:     0x561cac283e92 - rust_begin_unwind
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
[INFO] [stdout]   15:     0x561cac25b365 - core::panicking::panic_fmt::hbf0e066aabfa482c
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
[INFO] [stdout]   16:     0x561cac25b7c3 - core::result::unwrap_failed::hddb4fea594200c52
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
[INFO] [stdout]   17:     0x561cac25e6e3 - core::result::Result<T,E>::expect::h8aa24a497a63022f
[INFO] [stdout]   18:     0x561cac25d0da - yok::Dir::extract::h5481fc7038a67a5f
[INFO] [stdout]   19:     0x561cac25f447 - rust_out::main::_doctest_main_src_lib_rs_218_0::h2c4dd3ed81b5874d
[INFO] [stdout]   20:     0x561cac25f366 - rust_out::main::hc20c0d07e2402830
[INFO] [stdout]   21:     0x561cac25de13 - core::ops::function::FnOnce::call_once::hbc459743598298c4
[INFO] [stdout]   22:     0x561cac25be96 - std::sys_common::backtrace::__rust_begin_short_backtrace::h62debe7d3058b76a
[INFO] [stdout]   23:     0x561cac25cef9 - std::rt::lang_start::{{closure}}::h8f486f3e1e6418b2
[INFO] [stdout]   24:     0x561cac27d9d7 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hd95060ecd5e1ca24
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
[INFO] [stdout]   25:     0x561cac27d9d7 - std::panicking::try::do_call::h6e8cf51db32a6e4b
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
[INFO] [stdout]   26:     0x561cac27d9d7 - std::panicking::try::h3a52eefe24fe3c29
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
[INFO] [stdout]   27:     0x561cac27d9d7 - std::panic::catch_unwind::h24c28c23c02c3841
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
[INFO] [stdout]   28:     0x561cac27d9d7 - std::rt::lang_start_internal::{{closure}}::h705d3c9cbc06ef47
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
[INFO] [stdout]   29:     0x561cac27d9d7 - std::panicking::try::do_call::ha21f52ba13158470
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
[INFO] [stdout]   30:     0x561cac27d9d7 - std::panicking::try::h5581346bf6aeb1f8
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
[INFO] [stdout]   31:     0x561cac27d9d7 - std::panic::catch_unwind::h7919645a6b72e25b
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
[INFO] [stdout]   32:     0x561cac27d9d7 - std::rt::lang_start_internal::h12de51168669836e
[INFO] [stdout]                                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
[INFO] [stdout]   33:     0x561cac25ced7 - std::rt::lang_start::h2c48f91a7bf85629
[INFO] [stdout]   34:     0x561cac25f675 - main
[INFO] [stdout]   35:     0x7fb4178b8d90 - <unknown>
[INFO] [stdout]   36:     0x7fb4178b8e40 - __libc_start_main
[INFO] [stdout]   37:     0x561cac25ba85 - _start
[INFO] [stdout]   38:                0x0 - <unknown>
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] failures:
[INFO] [stdout]     src/lib.rs - Dir::extract (line 218)
[INFO] [stdout]     src/lib.rs - DirEntry (line 10)
[INFO] [stdout]     src/lib.rs - include_dir (line 282)
[INFO] [stdout] 
[INFO] [stdout] test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.44s
[INFO] [stdout] 
[INFO] running `Command { std: "docker" "inspect" "1cc21dcfd01a057855765def32c85c4c8e53cc4757453cd08d6b3fcb783a8f60", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "1cc21dcfd01a057855765def32c85c4c8e53cc4757453cd08d6b3fcb783a8f60", kill_on_drop: false }`
[INFO] [stdout] 1cc21dcfd01a057855765def32c85c4c8e53cc4757453cd08d6b3fcb783a8f60
[INFO] testing yok-0.1.9 against beta-2023-12-22 for beta-1.76-1
[INFO] extracting crate yok 0.1.9 into /workspace/builds/worker-0-tc2/source
[INFO] validating manifest of crates.io crate yok 0.1.9 on toolchain beta-2023-12-22
[INFO] running `Command { std: CARGO_HOME="/workspace/cargo-home" RUSTUP_HOME="/workspace/rustup-home" "/workspace/cargo-home/bin/cargo" "+beta-2023-12-22" "metadata" "--manifest-path" "Cargo.toml" "--no-deps", kill_on_drop: false }`
[INFO] started tweaking crates.io crate yok 0.1.9
[INFO] finished tweaking crates.io crate yok 0.1.9
[INFO] tweaked toml for crates.io crate yok 0.1.9 written to /workspace/builds/worker-0-tc2/source/Cargo.toml
[INFO] crate crates.io crate yok 0.1.9 already has a lockfile, it will not be regenerated
[INFO] running `Command { std: CARGO_HOME="/workspace/cargo-home" RUSTUP_HOME="/workspace/rustup-home" "/workspace/cargo-home/bin/cargo" "+beta-2023-12-22" "fetch" "--manifest-path" "Cargo.toml", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+beta-2023-12-22" "metadata" "--no-deps" "--format-version=1", kill_on_drop: false }`
[INFO] [stdout] da35b95463903880944e3ba41179b3b1ce6844048e14bf891dcff6314a658769
[INFO] running `Command { std: "docker" "start" "-a" "da35b95463903880944e3ba41179b3b1ce6844048e14bf891dcff6314a658769", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "inspect" "da35b95463903880944e3ba41179b3b1ce6844048e14bf891dcff6314a658769", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "da35b95463903880944e3ba41179b3b1ce6844048e14bf891dcff6314a658769", kill_on_drop: false }`
[INFO] [stdout] da35b95463903880944e3ba41179b3b1ce6844048e14bf891dcff6314a658769
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=warn" "-e" "RUSTDOCFLAGS=--cap-lints=warn" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+beta-2023-12-22" "build" "--frozen" "--message-format=json", kill_on_drop: false }`
[INFO] [stdout] 8e7cdaed4a1afe2c5a260416e4a74860cc451bf2016f5ea9e1fdc31bdcca44f6
[INFO] running `Command { std: "docker" "start" "-a" "8e7cdaed4a1afe2c5a260416e4a74860cc451bf2016f5ea9e1fdc31bdcca44f6", kill_on_drop: false }`
[INFO] [stderr]    Compiling yok v0.1.9 (/opt/rustwide/workdir)
[INFO] [stderr]     Finished dev [unoptimized + debuginfo] target(s) in 0.60s
[INFO] running `Command { std: "docker" "inspect" "8e7cdaed4a1afe2c5a260416e4a74860cc451bf2016f5ea9e1fdc31bdcca44f6", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "8e7cdaed4a1afe2c5a260416e4a74860cc451bf2016f5ea9e1fdc31bdcca44f6", kill_on_drop: false }`
[INFO] [stdout] 8e7cdaed4a1afe2c5a260416e4a74860cc451bf2016f5ea9e1fdc31bdcca44f6
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=warn" "-e" "RUSTDOCFLAGS=--cap-lints=warn" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+beta-2023-12-22" "test" "--frozen" "--no-run" "--message-format=json", kill_on_drop: false }`
[INFO] [stdout] 9227bd25aea825d1479ace65ab4f15402e57a481578e9ded45894880051a3cca
[INFO] running `Command { std: "docker" "start" "-a" "9227bd25aea825d1479ace65ab4f15402e57a481578e9ded45894880051a3cca", kill_on_drop: false }`
[INFO] [stderr]    Compiling yok v0.1.9 (/opt/rustwide/workdir)
[INFO] [stderr]     Finished test [unoptimized + debuginfo] target(s) in 0.60s
[INFO] running `Command { std: "docker" "inspect" "9227bd25aea825d1479ace65ab4f15402e57a481578e9ded45894880051a3cca", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "9227bd25aea825d1479ace65ab4f15402e57a481578e9ded45894880051a3cca", kill_on_drop: false }`
[INFO] [stdout] 9227bd25aea825d1479ace65ab4f15402e57a481578e9ded45894880051a3cca
[INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-0-tc2/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=warn" "-e" "RUSTDOCFLAGS=--cap-lints=warn" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:2788e3201cd34a07e3172128adcd8b3090168a8e3bcc40d7c032b9dda1df7d1c" "/opt/rustwide/cargo-home/bin/cargo" "+beta-2023-12-22" "test" "--frozen", kill_on_drop: false }`
[INFO] [stdout] ca295a19a45106cb7f336e577a7a4a5d7f4851e23e76141a0b3b9e2ee564b5bb
[INFO] running `Command { std: "docker" "start" "-a" "ca295a19a45106cb7f336e577a7a4a5d7f4851e23e76141a0b3b9e2ee564b5bb", kill_on_drop: false }`
[INFO] [stderr]    Compiling yok v0.1.9 (/opt/rustwide/workdir)
[INFO] [stderr]     Finished test [unoptimized + debuginfo] target(s) in 0.32s
[INFO] [stderr]      Running unittests src/lib.rs (/opt/rustwide/target/debug/deps/yok-452321e66c05b40f)
[INFO] [stdout] 
[INFO] [stdout] running 0 tests
[INFO] [stdout] 
[INFO] [stdout] test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[INFO] [stdout] 
[INFO] [stderr]      Running unittests src/main.rs (/opt/rustwide/target/debug/deps/yok-d647a73cc58bb9a0)
[INFO] [stdout] 
[INFO] [stdout] running 0 tests
[INFO] [stdout] 
[INFO] [stdout] test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[INFO] [stdout] 
[INFO] [stderr]    Doc-tests yok
[INFO] [stdout] 
[INFO] [stdout] running 3 tests
[INFO] [stdout] test src/lib.rs - Dir::extract (line 218) ... FAILED
[INFO] [stdout] test src/lib.rs - DirEntry (line 10) ... FAILED
[INFO] [stdout] test src/lib.rs - include_dir (line 282) ... FAILED
[INFO] [stdout] 
[INFO] [stdout] failures:
[INFO] [stdout] 
[INFO] [stdout] ---- src/lib.rs - Dir::extract (line 218) stdout ----
[INFO] [stdout] Test executable failed (exit status: 101).
[INFO] [stdout] 
[INFO] [stdout] stdout:
[INFO] [stdout] use std::{mem, path::PathBuf, str::FromStr};
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct DirEntry {
[INFO] [stdout]     pub path: String,
[INFO] [stdout]     pub is_dir: bool,
[INFO] [stdout]     pub is_file: bool,
[INFO] [stdout]     pub contents: Vec<u8>,
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct Dir {
[INFO] [stdout]     pub data: Vec<DirEntry>,
[INFO] [stdout] }
[INFO] [stdout] pub trait Bytes {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn from_bytes(&self) -> Dir;
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn into_dir(&self) -> Dir;
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for [u8] {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for Dir {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement as_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         // Calculate the total size of the serialized data
[INFO] [stdout]         let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]             size += entry.path.as_bytes().len();
[INFO] [stdout]             size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]             size += entry.contents.len();
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]         // Write the length prefix
[INFO] [stdout]         bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             // Write the size prefix for this entry
[INFO] [stdout]             bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             // Write the entry data
[INFO] [stdout]             bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]             bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]             bytes.extend((entry.contents.len() as u32).to_le_bytes().iter());
[INFO] [stdout]             bytes.extend(entry.contents.iter());
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         bytes
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement from_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]         let mut cursor = 0;
[INFO] [stdout]         let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]         if bytes.len() < len_prefix_size {
[INFO] [stdout]             return None;
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let len = u32::from_le_bytes([
[INFO] [stdout]             bytes[cursor],
[INFO] [stdout]             bytes[cursor + 1],
[INFO] [stdout]             bytes[cursor + 2],
[INFO] [stdout]             bytes[cursor + 3],
[INFO] [stdout]         ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]         cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]         let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]         for _ in 0..len {
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let entry_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < end_pos {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]             cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + 2 {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let is_dir = bytes[cursor] != 0;
[INFO] [stdout]             let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]             cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let content_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + content_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let contents = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]             cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]             data.push(DirEntry {
[INFO] [stdout]                 path,
[INFO] [stdout]                 is_dir,
[INFO] [stdout]                 is_file,
[INFO] [stdout]                 contents,
[INFO] [stdout]             });
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         Some(Dir { data })
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] fn get_new_path(path: &str) -> String {
[INFO] [stdout]     let yok_path = match std::env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     let path = path.to_string().replace("\\", "/").to_string();
[INFO] [stdout]     if yok_path != "."{
[INFO] [stdout]         return path;
[INFO] [stdout]     }else {
[INFO] [stdout]         return path;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] 
[INFO] [stdout] impl Dir {
[INFO] [stdout]     /// include dir at compile time
[INFO] [stdout]     /// in default die path is current dir
[INFO] [stdout]     ///
[INFO] [stdout]     /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout]     ///
[INFO] [stdout]     /// you can also set YOK_PATH env before cargo run
[INFO] [stdout]     ///
[INFO] [stdout]     /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout]     /// ```rust
[INFO] [stdout]     ///   use yok::include_dir;
[INFO] [stdout]     ///   use yok::Dir;
[INFO] [stdout]     ///   use yok::DirEntry;
[INFO] [stdout]     ///   use yok::Bytes;
[INFO] [stdout]     ///   const DATA:&[u8] = include_dir();
[INFO] [stdout]     ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout]     ///   for entry in &dir.data{
[INFO] [stdout]     ///       if entry.is_file{
[INFO] [stdout]     ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]     ///       }else if entry.is_dir {
[INFO] [stdout]     ///           println!("{}",entry.path);
[INFO] [stdout]     ///       }
[INFO] [stdout]     ///   }
[INFO] [stdout]     ///   dir.extract("./demo");
[INFO] [stdout]     /// ```
[INFO] [stdout]     ///
[INFO] [stdout]     pub fn extract(&self, base_dir: impl ToString) ->std::io::Result<()>{
[INFO] [stdout]         std::fs::create_dir_all(base_dir.to_string()).expect("create to dir error");
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_dir {
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 std::fs::create_dir_all(path.clone()).expect("create to dir error");
[INFO] [stdout]                 if cfg!(target_os = "windows") {
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }else{
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_file {
[INFO] [stdout]                 use std::fs::{self, File, OpenOptions};
[INFO] [stdout]                 use std::io::prelude::*;
[INFO] [stdout]                 use std::os::unix::fs::OpenOptionsExt;
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 if !path.exists(){
[INFO] [stdout]                     let mut open_options = OpenOptions::new();
[INFO] [stdout]                     open_options.mode(0o777); // Set read/write permission for owner, read-only for others
[INFO] [stdout]                     let file = open_options.create(true).write(true).open(path).unwrap();
[INFO] [stdout]                     let mut file_writer = std::io::BufWriter::new(file);
[INFO] [stdout]                     file_writer.write_all(&entry.contents).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(())
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] pub const fn include_dir() -> &'static [u8] {
[INFO] [stdout]     include_bytes!("../../.yok")
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::include_dir;
[INFO] [stdout]     use yok::Bytes;
[INFO] [stdout]     use yok::Dir;
[INFO] [stdout]     use yok::DirEntry;
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             // println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             // println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] 
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] src
[INFO] [stdout] use std::{
[INFO] [stdout]     fs, io,
[INFO] [stdout]     path::{Path, PathBuf},
[INFO] [stdout] };
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     use std::mem;
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct DirEntry {
[INFO] [stdout]         path: String,
[INFO] [stdout]         is_dir: bool,
[INFO] [stdout]         is_file: bool,
[INFO] [stdout]         content: Vec<u8>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct Dir {
[INFO] [stdout]         data: Vec<DirEntry>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement as_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]             // Calculate the total size of the serialized data
[INFO] [stdout]             let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]                 size += entry.path.as_bytes().len();
[INFO] [stdout]                 size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]                 size += entry.content.len();
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]             // Write the length prefix
[INFO] [stdout]             bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 // Write the size prefix for this entry
[INFO] [stdout]                 bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]                 // Write the entry data
[INFO] [stdout]                 bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]                 bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]                 bytes.extend((entry.content.len() as u32).to_le_bytes().iter());
[INFO] [stdout]                 bytes.extend(entry.content.iter());
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             bytes
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement from_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         #[allow(warnings)]
[INFO] [stdout]         pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]             let mut cursor = 0;
[INFO] [stdout]             let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let len = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]             for _ in 0..len {
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let entry_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < end_pos {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]                 cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + 2 {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let is_dir = bytes[cursor] != 0;
[INFO] [stdout]                 let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]                 cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + content_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]                 cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]                 data.push(DirEntry {
[INFO] [stdout]                     path,
[INFO] [stdout]                     is_dir,
[INFO] [stdout]                     is_file,
[INFO] [stdout]                     content,
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             Some(Dir { data })
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     pub fn walk_dir(path: impl ToString) -> io::Result<Vec<PathBuf>> {
[INFO] [stdout]         let path = path.to_string();
[INFO] [stdout]         let dir = Path::new(&path);
[INFO] [stdout]         let mut files = Vec::new();
[INFO] [stdout]         for entry in fs::read_dir(dir)? {
[INFO] [stdout]             let entry = entry?;
[INFO] [stdout]             let newpath = entry.path();
[INFO] [stdout] 
[INFO] [stdout]             if newpath.is_dir() {
[INFO] [stdout]                 files.extend(walk_dir(&newpath.display())?);
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             } else {
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(files)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     use std::env;
[INFO] [stdout]     let yok_path = match env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     println!("cargo:rerun-if-env-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed=main.rs");
[INFO] [stdout]     println!("cargo:rerun-if-changed=lib.rs");
[INFO] [stdout]     let yok_path = std::path::Path::new(&yok_path);
[INFO] [stdout]     if yok_path.is_dir() {
[INFO] [stdout]         let mut res_dir: Vec<DirEntry> = vec![];
[INFO] [stdout]         let dir_list = walk_dir(yok_path.display()).expect("walk dir error");
[INFO] [stdout]         for dir in dir_list {
[INFO] [stdout]             if dir.is_file() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: false,
[INFO] [stdout]                     is_file: true,
[INFO] [stdout]                     content: std::fs::read(dir).expect("read dir error"),
[INFO] [stdout]                 });
[INFO] [stdout]             } else if dir.is_dir() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: true,
[INFO] [stdout]                     is_file: false,
[INFO] [stdout]                     content: vec![],
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         let all_dir: Dir = Dir { data: res_dir };
[INFO] [stdout]         let all_dir_bytes = all_dir.as_bytes();
[INFO] [stdout]         if let Ok(_) = std::fs::write(format!("../.yok"), all_dir_bytes){}
[INFO] [stdout]     } else {
[INFO] [stdout]         eprintln!("Environment variable 'YOK_PATH' not dir");
[INFO] [stdout]         return;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] categories = ["development-tools", "game-engines", "web-programming"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] keywords = ["include", "dir", "compile-time"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] name = "yok"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] rm -rf path
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] # yok
[INFO] [stdout] 
[INFO] [stdout] [![Crates.io](https://img.shields.io/crates/v/yok.svg)](https://crates.io/crates/yok)
[INFO] [stdout] [![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://gitlab.com/andrew_ryan/yok)
[INFO] [stdout] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/andrew_ryan/yok/-/raw/master/LICENSE)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] A crate for Embed the contents of a directory in your binary at compile time.
[INFO] [stdout] 
[INFO] [stdout] ## Getting Started
[INFO] [stdout] ```sh
[INFO] [stdout] cargo add yok
[INFO] [stdout] ```
[INFO] [stdout] ```rust
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::{Dir, Bytes,include_dir};
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] }
[INFO] [stdout] ```
[INFO] [stdout] ## Set YOK_PATH env and run or default path is cuttent dir
[INFO] [stdout] ```sh
[INFO] [stdout] # linux,macos
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] # windows cmd
[INFO] [stdout] set YOK_PATH="C:\path\to\your\directory"
[INFO] [stdout] # windows powershell
[INFO] [stdout] $env:YOK_PATH = "C:\path\to\your\directory"
[INFO] [stdout] 
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] ```
[INFO] [stdout] MIT License
[INFO] [stdout] 
[INFO] [stdout] Copyright (c) [year] [fullname]
[INFO] [stdout] 
[INFO] [stdout] Permission is hereby granted, free of charge, to any person obtaining a copy
[INFO] [stdout] of this software and associated documentation files (the "Software"), to deal
[INFO] [stdout] in the Software without restriction, including without limitation the rights
[INFO] [stdout] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[INFO] [stdout] copies of the Software, and to permit persons to whom the Software is
[INFO] [stdout] furnished to do so, subject to the following conditions:
[INFO] [stdout] 
[INFO] [stdout] The above copyright notice and this permission notice shall be included in all
[INFO] [stdout] copies or substantial portions of the Software.
[INFO] [stdout] 
[INFO] [stdout] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[INFO] [stdout] IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[INFO] [stdout] FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[INFO] [stdout] AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[INFO] [stdout] LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[INFO] [stdout] OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
[INFO] [stdout] SOFTWARE.
[INFO] [stdout] # This file is automatically @generated by Cargo.
[INFO] [stdout] # It is not intended for manual editing.
[INFO] [stdout] version = 3
[INFO] [stdout] 
[INFO] [stdout] [[package]]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] 
[INFO] [stdout] image: rustlang/rust:nightly
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] push:cargo:
[INFO] [stdout]   script:
[INFO] [stdout]     - rustc --version && cargo --version  
[INFO] [stdout]     - cargo publish --allow-dirty --token cioHYTp8cpgbRbBqcJvqGF7rUIjJQSlBvH3
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] keywords = ["include","dir","compile-time"]
[INFO] [stdout] categories = ["development-tools","game-engines","web-programming"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] use std::fs::File;
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] use std::io::{BufWriter, Write};
[INFO] [stdout] use std::path::Path;
[INFO] [stdout] use zip::write::FileOptions;
[INFO] [stdout] use zip::ZipWriter;
[INFO] [stdout] use std::io::Read;
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     // Path to the directory to compress
[INFO] [stdout]     let dir_path = Path::new(".");
[INFO] [stdout] 
[INFO] [stdout]     // Path to the output ZIP file
[INFO] [stdout]     let zip_path = Path::new("app.zip");
[INFO] [stdout] 
[INFO] [stdout]     // Create a new ZIP file
[INFO] [stdout]     let file = File::create(&zip_path).unwrap();
[INFO] [stdout]     let writer = BufWriter::new(file);
[INFO] [stdout]     let mut zip = ZipWriter::new(writer);
[INFO] [stdout] 
[INFO] [stdout]     // Recursively add all files and directories in the input directory to the ZIP file
[INFO] [stdout]     add_directory_to_zip(&mut zip, dir_path, "").unwrap();
[INFO] [stdout] 
[INFO] [stdout]     // Finalize the ZIP file
[INFO] [stdout]     zip.finish().unwrap();
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Recursively adds a directory (and all its contents) to a ZipWriter
[INFO] [stdout] fn add_directory_to_zip(zip: &mut ZipWriter<BufWriter<File>>, dir_path: &Path, base_path: &str) -> zip::result::ZipResult<()> {
[INFO] [stdout]     for entry in dir_path.read_dir()? {
[INFO] [stdout]         let path = entry?.path();
[INFO] [stdout] 
[INFO] [stdout]         if path.is_dir() {
[INFO] [stdout]             // Recursively add the subdirectory
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let new_base_path = format!("{}/{}", base_path, name);
[INFO] [stdout]             add_directory_to_zip(zip, &path, &new_base_path)?;
[INFO] [stdout]         } else {
[INFO] [stdout]             // Add the file to the ZIP archive
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let options = FileOptions::default()
[INFO] [stdout]                 .compression_method(zip::CompressionMethod::Deflated)
[INFO] [stdout]                 .unix_permissions(0o755); // Set appropriate permissions for the file
[INFO] [stdout]             zip.start_file(format!("{}/{}", base_path, name), options)?;
[INFO] [stdout]             let mut file = File::open(&path)?;
[INFO] [stdout]             let mut buffer = Vec::new();
[INFO] [stdout]             file.read_to_end(&mut buffer)?;
[INFO] [stdout]             zip.write_all(&buffer)?;
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     Ok(())
[INFO] [stdout] }
[INFO] [stdout] /target
[INFO] [stdout] Cargo.lock
[INFO] [stdout] .DS_Store
[INFO] [stdout] 
[INFO] [stdout] stderr:
[INFO] [stdout] thread 'main' panicked at /opt/rustwide/workdir/src/lib.rs:236:55:
[INFO] [stdout] create to dir error: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }
[INFO] [stdout] stack backtrace:
[INFO] [stdout]    0:     0x5598cf249c26 - std::backtrace_rs::backtrace::libunwind::trace::h261606ad26a499c1
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
[INFO] [stdout]    1:     0x5598cf249c26 - std::backtrace_rs::backtrace::trace_unsynchronized::hd183f0625477fb28
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[INFO] [stdout]    2:     0x5598cf249c26 - std::sys_common::backtrace::_print_fmt::hd7f8fef21b4eda67
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:68:5
[INFO] [stdout]    3:     0x5598cf249c26 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h623d9b51f2f453f1
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:44:22
[INFO] [stdout]    4:     0x5598cf268900 - core::fmt::rt::Argument::fmt::h9f417ac76a86f368
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/rt.rs:142:9
[INFO] [stdout]    5:     0x5598cf268900 - core::fmt::write::hc9b6faf4ac2aeff7
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/mod.rs:1120:17
[INFO] [stdout]    6:     0x5598cf247eaf - std::io::Write::write_fmt::hfead1eee52c2e65e
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/io/mod.rs:1810:15
[INFO] [stdout]    7:     0x5598cf249a04 - std::sys_common::backtrace::_print::hd5d66399c7df88a2
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:47:5
[INFO] [stdout]    8:     0x5598cf249a04 - std::sys_common::backtrace::print::he81ed2da642d37e5
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:34:9
[INFO] [stdout]    9:     0x5598cf24af67 - std::panicking::default_hook::{{closure}}::h85773f4fa117163d
[INFO] [stdout]   10:     0x5598cf24acc9 - std::panicking::default_hook::h6a1694a91d09b278
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:292:9
[INFO] [stdout]   11:     0x5598cf24b3f8 - std::panicking::rust_panic_with_hook::h0a7ad96e90f7145b
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:779:13
[INFO] [stdout]   12:     0x5598cf24b2d2 - std::panicking::begin_panic_handler::{{closure}}::h7919090525c6485e
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:657:13
[INFO] [stdout]   13:     0x5598cf24a126 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3289479464f7dfe
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:171:18
[INFO] [stdout]   14:     0x5598cf24b030 - rust_begin_unwind
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:645:5
[INFO] [stdout]   15:     0x5598cf222375 - core::panicking::panic_fmt::hcc9f77c5c132af55
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:72:14
[INFO] [stdout]   16:     0x5598cf2227e3 - core::result::unwrap_failed::hbe14f498be1452f9
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/result.rs:1649:5
[INFO] [stdout]   17:     0x5598cf225783 - core::result::Result<T,E>::expect::hdab727ba03365fb3
[INFO] [stdout]   18:     0x5598cf2240e8 - yok::Dir::extract::hcc10d86fbb054c71
[INFO] [stdout]   19:     0x5598cf226447 - rust_out::main::_doctest_main_src_lib_rs_218_0::h6feb65766b41037a
[INFO] [stdout]   20:     0x5598cf226366 - rust_out::main::h71185a25be64b52e
[INFO] [stdout]   21:     0x5598cf224e13 - core::ops::function::FnOnce::call_once::h0a5e8bc522cf7e26
[INFO] [stdout]   22:     0x5598cf222ee6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h904992c6a2208b49
[INFO] [stdout]   23:     0x5598cf223f09 - std::rt::lang_start::{{closure}}::h95a4dad7805b7c7c
[INFO] [stdout]   24:     0x5598cf244a11 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h4eb4c5e1620f29b0
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/ops/function.rs:284:13
[INFO] [stdout]   25:     0x5598cf244a11 - std::panicking::try::do_call::h73fd26535faffcdf
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:552:40
[INFO] [stdout]   26:     0x5598cf244a11 - std::panicking::try::h77ff1d98f0fb9f39
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:516:19
[INFO] [stdout]   27:     0x5598cf244a11 - std::panic::catch_unwind::hab3caf2448b95e37
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panic.rs:142:14
[INFO] [stdout]   28:     0x5598cf244a11 - std::rt::lang_start_internal::{{closure}}::h8086711f9c783f78
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/rt.rs:148:48
[INFO] [stdout]   29:     0x5598cf244a11 - std::panicking::try::do_call::hf920d4dc291cd6ca
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:552:40
[INFO] [stdout]   30:     0x5598cf244a11 - std::panicking::try::h2b806ccc0a85db74
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:516:19
[INFO] [stdout]   31:     0x5598cf244a11 - std::panic::catch_unwind::h038489539c507df2
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panic.rs:142:14
[INFO] [stdout]   32:     0x5598cf244a11 - std::rt::lang_start_internal::h28503b88912e8a5c
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/rt.rs:148:20
[INFO] [stdout]   33:     0x5598cf223ee7 - std::rt::lang_start::h9942cc54b4d5350a
[INFO] [stdout]   34:     0x5598cf226675 - main
[INFO] [stdout]   35:     0x7f2b53e88d90 - <unknown>
[INFO] [stdout]   36:     0x7f2b53e88e40 - __libc_start_main
[INFO] [stdout]   37:     0x5598cf222aa5 - _start
[INFO] [stdout]   38:                0x0 - <unknown>
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] ---- src/lib.rs - DirEntry (line 10) stdout ----
[INFO] [stdout] Test executable failed (exit status: 101).
[INFO] [stdout] 
[INFO] [stdout] stdout:
[INFO] [stdout] use std::{mem, path::PathBuf, str::FromStr};
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct DirEntry {
[INFO] [stdout]     pub path: String,
[INFO] [stdout]     pub is_dir: bool,
[INFO] [stdout]     pub is_file: bool,
[INFO] [stdout]     pub contents: Vec<u8>,
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct Dir {
[INFO] [stdout]     pub data: Vec<DirEntry>,
[INFO] [stdout] }
[INFO] [stdout] pub trait Bytes {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn from_bytes(&self) -> Dir;
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn into_dir(&self) -> Dir;
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for [u8] {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for Dir {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement as_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         // Calculate the total size of the serialized data
[INFO] [stdout]         let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]             size += entry.path.as_bytes().len();
[INFO] [stdout]             size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]             size += entry.contents.len();
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]         // Write the length prefix
[INFO] [stdout]         bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             // Write the size prefix for this entry
[INFO] [stdout]             bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             // Write the entry data
[INFO] [stdout]             bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]             bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]             bytes.extend((entry.contents.len() as u32).to_le_bytes().iter());
[INFO] [stdout]             bytes.extend(entry.contents.iter());
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         bytes
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement from_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]         let mut cursor = 0;
[INFO] [stdout]         let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]         if bytes.len() < len_prefix_size {
[INFO] [stdout]             return None;
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let len = u32::from_le_bytes([
[INFO] [stdout]             bytes[cursor],
[INFO] [stdout]             bytes[cursor + 1],
[INFO] [stdout]             bytes[cursor + 2],
[INFO] [stdout]             bytes[cursor + 3],
[INFO] [stdout]         ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]         cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]         let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]         for _ in 0..len {
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let entry_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < end_pos {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]             cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + 2 {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let is_dir = bytes[cursor] != 0;
[INFO] [stdout]             let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]             cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let content_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + content_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let contents = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]             cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]             data.push(DirEntry {
[INFO] [stdout]                 path,
[INFO] [stdout]                 is_dir,
[INFO] [stdout]                 is_file,
[INFO] [stdout]                 contents,
[INFO] [stdout]             });
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         Some(Dir { data })
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] fn get_new_path(path: &str) -> String {
[INFO] [stdout]     let yok_path = match std::env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     let path = path.to_string().replace("\\", "/").to_string();
[INFO] [stdout]     if yok_path != "."{
[INFO] [stdout]         return path;
[INFO] [stdout]     }else {
[INFO] [stdout]         return path;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] 
[INFO] [stdout] impl Dir {
[INFO] [stdout]     /// include dir at compile time
[INFO] [stdout]     /// in default die path is current dir
[INFO] [stdout]     ///
[INFO] [stdout]     /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout]     ///
[INFO] [stdout]     /// you can also set YOK_PATH env before cargo run
[INFO] [stdout]     ///
[INFO] [stdout]     /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout]     /// ```rust
[INFO] [stdout]     ///   use yok::include_dir;
[INFO] [stdout]     ///   use yok::Dir;
[INFO] [stdout]     ///   use yok::DirEntry;
[INFO] [stdout]     ///   use yok::Bytes;
[INFO] [stdout]     ///   const DATA:&[u8] = include_dir();
[INFO] [stdout]     ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout]     ///   for entry in &dir.data{
[INFO] [stdout]     ///       if entry.is_file{
[INFO] [stdout]     ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]     ///       }else if entry.is_dir {
[INFO] [stdout]     ///           println!("{}",entry.path);
[INFO] [stdout]     ///       }
[INFO] [stdout]     ///   }
[INFO] [stdout]     ///   dir.extract("./demo");
[INFO] [stdout]     /// ```
[INFO] [stdout]     ///
[INFO] [stdout]     pub fn extract(&self, base_dir: impl ToString) ->std::io::Result<()>{
[INFO] [stdout]         std::fs::create_dir_all(base_dir.to_string()).expect("create to dir error");
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_dir {
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 std::fs::create_dir_all(path.clone()).expect("create to dir error");
[INFO] [stdout]                 if cfg!(target_os = "windows") {
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }else{
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_file {
[INFO] [stdout]                 use std::fs::{self, File, OpenOptions};
[INFO] [stdout]                 use std::io::prelude::*;
[INFO] [stdout]                 use std::os::unix::fs::OpenOptionsExt;
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 if !path.exists(){
[INFO] [stdout]                     let mut open_options = OpenOptions::new();
[INFO] [stdout]                     open_options.mode(0o777); // Set read/write permission for owner, read-only for others
[INFO] [stdout]                     let file = open_options.create(true).write(true).open(path).unwrap();
[INFO] [stdout]                     let mut file_writer = std::io::BufWriter::new(file);
[INFO] [stdout]                     file_writer.write_all(&entry.contents).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(())
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] pub const fn include_dir() -> &'static [u8] {
[INFO] [stdout]     include_bytes!("../../.yok")
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::include_dir;
[INFO] [stdout]     use yok::Bytes;
[INFO] [stdout]     use yok::Dir;
[INFO] [stdout]     use yok::DirEntry;
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             // println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             // println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] 
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] src
[INFO] [stdout] use std::{
[INFO] [stdout]     fs, io,
[INFO] [stdout]     path::{Path, PathBuf},
[INFO] [stdout] };
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     use std::mem;
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct DirEntry {
[INFO] [stdout]         path: String,
[INFO] [stdout]         is_dir: bool,
[INFO] [stdout]         is_file: bool,
[INFO] [stdout]         content: Vec<u8>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct Dir {
[INFO] [stdout]         data: Vec<DirEntry>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement as_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]             // Calculate the total size of the serialized data
[INFO] [stdout]             let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]                 size += entry.path.as_bytes().len();
[INFO] [stdout]                 size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]                 size += entry.content.len();
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]             // Write the length prefix
[INFO] [stdout]             bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 // Write the size prefix for this entry
[INFO] [stdout]                 bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]                 // Write the entry data
[INFO] [stdout]                 bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]                 bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]                 bytes.extend((entry.content.len() as u32).to_le_bytes().iter());
[INFO] [stdout]                 bytes.extend(entry.content.iter());
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             bytes
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement from_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         #[allow(warnings)]
[INFO] [stdout]         pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]             let mut cursor = 0;
[INFO] [stdout]             let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let len = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]             for _ in 0..len {
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let entry_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < end_pos {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]                 cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + 2 {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let is_dir = bytes[cursor] != 0;
[INFO] [stdout]                 let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]                 cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + content_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]                 cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]                 data.push(DirEntry {
[INFO] [stdout]                     path,
[INFO] [stdout]                     is_dir,
[INFO] [stdout]                     is_file,
[INFO] [stdout]                     content,
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             Some(Dir { data })
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     pub fn walk_dir(path: impl ToString) -> io::Result<Vec<PathBuf>> {
[INFO] [stdout]         let path = path.to_string();
[INFO] [stdout]         let dir = Path::new(&path);
[INFO] [stdout]         let mut files = Vec::new();
[INFO] [stdout]         for entry in fs::read_dir(dir)? {
[INFO] [stdout]             let entry = entry?;
[INFO] [stdout]             let newpath = entry.path();
[INFO] [stdout] 
[INFO] [stdout]             if newpath.is_dir() {
[INFO] [stdout]                 files.extend(walk_dir(&newpath.display())?);
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             } else {
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(files)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     use std::env;
[INFO] [stdout]     let yok_path = match env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     println!("cargo:rerun-if-env-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed=main.rs");
[INFO] [stdout]     println!("cargo:rerun-if-changed=lib.rs");
[INFO] [stdout]     let yok_path = std::path::Path::new(&yok_path);
[INFO] [stdout]     if yok_path.is_dir() {
[INFO] [stdout]         let mut res_dir: Vec<DirEntry> = vec![];
[INFO] [stdout]         let dir_list = walk_dir(yok_path.display()).expect("walk dir error");
[INFO] [stdout]         for dir in dir_list {
[INFO] [stdout]             if dir.is_file() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: false,
[INFO] [stdout]                     is_file: true,
[INFO] [stdout]                     content: std::fs::read(dir).expect("read dir error"),
[INFO] [stdout]                 });
[INFO] [stdout]             } else if dir.is_dir() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: true,
[INFO] [stdout]                     is_file: false,
[INFO] [stdout]                     content: vec![],
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         let all_dir: Dir = Dir { data: res_dir };
[INFO] [stdout]         let all_dir_bytes = all_dir.as_bytes();
[INFO] [stdout]         if let Ok(_) = std::fs::write(format!("../.yok"), all_dir_bytes){}
[INFO] [stdout]     } else {
[INFO] [stdout]         eprintln!("Environment variable 'YOK_PATH' not dir");
[INFO] [stdout]         return;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] categories = ["development-tools", "game-engines", "web-programming"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] keywords = ["include", "dir", "compile-time"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] name = "yok"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] rm -rf path
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] # yok
[INFO] [stdout] 
[INFO] [stdout] [![Crates.io](https://img.shields.io/crates/v/yok.svg)](https://crates.io/crates/yok)
[INFO] [stdout] [![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://gitlab.com/andrew_ryan/yok)
[INFO] [stdout] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/andrew_ryan/yok/-/raw/master/LICENSE)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] A crate for Embed the contents of a directory in your binary at compile time.
[INFO] [stdout] 
[INFO] [stdout] ## Getting Started
[INFO] [stdout] ```sh
[INFO] [stdout] cargo add yok
[INFO] [stdout] ```
[INFO] [stdout] ```rust
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::{Dir, Bytes,include_dir};
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] }
[INFO] [stdout] ```
[INFO] [stdout] ## Set YOK_PATH env and run or default path is cuttent dir
[INFO] [stdout] ```sh
[INFO] [stdout] # linux,macos
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] # windows cmd
[INFO] [stdout] set YOK_PATH="C:\path\to\your\directory"
[INFO] [stdout] # windows powershell
[INFO] [stdout] $env:YOK_PATH = "C:\path\to\your\directory"
[INFO] [stdout] 
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] ```
[INFO] [stdout] MIT License
[INFO] [stdout] 
[INFO] [stdout] Copyright (c) [year] [fullname]
[INFO] [stdout] 
[INFO] [stdout] Permission is hereby granted, free of charge, to any person obtaining a copy
[INFO] [stdout] of this software and associated documentation files (the "Software"), to deal
[INFO] [stdout] in the Software without restriction, including without limitation the rights
[INFO] [stdout] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[INFO] [stdout] copies of the Software, and to permit persons to whom the Software is
[INFO] [stdout] furnished to do so, subject to the following conditions:
[INFO] [stdout] 
[INFO] [stdout] The above copyright notice and this permission notice shall be included in all
[INFO] [stdout] copies or substantial portions of the Software.
[INFO] [stdout] 
[INFO] [stdout] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[INFO] [stdout] IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[INFO] [stdout] FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[INFO] [stdout] AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[INFO] [stdout] LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[INFO] [stdout] OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
[INFO] [stdout] SOFTWARE.
[INFO] [stdout] # This file is automatically @generated by Cargo.
[INFO] [stdout] # It is not intended for manual editing.
[INFO] [stdout] version = 3
[INFO] [stdout] 
[INFO] [stdout] [[package]]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] 
[INFO] [stdout] image: rustlang/rust:nightly
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] push:cargo:
[INFO] [stdout]   script:
[INFO] [stdout]     - rustc --version && cargo --version  
[INFO] [stdout]     - cargo publish --allow-dirty --token cioHYTp8cpgbRbBqcJvqGF7rUIjJQSlBvH3
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] keywords = ["include","dir","compile-time"]
[INFO] [stdout] categories = ["development-tools","game-engines","web-programming"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] use std::fs::File;
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] use std::io::{BufWriter, Write};
[INFO] [stdout] use std::path::Path;
[INFO] [stdout] use zip::write::FileOptions;
[INFO] [stdout] use zip::ZipWriter;
[INFO] [stdout] use std::io::Read;
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     // Path to the directory to compress
[INFO] [stdout]     let dir_path = Path::new(".");
[INFO] [stdout] 
[INFO] [stdout]     // Path to the output ZIP file
[INFO] [stdout]     let zip_path = Path::new("app.zip");
[INFO] [stdout] 
[INFO] [stdout]     // Create a new ZIP file
[INFO] [stdout]     let file = File::create(&zip_path).unwrap();
[INFO] [stdout]     let writer = BufWriter::new(file);
[INFO] [stdout]     let mut zip = ZipWriter::new(writer);
[INFO] [stdout] 
[INFO] [stdout]     // Recursively add all files and directories in the input directory to the ZIP file
[INFO] [stdout]     add_directory_to_zip(&mut zip, dir_path, "").unwrap();
[INFO] [stdout] 
[INFO] [stdout]     // Finalize the ZIP file
[INFO] [stdout]     zip.finish().unwrap();
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Recursively adds a directory (and all its contents) to a ZipWriter
[INFO] [stdout] fn add_directory_to_zip(zip: &mut ZipWriter<BufWriter<File>>, dir_path: &Path, base_path: &str) -> zip::result::ZipResult<()> {
[INFO] [stdout]     for entry in dir_path.read_dir()? {
[INFO] [stdout]         let path = entry?.path();
[INFO] [stdout] 
[INFO] [stdout]         if path.is_dir() {
[INFO] [stdout]             // Recursively add the subdirectory
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let new_base_path = format!("{}/{}", base_path, name);
[INFO] [stdout]             add_directory_to_zip(zip, &path, &new_base_path)?;
[INFO] [stdout]         } else {
[INFO] [stdout]             // Add the file to the ZIP archive
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let options = FileOptions::default()
[INFO] [stdout]                 .compression_method(zip::CompressionMethod::Deflated)
[INFO] [stdout]                 .unix_permissions(0o755); // Set appropriate permissions for the file
[INFO] [stdout]             zip.start_file(format!("{}/{}", base_path, name), options)?;
[INFO] [stdout]             let mut file = File::open(&path)?;
[INFO] [stdout]             let mut buffer = Vec::new();
[INFO] [stdout]             file.read_to_end(&mut buffer)?;
[INFO] [stdout]             zip.write_all(&buffer)?;
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     Ok(())
[INFO] [stdout] }
[INFO] [stdout] /target
[INFO] [stdout] Cargo.lock
[INFO] [stdout] .DS_Store
[INFO] [stdout] 
[INFO] [stdout] stderr:
[INFO] [stdout] thread 'main' panicked at /opt/rustwide/workdir/src/lib.rs:236:55:
[INFO] [stdout] create to dir error: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }
[INFO] [stdout] stack backtrace:
[INFO] [stdout]    0:     0x563a41f0cc26 - std::backtrace_rs::backtrace::libunwind::trace::h261606ad26a499c1
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
[INFO] [stdout]    1:     0x563a41f0cc26 - std::backtrace_rs::backtrace::trace_unsynchronized::hd183f0625477fb28
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[INFO] [stdout]    2:     0x563a41f0cc26 - std::sys_common::backtrace::_print_fmt::hd7f8fef21b4eda67
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:68:5
[INFO] [stdout]    3:     0x563a41f0cc26 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h623d9b51f2f453f1
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:44:22
[INFO] [stdout]    4:     0x563a41f2b900 - core::fmt::rt::Argument::fmt::h9f417ac76a86f368
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/rt.rs:142:9
[INFO] [stdout]    5:     0x563a41f2b900 - core::fmt::write::hc9b6faf4ac2aeff7
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/mod.rs:1120:17
[INFO] [stdout]    6:     0x563a41f0aeaf - std::io::Write::write_fmt::hfead1eee52c2e65e
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/io/mod.rs:1810:15
[INFO] [stdout]    7:     0x563a41f0ca04 - std::sys_common::backtrace::_print::hd5d66399c7df88a2
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:47:5
[INFO] [stdout]    8:     0x563a41f0ca04 - std::sys_common::backtrace::print::he81ed2da642d37e5
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:34:9
[INFO] [stdout]    9:     0x563a41f0df67 - std::panicking::default_hook::{{closure}}::h85773f4fa117163d
[INFO] [stdout]   10:     0x563a41f0dcc9 - std::panicking::default_hook::h6a1694a91d09b278
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:292:9
[INFO] [stdout]   11:     0x563a41f0e3f8 - std::panicking::rust_panic_with_hook::h0a7ad96e90f7145b
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:779:13
[INFO] [stdout]   12:     0x563a41f0e2d2 - std::panicking::begin_panic_handler::{{closure}}::h7919090525c6485e
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:657:13
[INFO] [stdout]   13:     0x563a41f0d126 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3289479464f7dfe
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:171:18
[INFO] [stdout]   14:     0x563a41f0e030 - rust_begin_unwind
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:645:5
[INFO] [stdout]   15:     0x563a41ee5375 - core::panicking::panic_fmt::hcc9f77c5c132af55
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:72:14
[INFO] [stdout]   16:     0x563a41ee57e3 - core::result::unwrap_failed::hbe14f498be1452f9
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/result.rs:1649:5
[INFO] [stdout]   17:     0x563a41ee8783 - core::result::Result<T,E>::expect::hdab727ba03365fb3
[INFO] [stdout]   18:     0x563a41ee70e8 - yok::Dir::extract::hcc10d86fbb054c71
[INFO] [stdout]   19:     0x563a41ee9447 - rust_out::main::_doctest_main_src_lib_rs_10_0::ha025534e883982ee
[INFO] [stdout]   20:     0x563a41ee9366 - rust_out::main::h71185a25be64b52e
[INFO] [stdout]   21:     0x563a41ee7e13 - core::ops::function::FnOnce::call_once::h0a5e8bc522cf7e26
[INFO] [stdout]   22:     0x563a41ee5ee6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h904992c6a2208b49
[INFO] [stdout]   23:     0x563a41ee6f09 - std::rt::lang_start::{{closure}}::h95a4dad7805b7c7c
[INFO] [stdout]   24:     0x563a41f07a11 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h4eb4c5e1620f29b0
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/ops/function.rs:284:13
[INFO] [stdout]   25:     0x563a41f07a11 - std::panicking::try::do_call::h73fd26535faffcdf
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:552:40
[INFO] [stdout]   26:     0x563a41f07a11 - std::panicking::try::h77ff1d98f0fb9f39
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:516:19
[INFO] [stdout]   27:     0x563a41f07a11 - std::panic::catch_unwind::hab3caf2448b95e37
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panic.rs:142:14
[INFO] [stdout]   28:     0x563a41f07a11 - std::rt::lang_start_internal::{{closure}}::h8086711f9c783f78
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/rt.rs:148:48
[INFO] [stdout]   29:     0x563a41f07a11 - std::panicking::try::do_call::hf920d4dc291cd6ca
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:552:40
[INFO] [stdout]   30:     0x563a41f07a11 - std::panicking::try::h2b806ccc0a85db74
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:516:19
[INFO] [stdout]   31:     0x563a41f07a11 - std::panic::catch_unwind::h038489539c507df2
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panic.rs:142:14
[INFO] [stdout]   32:     0x563a41f07a11 - std::rt::lang_start_internal::h28503b88912e8a5c
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/rt.rs:148:20
[INFO] [stdout]   33:     0x563a41ee6ee7 - std::rt::lang_start::h9942cc54b4d5350a
[INFO] [stdout]   34:     0x563a41ee9675 - main
[INFO] [stdout]   35:     0x7f7473f3fd90 - <unknown>
[INFO] [stdout]   36:     0x7f7473f3fe40 - __libc_start_main
[INFO] [stdout]   37:     0x563a41ee5aa5 - _start
[INFO] [stdout]   38:                0x0 - <unknown>
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] ---- src/lib.rs - include_dir (line 282) stdout ----
[INFO] [stdout] Test executable failed (exit status: 101).
[INFO] [stdout] 
[INFO] [stdout] stdout:
[INFO] [stdout] use std::{mem, path::PathBuf, str::FromStr};
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct DirEntry {
[INFO] [stdout]     pub path: String,
[INFO] [stdout]     pub is_dir: bool,
[INFO] [stdout]     pub is_file: bool,
[INFO] [stdout]     pub contents: Vec<u8>,
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout] pub struct Dir {
[INFO] [stdout]     pub data: Vec<DirEntry>,
[INFO] [stdout] }
[INFO] [stdout] pub trait Bytes {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn from_bytes(&self) -> Dir;
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8>;
[INFO] [stdout]     fn into_dir(&self) -> Dir;
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for [u8] {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         self.to_vec()
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         Dir::from_bytes(self).expect("from bytes error")
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] impl Bytes for Dir {
[INFO] [stdout]     fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout]     fn into_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         Dir::as_bytes(&self)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     fn from_bytes(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout]     fn into_dir(&self) -> Dir {
[INFO] [stdout]         self.clone()
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement as_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]         // Calculate the total size of the serialized data
[INFO] [stdout]         let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]             size += entry.path.as_bytes().len();
[INFO] [stdout]             size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]             size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]             size += entry.contents.len();
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]         // Write the length prefix
[INFO] [stdout]         bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]         for entry in &self.data {
[INFO] [stdout]             // Write the size prefix for this entry
[INFO] [stdout]             bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             // Write the entry data
[INFO] [stdout]             bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]             bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]             bytes.extend((entry.contents.len() as u32).to_le_bytes().iter());
[INFO] [stdout]             bytes.extend(entry.contents.iter());
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         bytes
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Implement from_bytes() for Dir
[INFO] [stdout] impl Dir {
[INFO] [stdout]     pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]         let mut cursor = 0;
[INFO] [stdout]         let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]         if bytes.len() < len_prefix_size {
[INFO] [stdout]             return None;
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         let len = u32::from_le_bytes([
[INFO] [stdout]             bytes[cursor],
[INFO] [stdout]             bytes[cursor + 1],
[INFO] [stdout]             bytes[cursor + 2],
[INFO] [stdout]             bytes[cursor + 3],
[INFO] [stdout]         ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]         cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]         let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]         for _ in 0..len {
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let entry_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < end_pos {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]             cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + 2 {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let is_dir = bytes[cursor] != 0;
[INFO] [stdout]             let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]             cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let content_size = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < cursor + content_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let contents = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]             cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]             data.push(DirEntry {
[INFO] [stdout]                 path,
[INFO] [stdout]                 is_dir,
[INFO] [stdout]                 is_file,
[INFO] [stdout]                 contents,
[INFO] [stdout]             });
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         Some(Dir { data })
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] fn get_new_path(path: &str) -> String {
[INFO] [stdout]     let yok_path = match std::env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     let path = path.to_string().replace("\\", "/").to_string();
[INFO] [stdout]     if yok_path != "."{
[INFO] [stdout]         return path;
[INFO] [stdout]     }else {
[INFO] [stdout]         return path;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] 
[INFO] [stdout] impl Dir {
[INFO] [stdout]     /// include dir at compile time
[INFO] [stdout]     /// in default die path is current dir
[INFO] [stdout]     ///
[INFO] [stdout]     /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout]     ///
[INFO] [stdout]     /// you can also set YOK_PATH env before cargo run
[INFO] [stdout]     ///
[INFO] [stdout]     /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout]     /// ```rust
[INFO] [stdout]     ///   use yok::include_dir;
[INFO] [stdout]     ///   use yok::Dir;
[INFO] [stdout]     ///   use yok::DirEntry;
[INFO] [stdout]     ///   use yok::Bytes;
[INFO] [stdout]     ///   const DATA:&[u8] = include_dir();
[INFO] [stdout]     ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout]     ///   for entry in &dir.data{
[INFO] [stdout]     ///       if entry.is_file{
[INFO] [stdout]     ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]     ///       }else if entry.is_dir {
[INFO] [stdout]     ///           println!("{}",entry.path);
[INFO] [stdout]     ///       }
[INFO] [stdout]     ///   }
[INFO] [stdout]     ///   dir.extract("./demo");
[INFO] [stdout]     /// ```
[INFO] [stdout]     ///
[INFO] [stdout]     pub fn extract(&self, base_dir: impl ToString) ->std::io::Result<()>{
[INFO] [stdout]         std::fs::create_dir_all(base_dir.to_string()).expect("create to dir error");
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_dir {
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 std::fs::create_dir_all(path.clone()).expect("create to dir error");
[INFO] [stdout]                 if cfg!(target_os = "windows") {
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }else{
[INFO] [stdout]                     use std::os::unix::fs::PermissionsExt;
[INFO] [stdout]                     let permissions = std::fs::Permissions::from_mode(0o777);
[INFO] [stdout]                     std::fs::set_permissions(path.clone(), permissions).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout] 
[INFO] [stdout]         for entry in self.data.clone().into_iter() {
[INFO] [stdout]             if entry.is_file {
[INFO] [stdout]                 use std::fs::{self, File, OpenOptions};
[INFO] [stdout]                 use std::io::prelude::*;
[INFO] [stdout]                 use std::os::unix::fs::OpenOptionsExt;
[INFO] [stdout]                 let path = PathBuf::from_str(&base_dir.to_string()).expect("parse to to PathBuf error");
[INFO] [stdout]                 let path = path.join(get_new_path(&entry.path.to_string()));
[INFO] [stdout]                 if !path.exists(){
[INFO] [stdout]                     let mut open_options = OpenOptions::new();
[INFO] [stdout]                     open_options.mode(0o777); // Set read/write permission for owner, read-only for others
[INFO] [stdout]                     let file = open_options.create(true).write(true).open(path).unwrap();
[INFO] [stdout]                     let mut file_writer = std::io::BufWriter::new(file);
[INFO] [stdout]                     file_writer.write_all(&entry.contents).unwrap();
[INFO] [stdout]                 }
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(())
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] /// include dir at compile time
[INFO] [stdout] /// in default die path is current dir
[INFO] [stdout] ///
[INFO] [stdout] /// `export YOK_PATH="/home/andrew/code/gitlab/test_code/"`
[INFO] [stdout] ///
[INFO] [stdout] /// you can also set YOK_PATH env before cargo run
[INFO] [stdout] ///
[INFO] [stdout] /// If the dir path is not the path you set, run `cargo clean` before `cargo run`
[INFO] [stdout] /// ```rust
[INFO] [stdout] ///   use yok::include_dir;
[INFO] [stdout] ///   use yok::Dir;
[INFO] [stdout] ///   use yok::DirEntry;
[INFO] [stdout] ///   use yok::Bytes;
[INFO] [stdout] ///   const DATA:&[u8] = include_dir();
[INFO] [stdout] ///   let dir:Dir = DATA.into_dir();
[INFO] [stdout] ///   for entry in &dir.data{
[INFO] [stdout] ///       if entry.is_file{
[INFO] [stdout] ///           println!("{}",String::from_utf8_lossy(&entry.contents));
[INFO] [stdout] ///       }else if entry.is_dir {
[INFO] [stdout] ///           println!("{}",entry.path);
[INFO] [stdout] ///       }
[INFO] [stdout] ///   }
[INFO] [stdout] ///   dir.extract("./demo");
[INFO] [stdout] /// ```
[INFO] [stdout] ///
[INFO] [stdout] pub const fn include_dir() -> &'static [u8] {
[INFO] [stdout]     include_bytes!("../../.yok")
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::include_dir;
[INFO] [stdout]     use yok::Bytes;
[INFO] [stdout]     use yok::Dir;
[INFO] [stdout]     use yok::DirEntry;
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             // println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             // println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] 
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] src
[INFO] [stdout] use std::{
[INFO] [stdout]     fs, io,
[INFO] [stdout]     path::{Path, PathBuf},
[INFO] [stdout] };
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     use std::mem;
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct DirEntry {
[INFO] [stdout]         path: String,
[INFO] [stdout]         is_dir: bool,
[INFO] [stdout]         is_file: bool,
[INFO] [stdout]         content: Vec<u8>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     #[derive(Debug, Clone, PartialEq, Eq)]
[INFO] [stdout]     pub struct Dir {
[INFO] [stdout]         data: Vec<DirEntry>,
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement as_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         pub fn as_bytes(&self) -> Vec<u8> {
[INFO] [stdout]             // Calculate the total size of the serialized data
[INFO] [stdout]             let mut size = mem::size_of::<u32>(); // Size of the length prefix
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of the entry size prefix
[INFO] [stdout]                 size += entry.path.as_bytes().len();
[INFO] [stdout]                 size += mem::size_of::<bool>() * 2; // Sizes of is_dir and is_file fields
[INFO] [stdout]                 size += mem::size_of::<u32>(); // Size of content size prefix
[INFO] [stdout]                 size += entry.content.len();
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let mut bytes = Vec::with_capacity(size);
[INFO] [stdout] 
[INFO] [stdout]             // Write the length prefix
[INFO] [stdout]             bytes.extend((self.data.len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]             for entry in &self.data {
[INFO] [stdout]                 // Write the size prefix for this entry
[INFO] [stdout]                 bytes.extend((entry.path.as_bytes().len() as u32).to_le_bytes().iter());
[INFO] [stdout] 
[INFO] [stdout]                 // Write the entry data
[INFO] [stdout]                 bytes.extend(entry.path.as_bytes().iter());
[INFO] [stdout]                 bytes.extend(&[entry.is_dir as u8, entry.is_file as u8]);
[INFO] [stdout]                 bytes.extend((entry.content.len() as u32).to_le_bytes().iter());
[INFO] [stdout]                 bytes.extend(entry.content.iter());
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             bytes
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     // Implement from_bytes() for Dir
[INFO] [stdout]     impl Dir {
[INFO] [stdout]         #[allow(warnings)]
[INFO] [stdout]         pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
[INFO] [stdout]             let mut cursor = 0;
[INFO] [stdout]             let len_prefix_size = mem::size_of::<u32>();
[INFO] [stdout] 
[INFO] [stdout]             if bytes.len() < len_prefix_size {
[INFO] [stdout]                 return None;
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             let len = u32::from_le_bytes([
[INFO] [stdout]                 bytes[cursor],
[INFO] [stdout]                 bytes[cursor + 1],
[INFO] [stdout]                 bytes[cursor + 2],
[INFO] [stdout]                 bytes[cursor + 3],
[INFO] [stdout]             ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]             cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]             let mut data = Vec::with_capacity(len);
[INFO] [stdout] 
[INFO] [stdout]             for _ in 0..len {
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let entry_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 let end_pos = cursor + entry_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < end_pos {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let path = String::from_utf8(bytes[cursor..end_pos].to_vec()).ok()?;
[INFO] [stdout]                 cursor = end_pos;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + 2 {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let is_dir = bytes[cursor] != 0;
[INFO] [stdout]                 let is_file = bytes[cursor + 1] != 0;
[INFO] [stdout]                 cursor += 2;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + len_prefix_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content_size = u32::from_le_bytes([
[INFO] [stdout]                     bytes[cursor],
[INFO] [stdout]                     bytes[cursor + 1],
[INFO] [stdout]                     bytes[cursor + 2],
[INFO] [stdout]                     bytes[cursor + 3],
[INFO] [stdout]                 ]) as usize;
[INFO] [stdout] 
[INFO] [stdout]                 cursor += len_prefix_size;
[INFO] [stdout] 
[INFO] [stdout]                 if bytes.len() < cursor + content_size {
[INFO] [stdout]                     return None;
[INFO] [stdout]                 }
[INFO] [stdout] 
[INFO] [stdout]                 let content = bytes[cursor..cursor + content_size].to_vec();
[INFO] [stdout]                 cursor += content_size;
[INFO] [stdout] 
[INFO] [stdout]                 data.push(DirEntry {
[INFO] [stdout]                     path,
[INFO] [stdout]                     is_dir,
[INFO] [stdout]                     is_file,
[INFO] [stdout]                     content,
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout] 
[INFO] [stdout]             Some(Dir { data })
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     pub fn walk_dir(path: impl ToString) -> io::Result<Vec<PathBuf>> {
[INFO] [stdout]         let path = path.to_string();
[INFO] [stdout]         let dir = Path::new(&path);
[INFO] [stdout]         let mut files = Vec::new();
[INFO] [stdout]         for entry in fs::read_dir(dir)? {
[INFO] [stdout]             let entry = entry?;
[INFO] [stdout]             let newpath = entry.path();
[INFO] [stdout] 
[INFO] [stdout]             if newpath.is_dir() {
[INFO] [stdout]                 files.extend(walk_dir(&newpath.display())?);
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             } else {
[INFO] [stdout]                 files.push(newpath);
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         Ok(files)
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     use std::env;
[INFO] [stdout]     let yok_path = match env::var("YOK_PATH") {
[INFO] [stdout]         Ok(value) => value,
[INFO] [stdout]         Err(_) => ".".to_string(),
[INFO] [stdout]     };
[INFO] [stdout]     println!("cargo:rerun-if-env-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed={}", yok_path);
[INFO] [stdout]     println!("cargo:rerun-if-changed=main.rs");
[INFO] [stdout]     println!("cargo:rerun-if-changed=lib.rs");
[INFO] [stdout]     let yok_path = std::path::Path::new(&yok_path);
[INFO] [stdout]     if yok_path.is_dir() {
[INFO] [stdout]         let mut res_dir: Vec<DirEntry> = vec![];
[INFO] [stdout]         let dir_list = walk_dir(yok_path.display()).expect("walk dir error");
[INFO] [stdout]         for dir in dir_list {
[INFO] [stdout]             if dir.is_file() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: false,
[INFO] [stdout]                     is_file: true,
[INFO] [stdout]                     content: std::fs::read(dir).expect("read dir error"),
[INFO] [stdout]                 });
[INFO] [stdout]             } else if dir.is_dir() {
[INFO] [stdout]                 res_dir.push(DirEntry {
[INFO] [stdout]                     path: dir.strip_prefix(yok_path).unwrap().display().to_string(),
[INFO] [stdout]                     is_dir: true,
[INFO] [stdout]                     is_file: false,
[INFO] [stdout]                     content: vec![],
[INFO] [stdout]                 });
[INFO] [stdout]             }
[INFO] [stdout]         }
[INFO] [stdout]         let all_dir: Dir = Dir { data: res_dir };
[INFO] [stdout]         let all_dir_bytes = all_dir.as_bytes();
[INFO] [stdout]         if let Ok(_) = std::fs::write(format!("../.yok"), all_dir_bytes){}
[INFO] [stdout]     } else {
[INFO] [stdout]         eprintln!("Environment variable 'YOK_PATH' not dir");
[INFO] [stdout]         return;
[INFO] [stdout]     }
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] categories = ["development-tools", "game-engines", "web-programming"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] keywords = ["include", "dir", "compile-time"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] name = "yok"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] rm -rf path
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] # yok
[INFO] [stdout] 
[INFO] [stdout] [![Crates.io](https://img.shields.io/crates/v/yok.svg)](https://crates.io/crates/yok)
[INFO] [stdout] [![Rust](https://img.shields.io/badge/rust-1.56.1%2B-blue.svg?maxAge=3600)](https://gitlab.com/andrew_ryan/yok)
[INFO] [stdout] [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/andrew_ryan/yok/-/raw/master/LICENSE)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] A crate for Embed the contents of a directory in your binary at compile time.
[INFO] [stdout] 
[INFO] [stdout] ## Getting Started
[INFO] [stdout] ```sh
[INFO] [stdout] cargo add yok
[INFO] [stdout] ```
[INFO] [stdout] ```rust
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] fn main() {
[INFO] [stdout]     use yok::{Dir, Bytes,include_dir};
[INFO] [stdout]     const DATA: &[u8] = include_dir();
[INFO] [stdout]     let dir: Dir = DATA.into_dir();
[INFO] [stdout]     for entry in &dir.data {
[INFO] [stdout]         if entry.is_file {
[INFO] [stdout]             println!("{}", String::from_utf8_lossy(&entry.contents));
[INFO] [stdout]         } else if entry.is_dir {
[INFO] [stdout]             println!("{}", entry.path);
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout]     dir.extract("./path");
[INFO] [stdout] }
[INFO] [stdout] ```
[INFO] [stdout] ## Set YOK_PATH env and run or default path is cuttent dir
[INFO] [stdout] ```sh
[INFO] [stdout] # linux,macos
[INFO] [stdout] export YOK_PATH="/home/andrew/code/gitlab/test_code/"
[INFO] [stdout] # windows cmd
[INFO] [stdout] set YOK_PATH="C:\path\to\your\directory"
[INFO] [stdout] # windows powershell
[INFO] [stdout] $env:YOK_PATH = "C:\path\to\your\directory"
[INFO] [stdout] 
[INFO] [stdout] cargo clean
[INFO] [stdout] cargo r
[INFO] [stdout] ```
[INFO] [stdout] MIT License
[INFO] [stdout] 
[INFO] [stdout] Copyright (c) [year] [fullname]
[INFO] [stdout] 
[INFO] [stdout] Permission is hereby granted, free of charge, to any person obtaining a copy
[INFO] [stdout] of this software and associated documentation files (the "Software"), to deal
[INFO] [stdout] in the Software without restriction, including without limitation the rights
[INFO] [stdout] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[INFO] [stdout] copies of the Software, and to permit persons to whom the Software is
[INFO] [stdout] furnished to do so, subject to the following conditions:
[INFO] [stdout] 
[INFO] [stdout] The above copyright notice and this permission notice shall be included in all
[INFO] [stdout] copies or substantial portions of the Software.
[INFO] [stdout] 
[INFO] [stdout] THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[INFO] [stdout] IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[INFO] [stdout] FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[INFO] [stdout] AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[INFO] [stdout] LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[INFO] [stdout] OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
[INFO] [stdout] SOFTWARE.
[INFO] [stdout] # This file is automatically @generated by Cargo.
[INFO] [stdout] # It is not intended for manual editing.
[INFO] [stdout] version = 3
[INFO] [stdout] 
[INFO] [stdout] [[package]]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] 
[INFO] [stdout] image: rustlang/rust:nightly
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] push:cargo:
[INFO] [stdout]   script:
[INFO] [stdout]     - rustc --version && cargo --version  
[INFO] [stdout]     - cargo publish --allow-dirty --token cioHYTp8cpgbRbBqcJvqGF7rUIjJQSlBvH3
[INFO] [stdout] 
[INFO] [stdout] [package]
[INFO] [stdout] name = "yok"
[INFO] [stdout] version = "0.1.9"
[INFO] [stdout] edition = "2021"
[INFO] [stdout] authors = ["Anonymous <dnrops@outlook.com>"]
[INFO] [stdout] description = "Embed the contents of a directory in your binary"
[INFO] [stdout] readme = "README.md"
[INFO] [stdout] keywords = ["include","dir","compile-time"]
[INFO] [stdout] categories = ["development-tools","game-engines","web-programming"]
[INFO] [stdout] license = "MIT"
[INFO] [stdout] documentation = "https://docs.rs/yok"
[INFO] [stdout] repository = "https://gitlab.com/andrew_ryan/yok"
[INFO] [stdout] homepage = "https://dnrops.gitee.io"
[INFO] [stdout] build = "build.rs"
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [package.metadata.docs.rs]
[INFO] [stdout] rustc-args = ["--cfg", "docsrs"]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [dependencies]
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] [build-dependencies]
[INFO] [stdout] use std::fs::File;
[INFO] [stdout] #[allow(warnings)]
[INFO] [stdout] use std::io::{BufWriter, Write};
[INFO] [stdout] use std::path::Path;
[INFO] [stdout] use zip::write::FileOptions;
[INFO] [stdout] use zip::ZipWriter;
[INFO] [stdout] use std::io::Read;
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] fn main() {
[INFO] [stdout]     // Path to the directory to compress
[INFO] [stdout]     let dir_path = Path::new(".");
[INFO] [stdout] 
[INFO] [stdout]     // Path to the output ZIP file
[INFO] [stdout]     let zip_path = Path::new("app.zip");
[INFO] [stdout] 
[INFO] [stdout]     // Create a new ZIP file
[INFO] [stdout]     let file = File::create(&zip_path).unwrap();
[INFO] [stdout]     let writer = BufWriter::new(file);
[INFO] [stdout]     let mut zip = ZipWriter::new(writer);
[INFO] [stdout] 
[INFO] [stdout]     // Recursively add all files and directories in the input directory to the ZIP file
[INFO] [stdout]     add_directory_to_zip(&mut zip, dir_path, "").unwrap();
[INFO] [stdout] 
[INFO] [stdout]     // Finalize the ZIP file
[INFO] [stdout]     zip.finish().unwrap();
[INFO] [stdout] }
[INFO] [stdout] 
[INFO] [stdout] // Recursively adds a directory (and all its contents) to a ZipWriter
[INFO] [stdout] fn add_directory_to_zip(zip: &mut ZipWriter<BufWriter<File>>, dir_path: &Path, base_path: &str) -> zip::result::ZipResult<()> {
[INFO] [stdout]     for entry in dir_path.read_dir()? {
[INFO] [stdout]         let path = entry?.path();
[INFO] [stdout] 
[INFO] [stdout]         if path.is_dir() {
[INFO] [stdout]             // Recursively add the subdirectory
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let new_base_path = format!("{}/{}", base_path, name);
[INFO] [stdout]             add_directory_to_zip(zip, &path, &new_base_path)?;
[INFO] [stdout]         } else {
[INFO] [stdout]             // Add the file to the ZIP archive
[INFO] [stdout]             let name = path.file_name().unwrap().to_str().unwrap();
[INFO] [stdout]             let options = FileOptions::default()
[INFO] [stdout]                 .compression_method(zip::CompressionMethod::Deflated)
[INFO] [stdout]                 .unix_permissions(0o755); // Set appropriate permissions for the file
[INFO] [stdout]             zip.start_file(format!("{}/{}", base_path, name), options)?;
[INFO] [stdout]             let mut file = File::open(&path)?;
[INFO] [stdout]             let mut buffer = Vec::new();
[INFO] [stdout]             file.read_to_end(&mut buffer)?;
[INFO] [stdout]             zip.write_all(&buffer)?;
[INFO] [stdout]         }
[INFO] [stdout]     }
[INFO] [stdout] 
[INFO] [stdout]     Ok(())
[INFO] [stdout] }
[INFO] [stdout] /target
[INFO] [stdout] Cargo.lock
[INFO] [stdout] .DS_Store
[INFO] [stdout] 
[INFO] [stdout] stderr:
[INFO] [stdout] thread 'main' panicked at /opt/rustwide/workdir/src/lib.rs:236:55:
[INFO] [stdout] create to dir error: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }
[INFO] [stdout] stack backtrace:
[INFO] [stdout]    0:     0x557cde1dcc26 - std::backtrace_rs::backtrace::libunwind::trace::h261606ad26a499c1
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
[INFO] [stdout]    1:     0x557cde1dcc26 - std::backtrace_rs::backtrace::trace_unsynchronized::hd183f0625477fb28
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[INFO] [stdout]    2:     0x557cde1dcc26 - std::sys_common::backtrace::_print_fmt::hd7f8fef21b4eda67
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:68:5
[INFO] [stdout]    3:     0x557cde1dcc26 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h623d9b51f2f453f1
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:44:22
[INFO] [stdout]    4:     0x557cde1fb900 - core::fmt::rt::Argument::fmt::h9f417ac76a86f368
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/rt.rs:142:9
[INFO] [stdout]    5:     0x557cde1fb900 - core::fmt::write::hc9b6faf4ac2aeff7
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/fmt/mod.rs:1120:17
[INFO] [stdout]    6:     0x557cde1daeaf - std::io::Write::write_fmt::hfead1eee52c2e65e
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/io/mod.rs:1810:15
[INFO] [stdout]    7:     0x557cde1dca04 - std::sys_common::backtrace::_print::hd5d66399c7df88a2
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:47:5
[INFO] [stdout]    8:     0x557cde1dca04 - std::sys_common::backtrace::print::he81ed2da642d37e5
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:34:9
[INFO] [stdout]    9:     0x557cde1ddf67 - std::panicking::default_hook::{{closure}}::h85773f4fa117163d
[INFO] [stdout]   10:     0x557cde1ddcc9 - std::panicking::default_hook::h6a1694a91d09b278
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:292:9
[INFO] [stdout]   11:     0x557cde1de3f8 - std::panicking::rust_panic_with_hook::h0a7ad96e90f7145b
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:779:13
[INFO] [stdout]   12:     0x557cde1de2d2 - std::panicking::begin_panic_handler::{{closure}}::h7919090525c6485e
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:657:13
[INFO] [stdout]   13:     0x557cde1dd126 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3289479464f7dfe
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/sys_common/backtrace.rs:171:18
[INFO] [stdout]   14:     0x557cde1de030 - rust_begin_unwind
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:645:5
[INFO] [stdout]   15:     0x557cde1b5375 - core::panicking::panic_fmt::hcc9f77c5c132af55
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:72:14
[INFO] [stdout]   16:     0x557cde1b57e3 - core::result::unwrap_failed::hbe14f498be1452f9
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/result.rs:1649:5
[INFO] [stdout]   17:     0x557cde1b8783 - core::result::Result<T,E>::expect::hdab727ba03365fb3
[INFO] [stdout]   18:     0x557cde1b70e8 - yok::Dir::extract::hcc10d86fbb054c71
[INFO] [stdout]   19:     0x557cde1b9447 - rust_out::main::_doctest_main_src_lib_rs_282_0::hd124689047d57331
[INFO] [stdout]   20:     0x557cde1b9366 - rust_out::main::h71185a25be64b52e
[INFO] [stdout]   21:     0x557cde1b7e13 - core::ops::function::FnOnce::call_once::h0a5e8bc522cf7e26
[INFO] [stdout]   22:     0x557cde1b5ee6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h904992c6a2208b49
[INFO] [stdout]   23:     0x557cde1b6f09 - std::rt::lang_start::{{closure}}::h95a4dad7805b7c7c
[INFO] [stdout]   24:     0x557cde1d7a11 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h4eb4c5e1620f29b0
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/ops/function.rs:284:13
[INFO] [stdout]   25:     0x557cde1d7a11 - std::panicking::try::do_call::h73fd26535faffcdf
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:552:40
[INFO] [stdout]   26:     0x557cde1d7a11 - std::panicking::try::h77ff1d98f0fb9f39
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:516:19
[INFO] [stdout]   27:     0x557cde1d7a11 - std::panic::catch_unwind::hab3caf2448b95e37
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panic.rs:142:14
[INFO] [stdout]   28:     0x557cde1d7a11 - std::rt::lang_start_internal::{{closure}}::h8086711f9c783f78
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/rt.rs:148:48
[INFO] [stdout]   29:     0x557cde1d7a11 - std::panicking::try::do_call::hf920d4dc291cd6ca
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:552:40
[INFO] [stdout]   30:     0x557cde1d7a11 - std::panicking::try::h2b806ccc0a85db74
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:516:19
[INFO] [stdout]   31:     0x557cde1d7a11 - std::panic::catch_unwind::h038489539c507df2
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panic.rs:142:14
[INFO] [stdout]   32:     0x557cde1d7a11 - std::rt::lang_start_internal::h28503b88912e8a5c
[INFO] [stdout]                                at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/rt.rs:148:20
[INFO] [stdout]   33:     0x557cde1b6ee7 - std::rt::lang_start::h9942cc54b4d5350a
[INFO] [stdout]   34:     0x557cde1b9675 - main
[INFO] [stdout]   35:     0x7fdf6e87cd90 - <unknown>
[INFO] [stdout]   36:     0x7fdf6e87ce40 - __libc_start_main
[INFO] [stdout]   37:     0x557cde1b5aa5 - _start
[INFO] [stdout]   38:                0x0 - <unknown>
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] failures:
[INFO] [stdout]     src/lib.rs - Dir::extract (line 218)
[INFO] [stdout]     src/lib.rs - DirEntry (line 10)
[INFO] [stdout]     src/lib.rs - include_dir (line 282)
[INFO] [stdout] 
[INFO] [stdout] test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.28s
[INFO] [stdout] 
[INFO] [stderr] error: doctest failed, to rerun pass `--doc`
[INFO] running `Command { std: "docker" "inspect" "ca295a19a45106cb7f336e577a7a4a5d7f4851e23e76141a0b3b9e2ee564b5bb", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "ca295a19a45106cb7f336e577a7a4a5d7f4851e23e76141a0b3b9e2ee564b5bb", kill_on_drop: false }`
[INFO] [stdout] ca295a19a45106cb7f336e577a7a4a5d7f4851e23e76141a0b3b9e2ee564b5bb
