libarmutils  1.4
 All Data Structures Files Functions Variables Typedefs Enumerations 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 */