feat(cli): move dictionary stat leaf to Rust
Move dictionary-path statting behind the existing Rust CLI file-I/O backend while keeping FIO_getDictFileStat as the C policy adapter. The adapter still owns the NULL-path early return, errno-based EXM_THROW(31) diagnostic, EXM_THROW(32) regular-file policy, and all dictionary orchestration. FIO_rust_getDictFileStat crosses only the existing path and stat_t boundary, delegates metadata and regular-file classification to UTIL_stat and UTIL_isRegularFileStat, and returns 0/1/2 for success, stat failure, or non-regular input. Reusing those ABIs preserves the C stat_t representation, errno behavior, and stat's symlink-following semantics. Focused backend tests cover regular, missing, directory, NULL, and symlink paths. Test Plan: - cargo test --manifest-path rust/cli/Cargo.toml --no-default-features --features cli,compression,decompression --lib fileio_backend (15 passed) - cargo clippy --no-default-features --features compression, including --benches and --tests (passed) - CLI cargo clippy with cli,compression,decompression,benchmark, including --benches and --tests (passed) - cargo +nightly fmt checks for the owned Rust module and CLI crate (passed); root-wide check remains limited by unrelated dict_builder_zdict.rs edits - Existing CLI dictionary scenarios for missing and directory paths retained status 31/32 and exact diagnostics - git diff --check and git diff --cached --check (passed) - zstd build variants were attempted; full links remain blocked by unrelated active dict-builder/zstd-cli/archive edits after the owned C file compiled
This commit is contained in:
+13
-2
@@ -350,6 +350,7 @@ const char* FIO_rust_determineDstName(const char* srcFileName, const char* outDi
|
||||
int FIO_rust_adjustMemLimitForPatchFromMode(FIO_prefs_t* prefs,
|
||||
unsigned long long dictSize,
|
||||
unsigned long long maxSrcFileSize);
|
||||
int FIO_rust_getDictFileStat(const char* fileName, stat_t* statBuf);
|
||||
int FIO_rust_setDictBufferMalloc(const char* fileName,
|
||||
unsigned long long expectedFileSize,
|
||||
size_t maxSize,
|
||||
@@ -543,16 +544,26 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
|
||||
/* FIO_getDictFileStat() :
|
||||
*/
|
||||
static void FIO_getDictFileStat(const char* fileName, stat_t* dictFileStat) {
|
||||
enum {
|
||||
FIO_DICT_STAT_SUCCESS = 0,
|
||||
FIO_DICT_STAT_FAILED = 1,
|
||||
FIO_DICT_STAT_NON_REGULAR = 2,
|
||||
};
|
||||
int status;
|
||||
|
||||
assert(dictFileStat != NULL);
|
||||
if (fileName == NULL) return;
|
||||
|
||||
if (!UTIL_stat(fileName, dictFileStat)) {
|
||||
status = FIO_rust_getDictFileStat(fileName, dictFileStat);
|
||||
if (status == FIO_DICT_STAT_FAILED) {
|
||||
EXM_THROW(31, "Stat failed on dictionary file %s: %s", fileName, strerror(errno));
|
||||
}
|
||||
|
||||
if (!UTIL_isRegularFileStat(dictFileStat)) {
|
||||
if (status == FIO_DICT_STAT_NON_REGULAR) {
|
||||
EXM_THROW(32, "Dictionary %s must be a regular file.", fileName);
|
||||
}
|
||||
|
||||
assert(status == FIO_DICT_STAT_SUCCESS);
|
||||
}
|
||||
|
||||
/* FIO_setDictBufferMalloc() :
|
||||
|
||||
Reference in New Issue
Block a user