mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
improve gres with file separator replaced to /
This commit is contained in:
@ -59,7 +59,7 @@ func ParseWithArgs(args []string, supportedOptions map[string]bool) (*Parser, er
|
||||
|
||||
for i := 0; i < len(args); {
|
||||
if option := parser.parseOption(args[i]); option != "" {
|
||||
array, _ := gregex.MatchString(`^(\w+)=(.+)$`, option)
|
||||
array, _ := gregex.MatchString(`^(.+?)=(.+)$`, option)
|
||||
if len(array) == 3 {
|
||||
if parser.isOptionValid(array[1]) {
|
||||
parser.setOptionValue(array[1], array[2])
|
||||
|
||||
@ -70,6 +70,7 @@ func (r *Resource) Get(path string) *File {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
if path != "/" {
|
||||
for path[len(path)-1] == '/' {
|
||||
path = path[:len(path)-1]
|
||||
@ -87,6 +88,7 @@ func (r *Resource) Get(path string) *File {
|
||||
//
|
||||
// GetWithIndex is usually used for http static file service.
|
||||
func (r *Resource) GetWithIndex(path string, indexFiles []string) *File {
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
if path != "/" {
|
||||
for path[len(path)-1] == '/' {
|
||||
path = path[:len(path)-1]
|
||||
@ -108,6 +110,7 @@ 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()
|
||||
@ -161,6 +164,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)
|
||||
if path != "/" {
|
||||
for path[len(path)-1] == '/' {
|
||||
path = path[:len(path)-1]
|
||||
|
||||
Reference in New Issue
Block a user