Skip to content

Commit

Permalink
Merge pull request #2 from Chikage0o0/fix-writeFile
Browse files Browse the repository at this point in the history
fix write file error in windows
  • Loading branch information
nothub authored Sep 6, 2022
2 parents db236a8 + 4afdcd5 commit 9651191
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modrinth/mrpack/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mrpack
import (
"archive/zip"
"fmt"
"io"
"log"
"os"
"path"
Expand Down Expand Up @@ -48,20 +49,22 @@ func ExtractOverrides(zipFile string, target string) error {
return err
}

var buf []byte
_, err = fileReader.Read(buf)
outFile, err := os.OpenFile(targetPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return err
}
err = os.WriteFile(targetPath, buf, 0644)
if err != nil {
if _, err := io.Copy(outFile, fileReader); err != nil {
return err
}

err = fileReader.Close()
if err != nil {
return err
}
err = outFile.Close()
if err != nil {
return err
}

log.Println("Override file extracted:", targetPath)
}
Expand Down

0 comments on commit 9651191

Please sign in to comment.