Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File interface { // Name returns the name of the file as presented to Open. Name() string // Read reads up to len(b) bytes from the File. It returns the number of bytes // read and any error encountered. At end of file, Read returns 0, io.EOF. Read(p []byte) (int, error) // ReadAt reads len(b) bytes from the File starting at byte offset off. It // returns the number of bytes read and the error, if any. ReadAt always // returns a non-nil error when n < len(b). At end of file, that error is // io.EOF. ReadAt(b []byte, off int64) (n int, err error) // If n <= 0, Readdir returns all the FileInfo from the directory in a single // slice. In this case, if Readdir succeeds (reads all the way to the end of // the directory), it returns the slice and a nil error. If it encounters an // error before the end of the directory, Readdir returns the FileInfo read // until that point and a non-nil error. ReadDir(int) ([]fs.DirEntry, error) // Write writes len(b) bytes to the File. It returns the number of bytes // written and an error, if any. Write returns a non-nil error when // n != len(b). Write(p []byte) (int, error) // WriteAt writes len(b) bytes to the File starting at byte offset off. It // returns the number of bytes written and an error, if any. WriteAt returns // a non-nil error when n != len(b). WriteAt(b []byte, off int64) (n int, err error) // WriteString is like Write, but writes the contents of string s rather than // a slice of bytes. WriteString(s string) (n int, err error) // Stat returns the FileInfo structure describing file. If there is an error, // it will be of type *PathError. Stat() (fs.FileInfo, error) // Seek sets the offset for the next Read or Write on file to offset, // interpreted according to whence: 0 means relative to the origin of the // file, 1 means relative to the current offset, and 2 means relative to the // end. It returns the new offset and an error, if any. The behavior of Seek // on a file opened with O_APPEND is not specified. Seek(offset int64, whence int) (ret int64, err error) // Sync commits the current contents of the file to stable storage. Typically, // this means flushing the file system's in-memory copy of recently written // data to disk. Sync() error // Truncate changes the size of the file. It does not change the I/O offset. // If there is an error, it will be of type *fs.PathError. Truncate(size int64) error // Close closes the File, rendering it unusable for I/O. It returns an error, // if any. Close() error }
type FileSystem ¶
type FileSystem interface { FS() fs.FS // Open opens the named file for reading. If successful, methods on the returned // file can be used for reading; the associated file descriptor has mode O_RDONLY. // If there is an error, it will be of type *fs.PathError. Open(name string) (File, error) // OpenFile is the generalized open call; most users will use Open or // Create instead. It opens the named file with specified flag (os.O_RDONLY etc.). // If the file does not exist, and the os.O_CREATE flag is passed, it is created // with mode perm (before umask). If successful, methods on the returned File // can be used for I/O. If there is an error, it will be of type *fs.PathError. OpenFile(name string, flag int, perm fs.FileMode) (File, error) // Create creates or truncates the named file. If the file already exists, // it is truncated. If the file does not exist, it is created with mode 0666 // (before umask). If successful, methods on the returned File can be used for // I/O; the associated file descriptor has mode os.O_RDWR. If there is an error, // it will be of type *fs.PathError. Create(name string) (File, error) // ReadFile reads the named file and returns its contents. // A successful call returns a nil error, not io.EOF. // (Because ReadFile reads the whole file, the expected EOF // from the final Read is not treated as an error to be reported.) ReadFile(name string) ([]byte, error) // ReadDir reads the named directory // and returns a list of directory entries sorted by filename. ReadDir(name string) ([]fs.DirEntry, error) // WriteFile writes data to the named file, creating it if necessary. If the // file does not exist, WriteFile creates it with permissions perm (before umask); // otherwise WriteFile truncates it before writing, without changing permissions. WriteFile(name string, data []byte, perm fs.FileMode) error // Mkdir creates a new directory with the specified name and permission bits // (before umask). If there is an error, it will be of type *fs.PathError. Mkdir(name string, perm fs.FileMode) error // MkdirAll creates a directory named path, along with any necessary parents, // and returns nil, or else returns an error. The permission bits perm (before umask) // are used for all directories that MkdirAll creates. If path is already a // directory, MkdirAll does nothing and returns nil. MkdirAll(name string, perm fs.FileMode) error // Stat returns the FileInfo structure describing file. If there is an error, // it will be of type *fs.PathError. Stat(name string) (fs.FileInfo, error) // Lstat returns a FileInfo describing the named file. // If the file is a symbolic link, the returned FileInfo // describes the symbolic link. Lstat makes no attempt to follow the link. // If there is an error, it will be of type *fs.PathError. Lstat(name string) (fs.FileInfo, error) // Rename renames (moves) oldpath to newpath. If newpath already exists and // is not a directory, Rename replaces it. OS-specific restrictions may apply // when oldpath and newpath are in different directories. If there is an // error, it will be of type *os.LinkError. Rename(oldpath, newpath string) error // Remove removes the named file or (empty) directory. If there is an error, // it will be of type *fs.PathError. Remove(name string) error // RemoveAll removes path and any children it contains. It removes everything // it can but returns the first error it encounters. If the path does not exist, // RemoveAll returns nil (no error). If there is an error, it will be of type // *fs.PathError. RemoveAll(path string) error // Truncate changes the size of the named file. If the file is a symbolic link, // it changes the size of the link's target. If there is an error, it will be // of type *fs.PathError. Truncate(name string, size int64) error // WalkDir walks the file tree rooted at root, calling fn for each file or directory // in the tree, including root. All errors that arise visiting files and directories // are filtered by fn: see the fs.WalkDirFunc documentation for details. The files may // or may not be walked in lexical order. WalkDir(root string, fn fs.WalkDirFunc) error // Abs returns an absolute representation of path. // If the path is not absolute it will be joined with the current // working directory to turn it into an absolute path. The absolute // path name for a given file is not guaranteed to be unique. // Abs calls pandorasbox.Clean on the result. Abs(path string) (string, error) Separator() uint8 ListSeparator() uint8 // Chdir changes the current working directory to the named directory. // If there is an error, it will be of type *fs.PathError. Chdir(dir string) error // Getwd returns a rooted path name corresponding to the // current directory. If the current directory can be // reached via multiple paths (due to symbolic links), // Getwd may return any one of them. Getwd() (dir string, err error) // TempDir returns the default directory to use for temporary files. // The directory is neither guaranteed to exist nor have accessible // permissions. TempDir() string }
Click to show internal directories.
Click to hide internal directories.