23 lines
1.3 KiB
C
23 lines
1.3 KiB
C
#pragma once
|
|
|
|
/**
|
|
* Removes multiple randomly selected segments from an input file and writes the remaining data to an output file.
|
|
*
|
|
* @param inputFileName The path to the input file to be processed.
|
|
* @param outputFileName The path to the output file to write the result.
|
|
* @param minSize The minimum size (in bytes) of each segment to remove.
|
|
* @param maxSize The maximum size (in bytes) of each segment to remove.
|
|
* @param counts The number of segments to remove.
|
|
* @return true if the operation succeeds; false otherwise.
|
|
*
|
|
* The function performs the following steps:
|
|
* 1. Validates input parameters and file names.
|
|
* 2. Opens the input file for reading and the output file for writing in binary mode.
|
|
* 3. Ensures the total size of all segments to be removed does not exceed the input file size.
|
|
* 4. Randomly selects 'counts' segments within the input file, each with a size between minSize and maxSize.
|
|
* 5. Copies unmodified data from the input file to the output file, skipping the selected segments.
|
|
* 6. Writes any remaining data after the last removed segment.
|
|
* 7. Returns true on success, or false if any error occurs during processing.
|
|
*/
|
|
bool randRemovePartOfFile(const char* inputFileName, const char* outputFileName, int64_t minSize, int64_t maxSize, int32_t counts);
|