Skip to content

Commit f56cc44

Browse files
committed
Fix windows tests
1 parent 4daa0cc commit f56cc44

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/module_writer.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,22 @@ impl ModuleWriter for PathWriter {
213213
.with_context(|| format!("Failed to create directory {}", parent_dir.display()))?;
214214
}
215215

216-
let mut options = OpenOptions::new();
217-
options.create(true).write(true).truncate(true);
218-
#[cfg(unix)]
219-
{
220-
options.mode(default_permission(executable));
216+
let mut file = {
217+
#[cfg(target_family = "unix")]
218+
{
219+
OpenOptions::new()
220+
.create(true)
221+
.write(true)
222+
.truncate(true)
223+
.mode(default_permission(executable))
224+
.open(&path)
225+
}
226+
#[cfg(target_os = "windows")]
227+
{
228+
File::create(&path)
229+
}
221230
}
222-
223-
let mut file = options
224-
.open(&path)
225-
.with_context(|| format!("Failed to create a file at {}", path.display()))?;
231+
.with_context(|| format!("Failed to create a file at {}", path.display()))?;
226232
let mut writer = StreamSha256::new(&mut file);
227233

228234
io::copy(&mut data, &mut writer)

0 commit comments

Comments
 (0)