MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / mk

Method mk

crates/cargo-lambda-cli/tests/harness/project.rs:120–140  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

118 }
119
120 fn mk(&mut self) {
121 if self.executable {
122 let mut path = self.path.clone().into_os_string();
123 write!(path, "{}", env::consts::EXE_SUFFIX).unwrap();
124 self.path = path.into();
125 }
126
127 self.dirname().mkdir_p();
128 fs::write(&self.path, &self.body)
129 .unwrap_or_else(|e| panic!("could not create file {}: {}", self.path.display(), e));
130
131 #[cfg(unix)]
132 if self.executable {
133 use std::os::unix::fs::PermissionsExt;
134
135 let mut perms = fs::metadata(&self.path).unwrap().permissions();
136 let mode = perms.mode();
137 perms.set_mode(mode | 0o111);
138 fs::set_permissions(&self.path, perms).unwrap();
139 }
140 }
141
142 fn dirname(&self) -> &Path {
143 self.path.parent().unwrap()

Callers 1

change_fileMethod · 0.80

Calls 2

mkdir_pMethod · 0.80
dirnameMethod · 0.80

Tested by

no test coverage detected