mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-10-01 00:06:11 -04:00
isolate filesystem interface package
This commit is contained in:
parent
78cefbaa91
commit
70c66853f9
@ -2,7 +2,7 @@ package environment
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/v2fly/v2ray-core/v4/common/log"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/transport/internet/tagged"
|
"github.com/v2fly/v2ray-core/v4/transport/internet/tagged"
|
||||||
)
|
)
|
||||||
@ -35,7 +35,7 @@ type LogCapabilitySet interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FileSystemCapabilitySet interface {
|
type FileSystemCapabilitySet interface {
|
||||||
OpenFileForReadSeek() filesystem.FileSeekerFunc
|
OpenFileForReadSeek() fsifce.FileSeekerFunc
|
||||||
OpenFileForRead() filesystem.FileReaderFunc
|
OpenFileForRead() fsifce.FileReaderFunc
|
||||||
OpenFileForWrite() filesystem.FileWriterFunc
|
OpenFileForWrite() fsifce.FileWriterFunc
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package filesystem
|
package filesystem
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/v2fly/v2ray-core/v4/common/platform/filesystem/fsifce"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -8,21 +9,15 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/platform"
|
"github.com/v2fly/v2ray-core/v4/common/platform"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileSeekerFunc func(path string) (io.ReadSeekCloser, error)
|
var NewFileSeeker fsifce.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) {
|
|
||||||
return os.Open(path)
|
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)
|
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)
|
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