$18 GRAYBYTE WORDPRESS FILE MANAGER $67

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/lib/golang/src/os/

HOME
Current File : /lib/golang/src/os//dir.go
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package os

import (
	"internal/bytealg"
	"internal/filepathlite"
	"io"
	"io/fs"
	"slices"
)

type readdirMode int

const (
	readdirName readdirMode = iota
	readdirDirEntry
	readdirFileInfo
)

// Readdir reads the contents of the directory associated with file and
// returns a slice of up to n [FileInfo] values, as would be returned
// by [Lstat], in directory order. Subsequent calls on the same file will yield
// further FileInfos.
//
// If n > 0, Readdir returns at most n FileInfo structures. In this case, if
// Readdir returns an empty slice, it will return a non-nil error
// explaining why. At the end of a directory, the error is [io.EOF].
//
// 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.
//
// Most clients are better served by the more efficient ReadDir method.
func (f *File) Readdir(n int) ([]FileInfo, error) {
	if f == nil {
		return nil, ErrInvalid
	}
	_, _, infos, err := f.readdir(n, readdirFileInfo)
	if infos == nil {
		// Readdir has historically always returned a non-nil empty slice, never nil,
		// even on error (except misuse with nil receiver above).
		// Keep it that way to avoid breaking overly sensitive callers.
		infos = []FileInfo{}
	}
	return infos, err
}

// Readdirnames reads the contents of the directory associated with file
// and returns a slice of up to n names of files in the directory,
// in directory order. Subsequent calls on the same file will yield
// further names.
//
// If n > 0, Readdirnames returns at most n names. In this case, if
// Readdirnames returns an empty slice, it will return a non-nil error
// explaining why. At the end of a directory, the error is [io.EOF].
//
// If n <= 0, Readdirnames returns all the names from the directory in
// a single slice. In this case, if Readdirnames 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, Readdirnames returns the names read until that point and
// a non-nil error.
func (f *File) Readdirnames(n int) (names []string, err error) {
	if f == nil {
		return nil, ErrInvalid
	}
	names, _, _, err = f.readdir(n, readdirName)
	if names == nil {
		// Readdirnames has historically always returned a non-nil empty slice, never nil,
		// even on error (except misuse with nil receiver above).
		// Keep it that way to avoid breaking overly sensitive callers.
		names = []string{}
	}
	return names, err
}

// A DirEntry is an entry read from a directory
// (using the [ReadDir] function or a [File.ReadDir] method).
type DirEntry = fs.DirEntry

// ReadDir reads the contents of the directory associated with the file f
// and returns a slice of [DirEntry] values in directory order.
// Subsequent calls on the same file will yield later DirEntry records in the directory.
//
// If n > 0, ReadDir returns at most n DirEntry records.
// In this case, if ReadDir returns an empty slice, it will return an error explaining why.
// At the end of a directory, the error is [io.EOF].
//
// If n <= 0, ReadDir returns all the DirEntry records remaining in the directory.
// When it succeeds, it returns a nil error (not io.EOF).
func (f *File) ReadDir(n int) ([]DirEntry, error) {
	if f == nil {
		return nil, ErrInvalid
	}
	_, dirents, _, err := f.readdir(n, readdirDirEntry)
	if dirents == nil {
		// Match Readdir and Readdirnames: don't return nil slices.
		dirents = []DirEntry{}
	}
	return dirents, err
}

// ReadDir reads the named directory,
// returning all its directory entries sorted by filename.
// If an error occurs reading the directory,
// ReadDir returns the entries it was able to read before the error,
// along with the error.
func ReadDir(name string) ([]DirEntry, error) {
	f, err := openDir(name)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	dirs, err := f.ReadDir(-1)
	slices.SortFunc(dirs, func(a, b DirEntry) int {
		return bytealg.CompareString(a.Name(), b.Name())
	})
	return dirs, err
}

// CopyFS copies the file system fsys into the directory dir,
// creating dir if necessary.
//
// Files are created with mode 0o666 plus any execute permissions
// from the source, and directories are created with mode 0o777
// (before umask).
//
// CopyFS will not overwrite existing files. If a file name in fsys
// already exists in the destination, CopyFS will return an error
// such that errors.Is(err, fs.ErrExist) will be true.
//
// Symbolic links in dir are followed.
//
// New files added to fsys (including if dir is a subdirectory of fsys)
// while CopyFS is running are not guaranteed to be copied.
//
// Copying stops at and returns the first error encountered.
func CopyFS(dir string, fsys fs.FS) error {
	return fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error {
		if err != nil {
			return err
		}

		fpath, err := filepathlite.Localize(path)
		if err != nil {
			return err
		}
		newPath := joinPath(dir, fpath)

		switch d.Type() {
		case ModeDir:
			return MkdirAll(newPath, 0777)
		case ModeSymlink:
			target, err := fs.ReadLink(fsys, path)
			if err != nil {
				return err
			}
			return Symlink(target, newPath)
		case 0:
			r, err := fsys.Open(path)
			if err != nil {
				return err
			}
			defer r.Close()
			info, err := r.Stat()
			if err != nil {
				return err
			}
			w, err := OpenFile(newPath, O_CREATE|O_EXCL|O_WRONLY, 0666|info.Mode()&0777)
			if err != nil {
				return err
			}

			if _, err := io.Copy(w, r); err != nil {
				w.Close()
				return &PathError{Op: "Copy", Path: newPath, Err: err}
			}
			return w.Close()
		default:
			return &PathError{Op: "CopyFS", Path: path, Err: ErrInvalid}
		}
	})
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.30 PM
root / root
0755
exec
--
16 Dec 2025 9.30 PM
root / root
0755
signal
--
16 Dec 2025 9.30 PM
root / root
0755
user
--
16 Dec 2025 9.30 PM
root / root
0755
dir.go
5.935 KB
4 Dec 2025 6.06 PM
root / root
0644
dir_darwin.go
3.498 KB
4 Dec 2025 6.06 PM
root / root
0644
dir_plan9.go
2.189 KB
4 Dec 2025 6.06 PM
root / root
0644
dir_unix.go
4.846 KB
4 Dec 2025 6.06 PM
root / root
0644
dir_windows.go
7.684 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_aix.go
0.741 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_dragonfly.go
1.279 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_freebsd.go
1.159 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_js.go
0.662 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_linux.go
1.184 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_netbsd.go
1.159 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_openbsd.go
1.159 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_solaris.go
0.741 KB
4 Dec 2025 6.06 PM
root / root
0644
dirent_wasip1.go
1.355 KB
4 Dec 2025 6.06 PM
root / root
0644
eloop_netbsd.go
0.496 KB
4 Dec 2025 6.06 PM
root / root
0644
eloop_other.go
0.646 KB
4 Dec 2025 6.06 PM
root / root
0644
env.go
3.854 KB
4 Dec 2025 6.06 PM
root / root
0644
error.go
4.796 KB
4 Dec 2025 6.06 PM
root / root
0644
error_errno.go
0.334 KB
4 Dec 2025 6.06 PM
root / root
0644
error_plan9.go
0.395 KB
4 Dec 2025 6.06 PM
root / root
0644
exec.go
11.473 KB
4 Dec 2025 6.06 PM
root / root
0644
exec_linux.go
0.263 KB
4 Dec 2025 6.06 PM
root / root
0644
exec_nohandle.go
0.296 KB
4 Dec 2025 6.06 PM
root / root
0644
exec_plan9.go
3.231 KB
4 Dec 2025 6.06 PM
root / root
0644
exec_posix.go
3.71 KB
4 Dec 2025 6.06 PM
root / root
0644
exec_unix.go
3.323 KB
4 Dec 2025 6.06 PM
root / root
0644
exec_windows.go
4.677 KB
4 Dec 2025 6.06 PM
root / root
0644
executable.go
0.758 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_darwin.go
0.659 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_dragonfly.go
0.362 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_freebsd.go
0.361 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_netbsd.go
0.364 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_path.go
2.309 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_plan9.go
0.417 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_procfs.go
0.643 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_solaris.go
0.739 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_sysctl.go
0.835 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_wasm.go
0.325 KB
4 Dec 2025 6.06 PM
root / root
0644
executable_windows.go
0.626 KB
4 Dec 2025 6.06 PM
root / root
0644
file.go
29.511 KB
4 Dec 2025 6.06 PM
root / root
0644
file_mutex_plan9.go
1.809 KB
4 Dec 2025 6.06 PM
root / root
0644
file_open_unix.go
0.388 KB
4 Dec 2025 6.06 PM
root / root
0644
file_open_wasip1.go
0.799 KB
4 Dec 2025 6.06 PM
root / root
0644
file_plan9.go
15.686 KB
4 Dec 2025 6.06 PM
root / root
0644
file_posix.go
7.47 KB
4 Dec 2025 6.06 PM
root / root
0644
file_unix.go
13.718 KB
4 Dec 2025 6.06 PM
root / root
0644
file_wasip1.go
0.618 KB
4 Dec 2025 6.06 PM
root / root
0644
file_windows.go
13.51 KB
4 Dec 2025 6.06 PM
root / root
0644
getwd.go
3.71 KB
4 Dec 2025 6.06 PM
root / root
0644
path.go
2.307 KB
4 Dec 2025 6.06 PM
root / root
0644
path_plan9.go
0.433 KB
4 Dec 2025 6.06 PM
root / root
0644
path_unix.go
1.155 KB
4 Dec 2025 6.06 PM
root / root
0644
path_windows.go
5.943 KB
4 Dec 2025 6.06 PM
root / root
0644
pidfd_linux.go
5.879 KB
4 Dec 2025 6.06 PM
root / root
0644
pidfd_other.go
0.662 KB
4 Dec 2025 6.06 PM
root / root
0644
pipe2_unix.go
0.639 KB
4 Dec 2025 6.06 PM
root / root
0644
pipe_unix.go
0.756 KB
4 Dec 2025 6.06 PM
root / root
0644
pipe_wasm.go
0.477 KB
4 Dec 2025 6.06 PM
root / root
0644
proc.go
2.272 KB
4 Dec 2025 6.06 PM
root / root
0644
rawconn.go
0.97 KB
4 Dec 2025 6.06 PM
root / root
0644
removeall_at.go
4.783 KB
4 Dec 2025 6.06 PM
root / root
0644
removeall_noat.go
3.145 KB
4 Dec 2025 6.06 PM
root / root
0644
removeall_unix.go
0.469 KB
4 Dec 2025 6.06 PM
root / root
0644
removeall_windows.go
0.383 KB
4 Dec 2025 6.06 PM
root / root
0644
root.go
13.48 KB
4 Dec 2025 6.06 PM
root / root
0644
root_js.go
2.602 KB
4 Dec 2025 6.06 PM
root / root
0644
root_nonwindows.go
0.275 KB
4 Dec 2025 6.06 PM
root / root
0644
root_noopenat.go
7.861 KB
4 Dec 2025 6.06 PM
root / root
0644
root_openat.go
11.419 KB
4 Dec 2025 6.06 PM
root / root
0644
root_plan9.go
0.485 KB
4 Dec 2025 6.06 PM
root / root
0644
root_unix.go
8.497 KB
4 Dec 2025 6.06 PM
root / root
0644
root_windows.go
12.229 KB
4 Dec 2025 6.06 PM
root / root
0644
stat.go
0.95 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_aix.go
1.211 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_darwin.go
1.122 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_dragonfly.go
1.096 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_freebsd.go
1.105 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_js.go
1.147 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_linux.go
1.096 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_netbsd.go
1.105 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_openbsd.go
1.096 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_plan9.go
2.375 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_solaris.go
1.337 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_unix.go
1.215 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_wasip1.go
1.241 KB
4 Dec 2025 6.06 PM
root / root
0644
stat_windows.go
5.356 KB
4 Dec 2025 6.06 PM
root / root
0644
sticky_bsd.go
0.415 KB
4 Dec 2025 6.06 PM
root / root
0644
sticky_notbsd.go
0.313 KB
4 Dec 2025 6.06 PM
root / root
0644
sys.go
0.287 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_aix.go
0.666 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_bsd.go
0.455 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_js.go
0.306 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_linux.go
1.045 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_plan9.go
0.442 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_solaris.go
0.259 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_unix.go
0.481 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_wasip1.go
0.302 KB
4 Dec 2025 6.06 PM
root / root
0644
sys_windows.go
0.854 KB
4 Dec 2025 6.06 PM
root / root
0644
tempfile.go
3.921 KB
4 Dec 2025 6.06 PM
root / root
0644
types.go
2.858 KB
4 Dec 2025 6.06 PM
root / root
0644
types_plan9.go
0.778 KB
4 Dec 2025 6.06 PM
root / root
0644
types_unix.go
0.758 KB
4 Dec 2025 6.06 PM
root / root
0644
types_windows.go
11.714 KB
4 Dec 2025 6.06 PM
root / root
0644
wait6_dragonfly.go
0.484 KB
4 Dec 2025 6.06 PM
root / root
0644
wait6_freebsd64.go
0.534 KB
4 Dec 2025 6.06 PM
root / root
0644
wait6_freebsd_386.go
0.531 KB
4 Dec 2025 6.06 PM
root / root
0644
wait6_freebsd_arm.go
0.536 KB
4 Dec 2025 6.06 PM
root / root
0644
wait6_netbsd.go
0.521 KB
4 Dec 2025 6.06 PM
root / root
0644
wait_unimp.go
0.812 KB
4 Dec 2025 6.06 PM
root / root
0644
wait_wait6.go
0.773 KB
4 Dec 2025 6.06 PM
root / root
0644
wait_waitid.go
1.033 KB
4 Dec 2025 6.06 PM
root / root
0644
zero_copy_freebsd.go
1.323 KB
4 Dec 2025 6.06 PM
root / root
0644
zero_copy_linux.go
3.755 KB
4 Dec 2025 6.06 PM
root / root
0644
zero_copy_posix.go
1.065 KB
4 Dec 2025 6.06 PM
root / root
0644
zero_copy_solaris.go
2.568 KB
4 Dec 2025 6.06 PM
root / root
0644
zero_copy_stub.go
0.42 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF