Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      File Primitives
         . . .
         Low-level File Primitives
         Directories
            Dired Subroutines
         Manipulating File Names
         . . .

Previous   Up    Next
Directories  Primitives and EEL Subroutines   Manipulating File Names


Epsilon User's Manual and Reference > Primitives and EEL Subroutines > File Primitives > Directories >

Dired Subroutines

int dired_one(char *files)    /* dired.e */
int create_dired_listing(char *files)
int make_dired(char *files)
int do_remote_dired(char *files)
int do_dired(char *files)
int is_dired_buf()      /* dired.e */

The dired_one( ) subroutine takes a file name pattern as its argument and acts just like the dired command does, making a dired buffer, filling it and putting it in dired mode. It puts its pattern in a standard form and chooses a suitable buffer name, then calls the create_dired_listing( ) subroutine. This function prepares the buffer and displays suitable messages, then calls make_dired( ).

The make_dired( ) subroutine handles FTP dired requests by calling do_remote_dired( ), and passes local dired requests to the do_dired( ) primitive to fill the buffer with directory information.

Each of these routines takes a file name with wildcard characters such as * and ?, and inserts in the current buffer exactly what the dired command does (see Directory Editing). Each returns 0 normally, and 1 if there were no matches.

By default, the do_dired( ) primitive ignores the abort key. To permit aborting a long file match, set the primitive variable abort_file_matching using save_var to tell Epsilon what to do when the user presses the abort key. See Listing Commands & Buffers & Files for details.

The is_dired_buf( ) subroutine returns 1 if the current buffer is a dired buffer, otherwise 0.

dired_standardize(char *files)
standardize_remote_pathname(char *files)
remote_dirname_absolute(char *dir)
drop_dots(char *path)

Sometimes there are several interchangeable ways to write a particular file pattern. For example, /dir1/dir2/* always makes the same list of files as /dir1/dir2/ or /dir1/dir2. The dired_standardize( ) primitive converts a dired pattern to its simplest form, in place. In the example, the last pattern is considered the simplest form.

The standardize_remote_pathname( ) subroutine is similar, but operates on FTP and SCP URLs. It calls several other subroutines to help.

The remote_dirname_absolute( ) subroutine converts a relative remote pathname to an absolute one in place. It performs an FTP or SCP operation to get the user's home directory, then inserts it into the given pathname.

The drop_dots( ) subroutine removes . and interprets .. in a pathname, modifying it in place. It removes any .. components at the start of a path.

detect_dired_format()
zeroed buffer char dired_format;
#define DF_UNIX     1
#define DF_SIMPLE   2
#define DF_OLDNT    3
#define DF_VMS      4
int get_dired_item(char *prefix, int func)

The dired command supports several different formats for directory listings. Besides the standard format it uses for local directory listings, as generated by the do_dired( ) primitive, it understands the directory listings generated by FTP servers that run on Unix systems (and the many servers on other operating systems that use the same format), as well as several others.

The detect_dired_format( ) subroutine determines the proper format by scanning a dired buffer, and sets the dired_format variable as appropriate. A value of 0 indicates the default, local directory format. The other values represent other formats.

Various subroutines in dired use the get_dired_item( ) subroutine to help locate format-specific functions or variables, to do tasks that depend on the particular format. The subroutine takes a prefix like "dired-isdir-" and looks for a function named dired_isdir_unix() (assuming the dired_format variable indicates Unix). It returns the name table index of the function it found, if there is one, or zero otherwise.

If its parameter func is nonzero, it looks only for functions; if zero, it looks only for variables. You can use an expression like (* (int (*)()) i)() to call the function (assuming i is the value returned by get_dired_item( )), or an expression like get_str_var(i) to get the value of a variable given its index.



Previous   Up    Next
Directories  Primitives and EEL Subroutines   Manipulating File Names


Lugaru Copyright (C) 1984, 2012 Lugaru Software Ltd. All Rights Reserved.