updating oE dir


include filesys.e 
namespace filesys 
public function dir(sequence name) 

returns directory information for the specified file or directory.

  1. name : a sequence, the name to be looked up in the file system.

An object, -1 if no match found, else a sequence of sequence entries


The length of name should not exceed 1_024 characters.


name can also contain * and ? wildcards to select multiple files.

The returned information is similar to what you would get from the DIR command. A sequence is returned where each element is a sequence that describes one file or subdirectory.

If name refers to a directory you may have entries for "." and "..", just as with the DIR command. If it refers to an existing file, and has no wildcards, then the returned sequence will have just one entry (that is its length will be 1). If name contains wildcards you may have multiple entries.

Each entry contains the name, attributes and file size as well as the time of the last modification.

You can refer to the elements of an entry with the following constants:

public constant  
    -- File Attributes 
    D_NAME       = 1, 
    D_ATTRIBUTES = 2, 
    D_SIZE       = 3, 
    D_YEAR       = 4, 
    D_MONTH      = 5, 
    D_DAY        = 6, 
    D_HOUR       = 7, 
    D_MINUTE     = 8, 
    D_SECOND     = 9, 
    D_MILLISECOND = 10, 
    D_ALTNAME    = 11 

The attributes element is a string sequence containing characters chosen from:

Attribute Description
'd' directory
'r' read only file
'h' hidden file
's' system file
'v' volume-id entry
'a' archive file
'c' compressed file
'e' encrypted file
'N' not indexed
'D' a device name
'O' offline
'R' reparse point or symbolic link
'S' sparse file
'T' temporary file
'V' virtual file

A normal file without special attributes would just have an empty string, "", in this field.

The top level directory ( therefore c:\ does not have "." or ".." entries).

This function is often used just to test if a file or directory exists.

Under Windows, the argument can have a long file or directory name anywhere in the path.

Under Unix, the only attribute currently available is 'd' and the milliseconds are always zero.

Windows: The file name returned in [D_NAME] will be a long file name. If [D_ALTNAME] is not zero, it contains the 'short' name of the file.

Example 1:
d = dir(current_dir()) 
-- d might have: 
--  { 
--    {".",    "d",     0  1994, 1, 18,  9, 30, 02}, 
--    {"..",   "d",     0  1994, 1, 18,  9, 20, 14}, 
--    {"fred", "ra", 2350, 1994, 1, 22, 17, 22, 40}, 
--    {"sub",  "d" ,    0, 1993, 9, 20,  8, 50, 12} 
--  } 
d[3][D_NAME] would be "fred" 
See Also:


Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu