1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (dir_list.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __LIBRETRO_SDK_DIR_LIST_H
24 #define __LIBRETRO_SDK_DIR_LIST_H
26 #include <retro_common_api.h>
29 #include <lists/string_list.h>
35 * @list : existing list to append to.
36 * @dir : directory path.
37 * @ext : allowed extensions of file directory entries to include.
38 * @include_dirs : include directories as part of the finished directory listing?
39 * @include_hidden : include hidden files and directories as part of the finished directory listing?
40 * @include_compressed : Only include files which match ext. Do not try to match compressed files, etc.
41 * @recursive : list directory contents recursively
43 * Create a directory listing, appending to an existing list
45 * @return Returns true on success, otherwise false.
47 bool dir_list_append(struct string_list *list, const char *dir, const char *ext,
48 bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
52 * @dir : directory path.
53 * @ext : allowed extensions of file directory entries to include.
54 * @include_dirs : include directories as part of the finished directory listing?
55 * @include_hidden : include hidden files and directories as part of the finished directory listing?
56 * @include_compressed : include compressed files, even when not part of ext.
57 * @recursive : list directory contents recursively
59 * Create a directory listing.
61 * @return pointer to a directory listing of type 'struct string_list *' on success,
62 * NULL in case of error. Has to be freed manually.
64 struct string_list *dir_list_new(const char *dir, const char *ext,
65 bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
68 * dir_list_initialize:
70 * NOTE: @list must zero initialised before
71 * calling this function, otherwise UB.
73 bool dir_list_initialize(struct string_list *list,
75 const char *ext, bool include_dirs,
76 bool include_hidden, bool include_compressed,
81 * @list : pointer to the directory listing.
82 * @dir_first : move the directories in the listing to the top?
84 * Sorts a directory listing.
86 void dir_list_sort(struct string_list *list, bool dir_first);
90 * @list : pointer to the directory listing
92 * Frees a directory listing.
94 void dir_list_free(struct string_list *list);
96 bool dir_list_deinitialize(struct string_list *list);