[Top] [Prev] [Next]

readdir

readdir - read directory and sort files

Synopsis

include "lib.m";
readdir:= load Readdir Readdir->PATH;
NAME, ATIME, MTIME, SIZE, NONE: con iota;
DESCENDING         : con (1<<5);
init: fn(path: string, sortkey: int): (array of ref Dir, int);

Description

The Readdir module reads the contents of the directory path and sorts the resulting array according to sortkey.

Each element in the returned array is a reference to one Dir element in the array formed by the dirread system call. Readdir also returns the number of entries read, or -1 on failure.

The sorting criteria for the returned array are based on sortkey as follows:
Readdir->NAME

Sort files alphabetically by name.

Readdir->ATIME

Sort files by access time, most recently accessed first.

Readdir->MTIME

Sort files by modification time, most recently modified first.

Readdir->SIZE

Sort files by size, largest file first.

Readdir->NONE

Files are left in directory order, unsorted.

If the value Readdir->DESCENDING is OR'ed into any of the above values (except Readdir->NONE) the order of sorting is reversed.

See Also

read



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.