mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-01-13 04:46:38 -05:00
Merge pull request #1114 from gucio321/revert-1113-revert-1105-fix_ci
Revert "Revert "Fix golang-ci gocritic error""
This commit is contained in:
commit
1a3f3ed91a
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -181,24 +182,26 @@ func (mpq *MPQ) Size() uint32 {
|
||||
func openIgnoreCase(mpqPath string) (*os.File, error) {
|
||||
// First see if file exists with specified case
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
mpqName := filepath.Base(mpqPath)
|
||||
mpqDir := filepath.Dir(mpqPath)
|
||||
|
||||
for _, file := range files {
|
||||
if strings.EqualFold(file.Name(), mpqName) {
|
||||
mpqName = file.Name()
|
||||
break
|
||||
var files []fs.FileInfo
|
||||
files, err = ioutil.ReadDir(mpqDir)
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user