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:
parent
78cefbaa91
commit
70c66853f9
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
9
common/platform/filesystem/fsifce/ifce.go
Normal file
9
common/platform/filesystem/fsifce/ifce.go
Normal 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)
|
Loading…
Reference in New Issue
Block a user