-/* Note: new code should use wimlib_extract_paths() instead of
- * wimlib_extract_files() if possible. */
-WIMLIBAPI int
-wimlib_extract_files(WIMStruct *wim, int image,
- const struct wimlib_extract_command *cmds, size_t num_cmds,
- int default_extract_flags,
- wimlib_progress_func_t progress_func)
-{
- int all_flags = 0;
- int link_flags;
- int ret;
-
- if (num_cmds == 0)
- return 0;
-
- default_extract_flags |= WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE;
-
- for (size_t i = 0; i < num_cmds; i++) {
- int cmd_flags = (cmds[i].extract_flags |
- default_extract_flags);
-
- if (cmd_flags & ~WIMLIB_EXTRACT_MASK_PUBLIC)
- return WIMLIB_ERR_INVALID_PARAM;
-
- int cmd_link_flags = (cmd_flags & (WIMLIB_EXTRACT_FLAG_SYMLINK |
- WIMLIB_EXTRACT_FLAG_HARDLINK));
- if (i == 0) {
- link_flags = cmd_link_flags;
- } else {
- if (cmd_link_flags != link_flags) {
- ERROR("The same symlink or hardlink extraction mode "
- "must be set on all extraction commands!");
- return WIMLIB_ERR_INVALID_PARAM;
- }
- }
- all_flags |= cmd_flags;
- }
- if (all_flags & WIMLIB_EXTRACT_FLAG_GLOB_PATHS) {
- ERROR("Glob paths not supported for wimlib_extract_files(). "
- "Use wimlib_extract_paths() instead.");
- return WIMLIB_ERR_INVALID_PARAM;
- }
-
- for (size_t i = 0; i < num_cmds; i++) {
- int extract_flags = (cmds[i].extract_flags |
- default_extract_flags);
- const tchar *target = cmds[i].fs_dest_path;
- const tchar *wim_source_path = cmds[i].wim_source_path;
-
- ret = do_wimlib_extract_paths(wim, image, target,
- &wim_source_path, 1,
- extract_flags | WIMLIB_EXTRACT_FLAG_FILEMODE,
- progress_func);
- if (ret)
- break;
- }
-
- clear_lte_extracted_file(wim, all_flags);
- return ret;
-}
-