stat
Retrieves information about a path.
Example
ts
import { SF } from "@duplojs/server-utils";
import { E, type ExpectType, unwrap } from "@duplojs/utils";
const result = await SF.stat("/tmp/file.txt");
// result: SF.FileSystemLeft | Success<SF.StatInfo>
if (E.isRight(result)) {
const fileInfo = unwrap(result);
type check = ExpectType<
typeof fileInfo,
SF.StatInfo,
"strict"
>;
}Syntax
typescript
function stat(
path: string | URL
): Promise<FileSystemLeft | E.Success<StatInfo>>Interface StatInfo
typescript
interface StatInfo {
isFile: boolean;
isDirectory: boolean;
isSymlink: boolean;
sizeBytes: number;
modifiedAt: D.TheDate | null;
accessedAt: D.TheDate | null;
createdAt: D.TheDate | null;
changedAt: D.TheDate | null;
deviceId: number;
inode: number | null;
permissionsMode: number | null;
hardLinkCount: number | null;
ownerUserId: number | null;
ownerGroupId: number | null;
specialDeviceId: number | null;
ioBlockSize: number | null;
allocatedBlockCount: number | null;
isBlockDevice: boolean | null;
isCharacterDevice: boolean | null;
isFifo: boolean | null;
isSocket: boolean | null;
}Parameters
path: path to inspect.
Return value
E.Success<StatInfo>: information about the path (type, size, dates, etc.).FileSystemLeft: if the read fails.
Notes
D.TheDateis the date type provided by@duplojs/utils.
See also
exists- Checks that a path exists.
