]> wimlib.net Git - wimlib/blob - src/pathlist.c
c366ed7f370c45e45ea11093875d322026a2a1fa
[wimlib] / src / pathlist.c
1 /*
2  * pathlist.c
3  *
4  * Utility function for reading path list files.
5  */
6
7 /*
8  * Copyright (C) 2013 Eric Biggers
9  *
10  * This file is part of wimlib, a library for working with WIM files.
11  *
12  * wimlib is free software; you can redistribute it and/or modify it under the
13  * terms of the GNU General Public License as published by the Free
14  * Software Foundation; either version 3 of the License, or (at your option)
15  * any later version.
16  *
17  * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19  * A PARTICULAR PURPOSE. See the GNU General Public License for more
20  * details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with wimlib; if not, see http://www.gnu.org/licenses/.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #  include "config.h"
28 #endif
29
30 #include "wimlib/pathlist.h"
31 #include "wimlib/textfile.h"
32
33 int
34 read_path_list_file(const tchar *listfile,
35                     tchar ***paths_ret, size_t *num_paths_ret,
36                     void **mem_ret)
37 {
38         STRING_SET(paths);
39         struct text_file_section tmp = {
40                 .name = T(""),
41                 .strings = &paths,
42         };
43         tchar *buf;
44         int ret;
45
46         ret = load_text_file(listfile, &buf, &tmp, 1, NULL);
47         if (ret)
48                 return ret;
49
50         *paths_ret = paths.strings;
51         *num_paths_ret = paths.num_strings;
52         *mem_ret = (void *)buf;
53         return 0;
54 }