mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 14:23:42 +00:00
windows快速分配
This commit is contained in:
1 parent
3215955056
commit
63210dce63
6 files changed
+142
-14
No files matched your search
@@ -48,6 +48,10 @@ type Process interface {
|
||||
Delete() error
|
||||
}
|
||||
|
||||
type FileCreator interface {
|
||||
Create(name string, size int64) (file *os.File, err error)
|
||||
}
|
||||
|
||||
type Controller struct {
|
||||
Files map[string]*os.File
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package file_allocate
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type FileAllocate interface {
|
||||
Allocate(name string, size int64) (file *os.File, err error)
|
||||
}
|
||||
|
||||
type DefaultFileAllocator struct {
|
||||
}
|
||||
|
||||
func (p *DefaultFileAllocator) Allocate(name string, size int64) (file *os.File, err error) {
|
||||
err = os.Truncate(name, size)
|
||||
file, err = os.OpenFile(name, os.O_RDWR, 0644)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package file_allocate
|
||||
|
||||
import "os"
|
||||
|
||||
type PreFileAllocator struct {
|
||||
}
|
||||
|
||||
func (p *PreFileAllocator) Allocate(name string, size int64) (file *os.File, err error) {
|
||||
err = os.Truncate(name, size)
|
||||
file, err = os.OpenFile(name, os.O_RDWR, 0644)
|
||||
return
|
||||
}
|
||||
Reference in new issue
Block a user