| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

load_dir_list

#include "sfldir.h"
NODE *
load_dir_list (
    const char *dir_name,
    const char *sort)

Synopsis

Loads and sorts the contents of a directory. Returns a NODE pointer to a linked list containing the directory entries. Each node is a FILEINFO structure (mapped onto a NODE structure for purposes of manipulating the linked list). You can ask for the directory list to be sorted in various ways; in this case subdirectory entries are always sorted first. To specify the sort order you pass a string consisting of one or more of these characters, which are then used in order:
n Sort by ascending name.
N Sort by descending name.
x Sort by ascending extension.
X Sort by descending extension.
t Sort by ascending time and date.
T Sort by descending time and date.
s Sort by ascending size.
S Sort by descending size.
If the sort string is NULL, no sort is carried out.

Source Code - (sfldir.c)

{
    NODE
        *file_list;                     /*  File list head                   */
    DIRST
        dir;
    Bool
        rc;
    int
        nbr_files = 0;

    file_list = mem_alloc (sizeof (NODE));
    if (!file_list)
        return (NULL);

    node_reset (file_list);             /*  Initialise file list             */

    /* Load directory                                                        */
    rc = open dir (&dir, dir_name);
    while (rc)
      {
        add dir list (file_list, &dir);
        nbr_files++;
        rc = read dir (&dir);
      }
    close dir (&dir);

    if (sort && nbr_files > 1)
        sort dir list (file_list, sort);
    return (file_list);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation