plibsys
pdir.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright (C) 2015-2016 Alexander Saprykin <saprykin.spb@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * 'Software'), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
47 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
48 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
49 #endif
50 
51 #ifndef PLIBSYS_HEADER_PDIR_H
52 #define PLIBSYS_HEADER_PDIR_H
53 
54 #include <pmacros.h>
55 #include <ptypes.h>
56 #include <perror.h>
57 
59 
61 typedef struct PDir_ PDir;
62 
64 typedef enum PDirEntryType_ {
69 
71 typedef struct PDirEntry_ {
72  char *name;
74 } PDirEntry;
75 
86 P_LIB_API PDir * p_dir_new (const pchar *path,
87  PError **error);
88 
100 P_LIB_API pboolean p_dir_create (const pchar *path,
101  pint mode,
102  PError **error);
103 
113 P_LIB_API pboolean p_dir_remove (const pchar *path,
114  PError **error);
115 
123 
133 P_LIB_API pchar * p_dir_get_path (const PDir *dir);
134 
149  PError **error);
150 
159  PError **error);
160 
166 P_LIB_API void p_dir_entry_free (PDirEntry *entry);
167 
173 P_LIB_API void p_dir_free (PDir *dir);
174 
176 
177 #endif /* PLIBSYS_HEADER_PDIR_H */
P_LIB_API void p_dir_entry_free(PDirEntry *entry)
Frees PDirEntry object.
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Definition: pmacros.h:299
P_LIB_API PDirEntry * p_dir_get_next_entry(PDir *dir, PError **error)
Gets the next directory entry info.
char * name
Name.
Definition: pdir.h:72
PDirEntryType_
Directory entry types.
Definition: pdir.h:64
int pint
Type for an int.
Definition: ptypes.h:120
char pchar
Type for a char.
Definition: ptypes.h:116
typedefP_BEGIN_DECLS struct PError_ PError
Opaque data structure for an error object.
Definition: perror.h:68
Miscellaneous macros.
Other.
Definition: pdir.h:67
P_LIB_API void p_dir_free(PDir *dir)
Frees PDir object.
signed int pboolean
Type for a bool.
Definition: ptypes.h:114
P_LIB_API pboolean p_dir_remove(const pchar *path, PError **error)
Removes an empty directory.
Error report system.
P_LIB_API PDir * p_dir_new(const pchar *path, PError **error)
Creates a new PDir object.
Directory.
Definition: pdir.h:65
P_LIB_API pboolean p_dir_rewind(PDir *dir, PError **error)
Resets a directory entry pointer.
#define P_LIB_API
Exports a symbol from a shared library.
Definition: pmacros.h:138
typedefP_BEGIN_DECLS struct PDir_ PDir
Directory opaque data structure.
Definition: pdir.h:61
File.
Definition: pdir.h:66
P_LIB_API pchar * p_dir_get_path(const PDir *dir)
Gets the original directory path used to create a PDir object.
P_LIB_API pboolean p_dir_is_exists(const pchar *path)
Checks whether a directory exists or not.
Structure with directory entry information.
Definition: pdir.h:71
Types definitions.
struct PDirEntry_ PDirEntry
Structure with directory entry information.
PDirEntryType type
Type.
Definition: pdir.h:73
P_LIB_API pboolean p_dir_create(const pchar *path, pint mode, PError **error)
Creates a new directory on a filesystem.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition: pmacros.h:298
enum PDirEntryType_ PDirEntryType
Directory entry types.