const _UTIME_OMIT … // fixLongPath is a noop on non-Windows platforms. func fixLongPath(path string) string { … } func rename(oldname, newname string) error { … } type file … // Fd returns the integer Unix file descriptor referencing the open file. // If f is closed, the file descriptor becomes invalid. // If f is garbage collected, a finalizer may close the file descriptor, // making it invalid; see [runtime.SetFinalizer] for more information on when // a finalizer might be run. On Unix systems this will cause the [File.SetDeadline] // methods to stop working. // Because file descriptors can be reused, the returned file descriptor may // only be closed through the [File.Close] method of f, or by its finalizer during // garbage collection. Otherwise, during garbage collection the finalizer // may close an unrelated file descriptor with the same (reused) number. // // As an alternative, see the f.SyscallConn method. func (f *File) Fd() uintptr { … } // NewFile returns a new File with the given file descriptor and // name. The returned value will be nil if fd is not a valid file // descriptor. On Unix systems, if the file descriptor is in // non-blocking mode, NewFile will attempt to return a pollable File // (one for which the SetDeadline methods work). // // After passing it to NewFile, fd may become invalid under the same // conditions described in the comments of the Fd method, and the same // constraints apply. func NewFile(fd uintptr, name string) *File { … } // net_newUnixFile is a hidden entry point called by net.conn.File. // This is used so that a nonblocking network connection will become // blocking if code calls the Fd method. We don't want that for direct // calls to NewFile: passing a nonblocking descriptor to NewFile should // remain nonblocking if you get it back using Fd. But for net.conn.File // the call to NewFile is hidden from the user. Historically in that case // the Fd method has returned a blocking descriptor, and we want to // retain that behavior because existing code expects it and depends on it. // //go:linkname net_newUnixFile net.newUnixFile func net_newUnixFile(fd int, name string) *File { … } type newFileKind … const kindNewFile … const kindOpenFile … const kindPipe … const kindSock … const kindNoPoll … // newFile is like NewFile, but if called from OpenFile or Pipe // (as passed in the kind parameter) it tries to add the file to // the runtime poller. func newFile(fd int, name string, kind newFileKind, nonBlocking bool) *File { … } func sigpipe() // epipecheck raises SIGPIPE if we get an EPIPE error on standard // output or standard error. See the SIGPIPE docs in os/signal, and // issue 11845. func epipecheck(file *File, e error) { … } const DevNull … // openFileNolog is the Unix implementation of OpenFile. // Changes here should be reflected in openDirAt and openDirNolog, if relevant. func openFileNolog(name string, flag int, perm FileMode) (*File, error) { … } func openDirNolog(name string) (*File, error) { … } func (file *file) close() 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. func (f *File) seek(offset int64, whence int) (ret int64, err 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 *PathError. func Truncate(name string, size int64) error { … } // Remove removes the named file or (empty) directory. // If there is an error, it will be of type *PathError. func Remove(name string) error { … } func tempDir() string { … } // Link creates newname as a hard link to the oldname file. // If there is an error, it will be of type *LinkError. func Link(oldname, newname string) error { … } // Symlink creates newname as a symbolic link to oldname. // On Windows, a symlink to a non-existent oldname creates a file symlink; // if oldname is later created as a directory the symlink will not work. // If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { … } func readlink(name string) (string, error) { … } type unixDirent … func (d *unixDirent) Name() string { … } func (d *unixDirent) IsDir() bool { … } func (d *unixDirent) Type() FileMode { … } func (d *unixDirent) Info() (FileInfo, error) { … } func (d *unixDirent) String() string { … } func newUnixDirent(parent, name string, typ FileMode) (DirEntry, error) { … }