Skip to content

Commit

Permalink
Merge pull request #107 from xushiwei/q
Browse files Browse the repository at this point in the history
fs/util => fs/fsutil
  • Loading branch information
xushiwei authored Dec 1, 2021
2 parents 2b070e4 + 6a23e30 commit 5625eff
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
11 changes: 11 additions & 0 deletions fs/fsutil/file_android.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package fsutil

import (
"io"

"golang.org/x/mobile/asset"
)

func OpenFile(path string) (io.ReadSeekCloser, error) {
return asset.Open(path)
}
5 changes: 3 additions & 2 deletions fs/util/file_js.go → fs/fsutil/file_js.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package util
package fsutil

import (
"bytes"
"io"
"io/ioutil"
"net/http"
)
Expand All @@ -14,7 +15,7 @@ func (f *file) Close() error {
return nil
}

func OpenFile(path string) (ReadSeekCloser, error) {
func OpenFile(path string) (io.ReadSeekCloser, error) {
res, err := http.Get(path)
if err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions fs/util/file_nojs.go → fs/fsutil/file_nojs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
// +build !android
// +build !ios

package util
package fsutil

import (
"io"
"os"
"path/filepath"
)
Expand All @@ -16,6 +17,6 @@ import (
// The path parts should be separated with slash '/' on any environments.
//
// Note that this doesn't work on mobiles.
func OpenFile(path string) (ReadSeekCloser, error) {
func OpenFile(path string) (io.ReadSeekCloser, error) {
return os.Open(filepath.FromSlash(path))
}
4 changes: 2 additions & 2 deletions fs/local/localfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io"

"github.com/goplus/spx/fs"
"github.com/goplus/spx/fs/util"
"github.com/goplus/spx/fs/fsutil"
)

// -------------------------------------------------------------------------------------
Expand All @@ -20,7 +20,7 @@ func Open(base string) (fs.Dir, error) {

// Open opens a zipped file object.
func (p *FS) Open(name string) (io.ReadCloser, error) {
f, err := util.OpenFile(p.base + name)
f, err := fsutil.OpenFile(p.base + name)
return f, err
}

Expand Down
9 changes: 0 additions & 9 deletions fs/util/file.go

This file was deleted.

9 changes: 0 additions & 9 deletions fs/util/file_android.go

This file was deleted.

4 changes: 2 additions & 2 deletions internal/gdi/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"

"github.com/golang/freetype/truetype"
"github.com/goplus/spx/fs/util"
"github.com/goplus/spx/fs/fsutil"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
Expand Down Expand Up @@ -90,7 +90,7 @@ func (p *DefaultFont) findFontAtPath(
}

func (p *DefaultFont) tryFontFile(name, tryFile string, options *truetype.Options) bool {
fp, err := util.OpenFile(tryFile)
fp, err := fsutil.OpenFile(tryFile)
if err != nil {
return false
}
Expand Down

0 comments on commit 5625eff

Please sign in to comment.