Skip to content

Commit

Permalink
Additional pakfile improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaco committed Dec 22, 2018
1 parent 85be03d commit 9596a49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ github.com/go-gl/mathgl v0.0.0-20180804195959-cdf14b6b8f8a h1:2n5w2v3knlspzjJWyQ
github.com/go-gl/mathgl v0.0.0-20180804195959-cdf14b6b8f8a/go.mod h1:dvrdneKbyWbK2skTda0nM4B9zSlS2GZSnjX7itr/skQ=
golang.org/x/image v0.0.0-20181109002202-aa35264064ba h1:tKfAeDKyjJZwxAJ8TPBZaf6LpvauubUHT8wwpdz+OMM=
golang.org/x/image v0.0.0-20181109002202-aa35264064ba/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20181206121112-cd38e8056d9b h1:9WPnadh+EKSlC7bAQtFhmNxmx/rQOj35pa7nFj6b/Dw=
golang.org/x/image v0.0.0-20181206121112-cd38e8056d9b/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
8 changes: 6 additions & 2 deletions lumps/pakfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (lump *Pakfile) ToBytes() []byte {
func (lump *Pakfile) GetFile(filePath string) ([]byte, error) {
filePath = lump.sanitisePath(filePath)
for _, f := range lump.zipReader.File {
if lump.sanitisePath(f.Name) == filePath {
if strings.EqualFold(filePath, lump.sanitisePath(f.Name)) == true {
rc, err := f.Open()
if err != nil {
return nil, err
Expand All @@ -58,5 +58,9 @@ func (lump *Pakfile) GetFile(filePath string) ([]byte, error) {

// sanitisePath ensures that the requested path matches internal casing
func (lump *Pakfile) sanitisePath(filePath string) string {
return strings.Replace(strings.ToLower(filePath), "\\", "/", -1)
return strings.Replace(
strings.Replace(strings.ToLower(filePath), "\\", "/", -1),
"//",
"/",
-1)
}

0 comments on commit 9596a49

Please sign in to comment.