mirror of
https://github.com/zyedidia/micro.git
synced 2024-10-03 23:17:52 +03:00
normalize path - force slash separator to access embed FS (#2197)
This commit is contained in:
parent
ec3292e8c4
commit
a417ec4dcb
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,5 @@ benchmark_results*
|
|||||||
tools/build-version
|
tools/build-version
|
||||||
tools/build-date
|
tools/build-date
|
||||||
tools/info-plist
|
tools/info-plist
|
||||||
tools/bindata
|
|
||||||
tools/vscode-tests/
|
tools/vscode-tests/
|
||||||
*.hdr
|
*.hdr
|
||||||
|
@ -2,6 +2,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -10,9 +11,13 @@ import (
|
|||||||
//go:embed colorschemes help plugins syntax
|
//go:embed colorschemes help plugins syntax
|
||||||
var runtime embed.FS
|
var runtime embed.FS
|
||||||
|
|
||||||
|
func fixPath(name string) string {
|
||||||
|
return strings.TrimLeft(filepath.ToSlash(name), "runtime/")
|
||||||
|
}
|
||||||
|
|
||||||
// AssetDir lists file names in folder
|
// AssetDir lists file names in folder
|
||||||
func AssetDir(name string) ([]string, error) {
|
func AssetDir(name string) ([]string, error) {
|
||||||
name = strings.TrimLeft(name, "runtime/")
|
name = fixPath(name)
|
||||||
entries, err := runtime.ReadDir(name)
|
entries, err := runtime.ReadDir(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -26,6 +31,6 @@ func AssetDir(name string) ([]string, error) {
|
|||||||
|
|
||||||
// Asset returns a file content
|
// Asset returns a file content
|
||||||
func Asset(name string) ([]byte, error) {
|
func Asset(name string) ([]byte, error) {
|
||||||
name = strings.TrimLeft(name, "runtime/")
|
name = fixPath(name)
|
||||||
return runtime.ReadFile(name)
|
return runtime.ReadFile(name)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user