1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-16 04:25:23 +00:00

Merge pull request #1105 from drpaneas/fix_ci

Fix golang-ci gocritic error
This commit is contained in:
gravestench 2021-03-26 11:03:14 -07:00 committed by GitHub
commit 5b1debd3f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"errors" "errors"
"fmt" "fmt"
"io/fs"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -181,24 +182,26 @@ func (mpq *MPQ) Size() uint32 {
func openIgnoreCase(mpqPath string) (*os.File, error) { func openIgnoreCase(mpqPath string) (*os.File, error) {
// First see if file exists with specified case // First see if file exists with specified case
mpqFile, err := os.Open(mpqPath) //nolint:gosec // Will fix later mpqFile, err := os.Open(mpqPath) //nolint:gosec // Will fix later
if err == nil {
return mpqFile, err
}
mpqName := filepath.Base(mpqPath)
mpqDir := filepath.Dir(mpqPath)
files, err := ioutil.ReadDir(mpqDir)
if err != nil { if err != nil {
return nil, err mpqName := filepath.Base(mpqPath)
} mpqDir := filepath.Dir(mpqPath)
for _, file := range files { var files []fs.FileInfo
if strings.EqualFold(file.Name(), mpqName) { files, err = ioutil.ReadDir(mpqDir)
mpqName = file.Name()
break if err != nil {
return nil, err
} }
for _, file := range files {
if strings.EqualFold(file.Name(), mpqName) {
mpqName = file.Name()
break
}
}
return os.Open(filepath.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later
} }
return os.Open(filepath.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later return mpqFile, err
} }