1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

isolate filesystem interface package

This commit is contained in:
Shelikhoo 2021-09-05 14:37:24 +01:00
parent 78cefbaa91
commit 70c66853f9
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
3 changed files with 17 additions and 13 deletions

View File

@ -2,7 +2,7 @@ package environment
import (
"github.com/v2fly/v2ray-core/v4/common/log"
"github.com/v2fly/v2ray-core/v4/common/platform/filesystem"
"github.com/v2fly/v2ray-core/v4/common/platform/filesystem/fsifce"
"github.com/v2fly/v2ray-core/v4/transport/internet"
"github.com/v2fly/v2ray-core/v4/transport/internet/tagged"
)
@ -35,7 +35,7 @@ type LogCapabilitySet interface {
}
type FileSystemCapabilitySet interface {
OpenFileForReadSeek() filesystem.FileSeekerFunc
OpenFileForRead() filesystem.FileReaderFunc
OpenFileForWrite() filesystem.FileWriterFunc
OpenFileForReadSeek() fsifce.FileSeekerFunc
OpenFileForRead() fsifce.FileReaderFunc
OpenFileForWrite() fsifce.FileWriterFunc
}

View File

@ -1,6 +1,7 @@
package filesystem
import (
"github.com/v2fly/v2ray-core/v4/common/platform/filesystem/fsifce"
"io"
"os"
@ -8,21 +9,15 @@ import (
"github.com/v2fly/v2ray-core/v4/common/platform"
)
type FileSeekerFunc func(path string) (io.ReadSeekCloser, error)
type FileReaderFunc func(path string) (io.ReadCloser, error)
type FileWriterFunc func(path string) (io.WriteCloser, error)
var NewFileSeeker FileSeekerFunc = func(path string) (io.ReadSeekCloser, error) {
var NewFileSeeker fsifce.FileSeekerFunc = func(path string) (io.ReadSeekCloser, error) {
return os.Open(path)
}
var NewFileReader FileReaderFunc = func(path string) (io.ReadCloser, error) {
var NewFileReader fsifce.FileReaderFunc = func(path string) (io.ReadCloser, error) {
return os.Open(path)
}
var NewFileWriter FileWriterFunc = func(path string) (io.WriteCloser, error) {
var NewFileWriter fsifce.FileWriterFunc = func(path string) (io.WriteCloser, error) {
return os.Create(path)
}

View File

@ -0,0 +1,9 @@
package fsifce
import "io"
type FileSeekerFunc func(path string) (io.ReadSeekCloser, error)
type FileReaderFunc func(path string) (io.ReadCloser, error)
type FileWriterFunc func(path string) (io.WriteCloser, error)