]> wimlib.net Git - wimlib/blob - src/progress.c
Remove unnecessary argument to hlist iteration macros
[wimlib] / src / progress.c
1 /*
2  * progress.c
3  */
4
5 /*
6  * Copyright (C) 2014 Eric Biggers
7  *
8  * This file is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the Free
10  * Software Foundation; either version 3 of the License, or (at your option) any
11  * later version.
12  *
13  * This file is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this file; if not, see http://www.gnu.org/licenses/.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #  include "config.h"
24 #endif
25
26 #include <string.h>
27
28 #include "wimlib/progress.h"
29
30 int
31 report_error(wimlib_progress_func_t progfunc,
32              void *progctx, int error_code, const tchar *path)
33 {
34         int ret;
35         union wimlib_progress_info progress;
36
37         if (error_code == WIMLIB_ERR_SUCCESS ||
38             error_code == WIMLIB_ERR_ABORTED_BY_PROGRESS ||
39             error_code == WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS)
40                 return error_code;
41
42         progress.handle_error.path = path;
43         progress.handle_error.error_code = error_code;
44         progress.handle_error.will_ignore = false;
45
46 #ifdef __WIN32__
47         /* Hack for Windows...  */
48
49         wchar_t *p_question_mark = NULL;
50
51         if (!wcsncmp(path, L"\\??\\", 4)) {
52                 /* Trivial transformation:  NT namespace => Win32 namespace  */
53                 p_question_mark = (wchar_t *)&path[1];
54                 *p_question_mark = L'\\';
55         }
56 #endif
57
58         ret = call_progress(progfunc, WIMLIB_PROGRESS_MSG_HANDLE_ERROR,
59                             &progress, progctx);
60
61 #ifdef __WIN32__
62         if (p_question_mark)
63                 *p_question_mark = L'?';
64 #endif
65
66         if (ret)
67                 return ret;
68
69         if (!progress.handle_error.will_ignore)
70                 return error_code;
71
72         return 0;
73 }