github.com/0chain/gosdk@v1.17.11/core/sys/fs.go (about) 1 package sys 2 3 import ( 4 "io/fs" 5 "os" 6 ) 7 8 // FS An FS provides access to a hierarchical file system. 9 type FS interface { 10 11 // Open opens the named file for reading. If successful, methods on 12 // the returned file can be used for reading; the associated file 13 // descriptor has mode O_RDONLY. 14 // If there is an error, it will be of type *PathError. 15 Open(name string) (File, error) 16 17 // OpenFile open a file 18 OpenFile(name string, flag int, perm os.FileMode) (File, error) 19 20 // ReadFile reads the file named by filename and returns the contents. 21 ReadFile(name string) ([]byte, error) 22 23 // WriteFile writes data to a file named by filename. 24 WriteFile(name string, data []byte, perm fs.FileMode) error 25 26 Stat(name string) (fs.FileInfo, error) 27 28 // Remove removes the named file or (empty) directory. 29 // If there is an error, it will be of type *PathError. 30 Remove(name string) error 31 32 //MkdirAll creates a directory named path 33 MkdirAll(path string, perm os.FileMode) error 34 35 // LoadProgress load progress 36 LoadProgress(progressID string) ([]byte, error) 37 38 // SaveProgress save progress 39 SaveProgress(progressID string, data []byte, perm fs.FileMode) error 40 41 // RemoveProgress remove progress 42 RemoveProgress(progressID string) error 43 44 // Create Directory 45 CreateDirectory(dirID string) error 46 47 // GetFileHandler 48 GetFileHandler(dirID, name string) (File, error) 49 50 // Remove all created directories(used in download directory) 51 RemoveAllDirectories() 52 } 53 54 type File interface { 55 Stat() (fs.FileInfo, error) 56 Read([]byte) (int, error) 57 Write(p []byte) (n int, err error) 58 59 Sync() error 60 Seek(offset int64, whence int) (ret int64, err error) 61 62 Close() error 63 }