mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
improve package gres
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
@ -74,6 +74,7 @@ func (r *Resource) Get(path string) *File {
|
||||
return nil
|
||||
}
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
path = strings.Replace(path, "//", "/", -1)
|
||||
if path != "/" {
|
||||
for path[len(path)-1] == '/' {
|
||||
path = path[:len(path)-1]
|
||||
@ -93,6 +94,7 @@ func (r *Resource) Get(path string) *File {
|
||||
func (r *Resource) GetWithIndex(path string, indexFiles []string) *File {
|
||||
// Necessary for double char '/' replacement in prefix.
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
path = strings.Replace(path, "//", "/", -1)
|
||||
if path != "/" {
|
||||
for path[len(path)-1] == '/' {
|
||||
path = path[:len(path)-1]
|
||||
@ -114,7 +116,6 @@ func (r *Resource) GetWithIndex(path string, indexFiles []string) *File {
|
||||
|
||||
// GetContent directly returns the content of <path>.
|
||||
func (r *Resource) GetContent(path string) []byte {
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
file := r.Get(path)
|
||||
if file != nil {
|
||||
return file.Content()
|
||||
@ -169,6 +170,7 @@ func (r *Resource) ScanDirFile(path string, pattern string, recursive ...bool) [
|
||||
// It scans directory recursively if given parameter <recursive> is true.
|
||||
func (r *Resource) doScanDir(path string, pattern string, recursive bool, onlyFile bool) []*File {
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
path = strings.Replace(path, "//", "/", -1)
|
||||
if path != "/" {
|
||||
for path[len(path)-1] == '/' {
|
||||
path = path[:len(path)-1]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
|
||||
2
os/gres/testdata/data/data.go
vendored
2
os/gres/testdata/data/data.go
vendored
File diff suppressed because one or more lines are too long
2
os/gres/testdata/testdata.go
vendored
2
os/gres/testdata/testdata.go
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user