refactor(cli): expose filename and buffer leaves from Rust

Move the pure filename-collision, input/output-buffer construction, and
compressed-destination-name helpers to direct Rust-owned caller symbols.
Leave C responsible for diagnostics, filesystem resources, suffix-list policy,
and the surrounding file-processing orchestration.

Test Plan: Pending capped full verification after this atomic ABI cleanup.
This commit is contained in:
2026-07-20 11:01:05 +02:00
parent 03ac61063d
commit c750a91cff
2 changed files with 20 additions and 50 deletions
+12 -12
View File
@@ -1844,7 +1844,7 @@ pub unsafe extern "C" fn FIO_getLargestFileSize(
/// The pointer form avoids relying on a cross-language struct return ABI while
/// retaining the public `ZSTD_inBuffer` field order and values.
#[no_mangle]
pub unsafe extern "C" fn FIO_rust_setInBuffer(
pub unsafe extern "C" fn FIO_setInBuffer(
output: *mut FIO_inBuffer,
buf: *const c_void,
size: usize,
@@ -1861,7 +1861,7 @@ pub unsafe extern "C" fn FIO_rust_setInBuffer(
/// Fill a C-compatible output buffer through an output pointer.
#[no_mangle]
pub unsafe extern "C" fn FIO_rust_setOutBuffer(
pub unsafe extern "C" fn FIO_setOutBuffer(
output: *mut FIO_outBuffer,
buf: *mut c_void,
size: usize,
@@ -2023,7 +2023,7 @@ pub extern "C" fn FIO_LZ4_GetBlockSize_FromBlockId(id: c_int) -> c_int {
/// not thread-safe. The output-directory basename construction is shared
/// with `UTIL_createFilenameFromOutDir`, while suffix assembly remains here.
#[no_mangle]
pub unsafe extern "C" fn FIO_rust_determineCompressedName(
pub unsafe extern "C" fn FIO_determineCompressedName(
src_file_name: *const c_char,
out_dir_name: *const c_char,
suffix: *const c_char,
@@ -2256,7 +2256,7 @@ fn display_filename_collision_warning(filename: *const c_char) {
/// Rust implementation of the filename collision checker used by
/// `FIO_checkFilenameCollisions` in `programs/fileio.c`.
#[no_mangle]
pub unsafe extern "C" fn FIO_rust_checkFilenameCollisions(
pub unsafe extern "C" fn FIO_checkFilenameCollisions(
filename_table: *const *const c_char,
nb_files: c_uint,
) -> c_int {
@@ -3242,13 +3242,13 @@ mod tests {
};
unsafe {
FIO_rust_setInBuffer(
FIO_setInBuffer(
&mut input,
source.as_ptr().cast::<c_void>(),
source.len(),
1,
);
FIO_rust_setOutBuffer(
FIO_setOutBuffer(
&mut output,
destination.as_mut_ptr().cast::<c_void>(),
destination.len(),
@@ -3693,10 +3693,10 @@ mod tests {
unsafe {
let name =
FIO_rust_determineCompressedName(source.as_ptr(), ptr::null(), suffix.as_ptr());
FIO_determineCompressedName(source.as_ptr(), ptr::null(), suffix.as_ptr());
assert_eq!(CStr::from_ptr(name).to_bytes(), b"input/nested/file.zst");
let name = FIO_rust_determineCompressedName(
let name = FIO_determineCompressedName(
source.as_ptr(),
output_dir.as_ptr(),
suffix.as_ptr(),
@@ -3705,7 +3705,7 @@ mod tests {
let stdin = CString::new("/*stdin*\\").unwrap();
let name =
FIO_rust_determineCompressedName(stdin.as_ptr(), ptr::null(), suffix.as_ptr());
FIO_determineCompressedName(stdin.as_ptr(), ptr::null(), suffix.as_ptr());
assert_eq!(CStr::from_ptr(name).to_bytes(), b"/*stdout*\\");
}
}
@@ -3825,8 +3825,8 @@ mod tests {
let names = [ptr::null(), empty.as_ptr()];
unsafe {
assert_eq!(FIO_rust_checkFilenameCollisions(ptr::null(), 0), 0);
assert_eq!(FIO_rust_checkFilenameCollisions(names.as_ptr(), 2), 0);
assert_eq!(FIO_checkFilenameCollisions(ptr::null(), 0), 0);
assert_eq!(FIO_checkFilenameCollisions(names.as_ptr(), 2), 0);
assert!(same_filename_collision_key(ptr::null(), empty.as_ptr()));
}
}
@@ -3848,7 +3848,7 @@ mod tests {
first.as_ptr(),
different.as_ptr()
));
assert_eq!(FIO_rust_checkFilenameCollisions(names.as_ptr(), 2), 0);
assert_eq!(FIO_checkFilenameCollisions(names.as_ptr(), 2), 0);
}
}