-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from Defelo/update_flake_lock_action
Update flake.lock
- Loading branch information
Showing
4 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
diff --git a/src/sys.rs b/src/sys.rs | ||
index a5388a57..034198e2 100644 | ||
--- a/src/sys.rs | ||
+++ b/src/sys.rs | ||
@@ -743,12 +743,12 @@ pub trait SysBackend: Any + Send + Sync + 'static { | ||
Err("Creating files is not supported in this environment".into()) | ||
} | ||
/// Open a file | ||
- fn open_file(&self, path: &Path) -> Result<Handle, String> { | ||
+ fn open_file(&self, path: &Path, write: bool) -> Result<Handle, String> { | ||
Err("Opening files is not supported in this environment".into()) | ||
} | ||
/// Read all bytes from a file | ||
fn file_read_all(&self, path: &Path) -> Result<Vec<u8>, String> { | ||
- let handle = self.open_file(path)?; | ||
+ let handle = self.open_file(path, false)?; | ||
let bytes = self.read(handle, usize::MAX)?; | ||
self.close(handle)?; | ||
Ok(bytes) | ||
@@ -1020,7 +1020,7 @@ impl SysOp { | ||
SysOp::FOpen => { | ||
let path = env.pop(1)?.as_string(env, "Path must be a string")?; | ||
let handle = (env.rt.backend) | ||
- .open_file(path.as_ref()) | ||
+ .open_file(path.as_ref(), true) | ||
.map_err(|e| env.error(e))? | ||
.value(HandleKind::File(path.into())); | ||
env.push(handle); | ||
diff --git a/src/sys_native.rs b/src/sys_native.rs | ||
index bf598ec6..d192f286 100644 | ||
--- a/src/sys_native.rs | ||
+++ b/src/sys_native.rs | ||
@@ -206,18 +206,18 @@ impl SysBackend for NativeSys { | ||
} | ||
Ok(paths) | ||
} | ||
- fn open_file(&self, path: &Path) -> Result<Handle, String> { | ||
+ fn open_file(&self, path: &Path, write: bool) -> Result<Handle, String> { | ||
let handle = NATIVE_SYS.new_handle(); | ||
let file = OpenOptions::new() | ||
.read(true) | ||
- .write(true) | ||
+ .write(write) | ||
.open(path) | ||
.map_err(|e| format!("{e} {}", path.display()))?; | ||
NATIVE_SYS.files.insert(handle, Buffered::new_reader(file)); | ||
Ok(handle) | ||
} | ||
fn file_read_all(&self, path: &Path) -> Result<Vec<u8>, String> { | ||
- let handle = self.open_file(path)?; | ||
+ let handle = self.open_file(path, false)?; | ||
let bytes = self.read_all(handle)?; | ||
self.close(handle)?; | ||
Ok(bytes) |