1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00
This commit is contained in:
Mikadore 2021-03-31 12:54:16 +02:00 committed by GitHub
parent a57f17ac5b
commit 96643d6f91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -358,7 +358,8 @@ impl AtPath {
pub fn read(&self, name: &str) -> String { pub fn read(&self, name: &str) -> String {
let mut f = self.open(name); let mut f = self.open(name);
let mut contents = String::new(); let mut contents = String::new();
let _ = f.read_to_string(&mut contents); f.read_to_string(&mut contents)
.unwrap_or_else(|e| panic!("Couldn't read {}: {}", name, e));
contents contents
} }
@ -372,7 +373,8 @@ impl AtPath {
pub fn write(&self, name: &str, contents: &str) { pub fn write(&self, name: &str, contents: &str) {
log_info("open(write)", self.plus_as_string(name)); log_info("open(write)", self.plus_as_string(name));
let _ = std::fs::write(self.plus(name), contents); std::fs::write(self.plus(name), contents)
.unwrap_or_else(|e| panic!("Couldn't write {}: {}", name, e));
} }
pub fn write_bytes(&self, name: &str, contents: &[u8]) { pub fn write_bytes(&self, name: &str, contents: &[u8]) {
@ -388,7 +390,8 @@ impl AtPath {
.append(true) .append(true)
.open(self.plus(name)) .open(self.plus(name))
.unwrap(); .unwrap();
let _ = f.write(contents.as_bytes()); f.write(contents.as_bytes())
.unwrap_or_else(|e| panic!("Couldn't write {}: {}", name, e));
} }
pub fn append_bytes(&self, name: &str, contents: &[u8]) { pub fn append_bytes(&self, name: &str, contents: &[u8]) {
@ -781,7 +784,7 @@ pub fn read_size(child: &mut Child, size: usize) -> String {
.stdout .stdout
.as_mut() .as_mut()
.unwrap() .unwrap()
.read(output.as_mut_slice()) .read_exact(output.as_mut_slice())
.unwrap(); .unwrap();
String::from_utf8(output).unwrap() String::from_utf8(output).unwrap()
} }