MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / write

Method write

crates/chat-cli/src/os/fs/mod.rs:221–233  ·  view source on GitHub ↗

Creates a future that will open a file for writing and write the entire contents of `contents` to it. This is a proxy to [`tokio::fs::write`].

(&self, path: impl AsRef<Path>, contents: impl AsRef<[u8]>)

Source from the content-addressed store, hash-verified

219 ///
220 /// This is a proxy to [`tokio::fs::write`].
221 pub async fn write(&self, path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> io::Result<()> {
222 match self {
223 Self::Real => fs::write(path, contents).await,
224 Self::Chroot(root) => fs::write(append(root.path(), path), contents).await,
225 Self::Fake(map) => {
226 let Ok(mut lock) = map.lock() else {
227 return Err(io::Error::other("poisoned lock"));
228 };
229 lock.insert(path.as_ref().to_owned(), contents.as_ref().to_owned());
230 Ok(())
231 },
232 }
233 }
234
235 /// Removes a file from the filesystem.
236 ///

Callers 15

newMethod · 0.45
save_to_fileMethod · 0.45
test_fakeFunction · 0.45
test_realFunction · 0.45
test_read_to_stringFunction · 0.45
executeMethod · 0.45
get_test_agentsFunction · 0.45

Calls 4

insertMethod · 0.80
appendFunction · 0.70
pathMethod · 0.45
as_refMethod · 0.45