Skip to content

Commit

Permalink
Fix windows build (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimach committed Aug 5, 2024
1 parent 796bead commit 5d52d31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: ilammy/setup-nasm@v1

- uses: dtolnay/rust-toolchain@stable
with:
Expand Down
10 changes: 5 additions & 5 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,31 @@ fn exists(path: &str) -> String {
path.exists().to_string()
}

fn write(data: &str, path: &str, base64decode: bool) -> Result<usize> {
fn write(data: &str, path: &str, base64decode: bool) -> Result<()> {
let path: &std::path::Path = path.as_ref();
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)?;
}

let mut file = BufWriter::new(File::create(path)?);

let written = if base64decode {
file.write(
if base64decode {
file.write_all(
base64::prelude::BASE64_STANDARD
.decode(data)
.unwrap()
.as_ref(),
)?
} else {
file.write(data.as_bytes())?
file.write_all(data.as_bytes())?
};

file.flush()?;
file.into_inner()
.map_err(|e| std::io::Error::new(e.error().kind(), e.error().to_string()))? // This is god-awful, but the compiler REFUSES to let me get an owned copy of `e`
.sync_all()?;

Ok(written)
Ok(())
}

fn append(data: &str, path: &str) -> Result<usize> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// #![forbid(unsafe_op_in_unsafe_fn)] - see github.com/rust-lang/rust/issues/121483

#![allow(clippy::thread_local_initializer_can_be_made_const)]
#[macro_use]
mod byond;
#[allow(dead_code)]
Expand Down

0 comments on commit 5d52d31

Please sign in to comment.