refactor(cli): move compressed source exclusion to Rust

The Rust source-file scheduler already owns the ordering around source
exclusion, but its suffix policy and diagnostic still depended on a C table
and helper.  That left the policy leaf on the C side of the boundary and
made the Rust scheduler call back into a C-owned decision.

Move the complete 113-entry, case-sensitive suffix policy into the Rust CLI
file-I/O layer and export the exclusion callback through the existing C ABI.
The callback preserves leading dots, the stdin and NULL non-match behavior,
the 0/1 return policy, and the exact display-level-4 diagnostic while leaving
C resource, compression, and asynchronous callbacks unchanged.  Focused
checks cover representative suffixes, case sensitivity, stdin/NULL handling,
and the display gate.

Test Plan:
- `cc -fsyntax-only -Iprograms -Ilib -Ilib/common programs/fileio.c` -- passed
- Exact extracted C/Rust suffix-list comparison -- passed; all 113 entries match
- `git diff --check` and `git diff --cached --check` -- passed
- Rust unit tests and Cargo/Make/native suites were not run per request
- `rustfmt +nightly --check --edition 2021 rust/src/fileio_prefs.rs` -- not clean
  because it reports pre-existing formatting drift in unchanged code
This commit is contained in:
2026-07-20 15:56:53 +02:00
parent 499886116b
commit 882ad7ccef
2 changed files with 211 additions and 134 deletions
+5 -132
View File
@@ -1659,9 +1659,10 @@ typedef int (*FIO_rust_compress_src_compress_fn)(void* opaque,
typedef void (*FIO_rust_compress_src_close_fn)(void* opaque);
typedef void (*FIO_rust_compress_src_remove_fn)(void* opaque, const char* srcFileName);
/* Rust owns the source policy; this projection exposes only scalar names and
* opaque C callbacks. FIO_ctx_t, cRess_t, stat_t, and all resource/diagnostic
* state remain private to the callback context below. */
/* Rust owns the source policy and exclusion diagnostic; this projection
* exposes only scalar names and opaque callbacks for C-owned operations.
* FIO_ctx_t, cRess_t, stat_t, and all resource state remain private to the
* callback context below. */
typedef struct {
void* opaque;
const char* dstFileName;
@@ -1708,6 +1709,7 @@ typedef char FIO_rust_compress_src_projection_size[
+ 8 * sizeof(FIO_rust_compress_src_stat_fn)) ? 1 : -1];
int FIO_rust_compressFilenameSrcFile(
const FIO_rust_compress_src_projection_t* projection);
int FIO_rust_compressSourceIsExcluded(void* opaque, const char* srcFileName);
static void FIO_adjustParamsForPatchFromMode(FIO_prefs_t* const prefs,
ZSTD_compressionParameters* comprParams,
@@ -3158,126 +3160,6 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
return FIO_rust_compressFilenameDstFile(&projection);
}
/* List used to compare file extensions (used with --exclude-compressed flag)
* Different from the suffixList and should only apply to ZSTD compress operationResult
*/
static const char *compressedFileExtensions[] = {
ZSTD_EXTENSION,
TZSTD_EXTENSION,
GZ_EXTENSION,
TGZ_EXTENSION,
LZMA_EXTENSION,
XZ_EXTENSION,
TXZ_EXTENSION,
LZ4_EXTENSION,
TLZ4_EXTENSION,
".7z",
".aa3",
".aac",
".aar",
".ace",
".alac",
".ape",
".apk",
".apng",
".arc",
".archive",
".arj",
".ark",
".asf",
".avi",
".avif",
".ba",
".br",
".bz2",
".cab",
".cdx",
".chm",
".cr2",
".divx",
".dmg",
".dng",
".docm",
".docx",
".dotm",
".dotx",
".dsft",
".ear",
".eftx",
".emz",
".eot",
".epub",
".f4v",
".flac",
".flv",
".gho",
".gif",
".gifv",
".gnp",
".iso",
".jar",
".jpeg",
".jpg",
".jxl",
".lz",
".lzh",
".m4a",
".m4v",
".mkv",
".mov",
".mp2",
".mp3",
".mp4",
".mpa",
".mpc",
".mpe",
".mpeg",
".mpg",
".mpl",
".mpv",
".msi",
".odp",
".ods",
".odt",
".ogg",
".ogv",
".otp",
".ots",
".ott",
".pea",
".png",
".pptx",
".qt",
".rar",
".s7z",
".sfx",
".sit",
".sitx",
".sqx",
".svgz",
".swf",
".tbz2",
".tib",
".tlz",
".vob",
".war",
".webm",
".webp",
".wma",
".wmv",
".woff",
".woff2",
".wvl",
".xlsx",
".xpi",
".xps",
".zip",
".zipx",
".zoo",
".zpaq",
NULL
};
typedef struct {
FIO_ctx_t* fCtx;
FIO_prefs_t* prefs;
@@ -3311,15 +3193,6 @@ static int FIO_rust_compressSourceStat(void* opaque, const char* srcFileName)
return FIO_RUST_COMPRESS_SRC_STAT_OK;
}
static int FIO_rust_compressSourceIsExcluded(void* opaque, const char* srcFileName)
{
int const isCompressed = UTIL_isCompressedFile(srcFileName, compressedFileExtensions);
(void)opaque;
if (isCompressed)
DISPLAYLEVEL(4, "File is already compressed : %s \n", srcFileName);
return isCompressed;
}
static int FIO_rust_compressSourceOpen(void* opaque, const char* srcFileName,
U64* fileSize)
{