mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
ebitenutil: Add ReadSeekCloser and use this
This commit is contained in:
parent
992832afe1
commit
07968abfd6
@ -17,13 +17,12 @@
|
|||||||
package ebitenutil
|
package ebitenutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OpenFile opens a file and returns a stream for its data.
|
// OpenFile opens a file and returns a stream for its data.
|
||||||
//
|
//
|
||||||
// This function is available both on desktops and browsers.
|
// 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)
|
return os.Open(path)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/gopherjs/gopherjs/js"
|
"github.com/gopherjs/gopherjs/js"
|
||||||
)
|
)
|
||||||
@ -33,7 +32,7 @@ func (f *file) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenFile(path string) (io.ReadCloser, error) {
|
func OpenFile(path string) (ReadSeekCloser, error) {
|
||||||
var err error
|
var err error
|
||||||
var content *js.Object
|
var content *js.Object
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
|
24
ebitenutil/io.go
Normal file
24
ebitenutil/io.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user