libarmutils  1.14-0.el7
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dir_utils.h
Go to the documentation of this file.
1 /*******************************************************************************
2 *
3 * COPYRIGHT (C) 2010 Battelle Memorial Institute. All Rights Reserved.
4 *
5 ********************************************************************************
6 *
7 * Author:
8 * name: Brian Ermold
9 * phone: (509) 375-2277
10 * email: brian.ermold@pnl.gov
11 *
12 ********************************************************************************
13 *
14 * REPOSITORY INFORMATION:
15 * $Revision: 6421 $
16 * $Author: ermold $
17 * $Date: 2011-04-26 01:23:44 +0000 (Tue, 26 Apr 2011) $
18 *
19 ********************************************************************************
20 *
21 * NOTE: DOXYGEN is used to generate documentation for this file.
22 *
23 *******************************************************************************/
24 
25 /** @file dir_utils.h
26  * Directory Utilities
27  */
28 
29 #ifndef _DIR_UTILS_H
30 #define _DIR_UTILS_H
31 
32 #include "armutils/regex_utils.h"
33 
34 /**
35  * @defgroup ARMUTILS_DIR_UTILS Directory Utils
36  */
37 /*@{*/
38 
39 #define DL_SHOW_DOT_FILES 0x1 /**< include files starting with a '.' */
40 
41 /**
42  * Directory List.
43  */
44 typedef struct {
45 
46  char *path; /**< path to the directory */
47  int flags; /**< control flags */
48 
49  struct stat stats; /**< directory stats */
50 
51  REList *patterns; /**< list of file patterns to look for */
52 
53  int nalloced; /**< allocated length of the file list */
54  int nfiles; /**< number of files in the file list */
55  char **file_list; /**< list of files in the directory */
56 
57  /** function used by qsort to sort the file list */
58  int (*qsort_compare)(const void *, const void *);
59 
60 } DirList;
61 
62 /***** DirList functions and flags *****/
63 
65  const char *path,
66  int flags);
67 
68 void dirlist_free(DirList *dirlist);
69 
71  DirList *dirlist,
72  int npatterns,
73  const char **patterns,
74  int ignore_case);
75 
77  DirList *dirlist,
78  char ***file_list);
79 
81  DirList *dirlist,
82  int (*qsort_compare)(const void *, const void *));
83 
84 /***** Utility functions *****/
85 
86 int make_path(const char *path, mode_t mode);
87 
88 /*@}*/
89 
90 #endif /* _DIR_UTILS_H */
int nalloced
allocated length of the file list
Definition: dir_utils.h:53
int make_path(const char *path, mode_t mode)
Make the full path to a directory.
Definition: dir_utils.c:444
Regular Expression Utilities.
char * path
path to the directory
Definition: dir_utils.h:46
int dirlist_get_file_list(DirList *dirlist, char ***file_list)
Get the list of files in a directory.
Definition: dir_utils.c:210
void dirlist_set_qsort_compare(DirList *dirlist, int(*qsort_compare)(const void *, const void *))
Set the file name compare function.
Definition: dir_utils.c:421
char ** file_list
list of files in the directory
Definition: dir_utils.h:55
int dirlist_add_patterns(DirList *dirlist, int npatterns, const char **patterns, int ignore_case)
Add file patterns to a directory list.
Definition: dir_utils.c:152
Regular Expressions List.
Definition: regex_utils.h:40
int flags
control flags
Definition: dir_utils.h:47
DirList * dirlist_create(const char *path, int flags)
Create a new directory list.
Definition: dir_utils.c:86
void dirlist_free(DirList *dirlist)
Free all memory used by a directory list.
Definition: dir_utils.c:46
REList * patterns
list of file patterns to look for
Definition: dir_utils.h:51
int nfiles
number of files in the file list
Definition: dir_utils.h:54
Directory List.
Definition: dir_utils.h:44