Files
dnf-utils/sgutil/sgu_mode_npk_extract_files.h
T
2025-09-01 20:47:58 +08:00

22 lines
921 B
C

#pragma once
/**
* Extracts all files from an NPK archive to a specified output directory.
*
* @param szNPKFileName The path to the NPK archive file to be extracted.
* @param szOutputDir The path to the output directory where files will be extracted.
* @return true if extraction succeeds; false otherwise.
*
* The function performs the following steps:
* 1. Validates the input parameters.
* 2. Creates or clears the output directory.
* 3. Opens the NPK archive and retrieves the file list.
* 4. For each file in the archive:
* - Ensures the output path exists.
* - Opens a stream to the file in the archive.
* - Creates the corresponding output file.
* - Copies the file data from the archive to the output file in chunks.
* 5. Closes all resources and returns true on success, or false if any error occurs.
*/
bool extractNPKFiles(const char* szNPKFileName, const char* szOutputDir);