ebitenutil: Add ReadSeekCloser and use this

This commit is contained in:
Hajime Hoshi 2016-03-29 23:52:11 +09:00
parent 992832afe1
commit 07968abfd6
3 changed files with 26 additions and 4 deletions

View File

@ -17,13 +17,12 @@
package ebitenutil
import (
"io"
"os"
)
// OpenFile opens a file and returns a stream for its data.
//
// This function is available both on desktops and browsers.
func OpenFile(path string) (io.ReadCloser, error) {
func OpenFile(path string) (ReadSeekCloser, error) {
return os.Open(path)
}

View File

@ -20,7 +20,6 @@ import (
"bytes"
"errors"
"fmt"
"io"
"github.com/gopherjs/gopherjs/js"
)
@ -33,7 +32,7 @@ func (f *file) Close() error {
return nil
}
func OpenFile(path string) (io.ReadCloser, error) {
func OpenFile(path string) (ReadSeekCloser, error) {
var err error
var content *js.Object
ch := make(chan struct{})

24
ebitenutil/io.go Normal file
View File

@ -0,0 +1,24 @@
// Copyright 2016 Hajime Hoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ebitenutil
import (
"io"
)
type ReadSeekCloser interface {
io.ReadSeeker
io.Closer
}