25 lines
1.3 KiB
C
25 lines
1.3 KiB
C
#pragma once
|
|
|
|
/**
|
|
* Modifies an input file by replacing multiple randomly selected segments with random data,
|
|
* and writes the result to an output file.
|
|
*
|
|
* @param inputFileName The path to the input file to be modified.
|
|
* @param outputFileName The path to the output file to write the modified content.
|
|
* @param minSize The minimum size (in bytes) of each random segment to be replaced.
|
|
* @param maxSize The maximum size (in bytes) of each random segment to be replaced.
|
|
* @param counts The number of random segments to modify.
|
|
* @return true if the operation succeeds; false otherwise.
|
|
*
|
|
* The function performs the following steps:
|
|
* 1. Validates input parameters and file names.
|
|
* 2. Ensures the total size of all segments does not exceed the input file size.
|
|
* 3. Randomly selects 'counts' segments within the input file, each with a size between minSize and maxSize.
|
|
* 4. Copies unmodified data from the input file to the output file, except for the selected segments.
|
|
* 5. For each selected segment, replaces its content with random data in the output file.
|
|
* 6. Writes the remaining data after the last segment.
|
|
* 7. Returns true on success, or false if any error occurs.
|
|
*/
|
|
bool randomModifyFile(const char* inputFileName, const char* outputFileName, int64_t minSize, int64_t maxSize, int32_t counts);
|
|
|