grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dirent.c File Reference

DBMI Library (base) - directory entities management. More...

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <grass/dbmi.h>
#include <sys/types.h>
#include <dirent.h>
Include dependency graph for dirent.c:

Go to the source code of this file.


#define R_OK   4
#define W_OK   2
#define X_OK   1


typedef struct dirent dir_entry


DIR * opendir ()
dir_entryreaddir ()
static int cmp_dirent (const void *, const void *)
static int get_perm (char *)
static void sort_dirent (dbDirent *, int)
dbDirentdb_dirent (const char *dirname, int *n)
 Read directory and build an array of dbDirent's. More...
void db_free_dirent_array (dbDirent *dirent, int count)
 Free dbDirent. More...
dbDirentdb_alloc_dirent_array (int count)
 Allocate dirent array. More...

Detailed Description

DBMI Library (base) - directory entities management.

(C) 1999-2010 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Joel Jones (CERL/UIUC)
Upgraded to GRASS 5.7 by Radim Blazek

Definition in file dirent.c.

Macro Definition Documentation

◆ R_OK

#define R_OK   4

Definition at line 20 of file dirent.c.

◆ W_OK

#define W_OK   2

Definition at line 21 of file dirent.c.

◆ X_OK

#define X_OK   1

Definition at line 22 of file dirent.c.

Typedef Documentation

◆ dir_entry

typedef struct dirent dir_entry

Definition at line 30 of file dirent.c.

Function Documentation

◆ cmp_dirent()

static int cmp_dirent ( const void *  aa,
const void *  bb 

Definition at line 144 of file dirent.c.

References a, b, and db_get_string().

Referenced by sort_dirent().

◆ db_alloc_dirent_array()

dbDirent * db_alloc_dirent_array ( int  count)

Allocate dirent array.

countnumber of entities in the array
pointer to dbDirent array
NULL on failure

Definition at line 166 of file dirent.c.

References count, db_calloc(), db_init_string(), name, and NULL.

Referenced by db_dirent().

◆ db_dirent()

dbDirent * db_dirent ( const char *  dirname,
int *  n 

Read directory and build an array of dbDirent's.

Append one entry with name = NULL to mark end of array

dirnamedirectory name
[out]nnumber of entities
pointer to dbDirent
NULL on error

Definition at line 51 of file dirent.c.

References count, db_alloc_dirent_array(), db_clear_error(), db_free(), db_isdir(), db_malloc(), DB_OK, db_set_string(), db_syserror(), get_perm(), _db_dirent::isdir, max, name, NULL, opendir(), path, _db_dirent::perm, readdir(), and sort_dirent().

◆ db_free_dirent_array()

void db_free_dirent_array ( dbDirent dirent,
int  count 

Free dbDirent.

direntpointer to dbDirent
countnumber of entities in the array

Definition at line 117 of file dirent.c.

References count, db_free(), db_free_string(), and name.

◆ get_perm()

static int get_perm ( char *  path)

Definition at line 128 of file dirent.c.

References DB_PERM_R, DB_PERM_W, DB_PERM_X, R_OK, W_OK, and X_OK.

Referenced by db_dirent().

◆ opendir()

◆ readdir()

◆ sort_dirent()

static void sort_dirent ( dbDirent a,
int  n 

Definition at line 153 of file dirent.c.

References a, and cmp_dirent().

Referenced by db_dirent().