@@ -301,7 +301,10 @@ pub unsafe fn buffered_read_opt(
301
301
// buffered - if here, then it must be files.
302
302
if !buffer_ptr. is_null ( ) {
303
303
// Read
304
+ #[ cfg( unix) ]
304
305
let mut file = File :: from_raw_fd ( ctx. infd ) ;
306
+ #[ cfg( windows) ]
307
+ let mut file = File :: from_raw_handle ( ctx. infd as _ ) ;
305
308
let slice = slice:: from_raw_parts_mut ( buffer_ptr, bytes) ;
306
309
match file. read ( slice) {
307
310
Ok ( n) => i = n as isize ,
@@ -317,7 +320,10 @@ pub unsafe fn buffered_read_opt(
317
320
buffer_ptr = buffer_ptr. add ( i as usize ) ;
318
321
} else {
319
322
// Seek
323
+ #[ cfg( unix) ]
320
324
let mut file = File :: from_raw_fd ( ctx. infd ) ;
325
+ #[ cfg( windows) ]
326
+ let mut file = File :: from_raw_handle ( ctx. infd as _ ) ;
321
327
let mut op = file. stream_position ( ) . unwrap_or ( i64:: MAX as u64 ) as i64 ; // Get current pos
322
328
if op == i64:: MAX {
323
329
op = -1 ;
@@ -387,7 +393,10 @@ pub unsafe fn buffered_read_opt(
387
393
let i = if ccx_options. input_source == DataSource :: File
388
394
|| ccx_options. input_source == DataSource :: Stdin
389
395
{
396
+ #[ cfg( unix) ]
390
397
let mut file = File :: from_raw_fd ( ctx. infd ) ;
398
+ #[ cfg( windows) ]
399
+ let mut file = File :: from_raw_handle ( ctx. infd as _ ) ;
391
400
let slice = slice:: from_raw_parts_mut (
392
401
ctx. filebuffer . add ( keep as usize ) ,
393
402
FILEBUFFERSIZE - keep as usize ,
@@ -467,7 +476,10 @@ pub unsafe fn buffered_read_opt(
467
476
let mut buffer_ptr = buffer;
468
477
let mut i;
469
478
while bytes > 0 && ctx. infd != -1 {
479
+ #[ cfg( unix) ]
470
480
let mut file = File :: from_raw_fd ( ctx. infd ) ;
481
+ #[ cfg( windows) ]
482
+ let mut file = File :: from_raw_handle ( ctx. infd as _ ) ;
471
483
let slice = slice:: from_raw_parts_mut ( buffer_ptr, bytes) ;
472
484
i = file. read ( slice) . unwrap_or ( i64:: MAX as usize ) as isize ;
473
485
if i == i64:: MAX as usize as isize {
@@ -508,7 +520,10 @@ pub unsafe fn buffered_read_opt(
508
520
if terminate_asap != 0 {
509
521
break ;
510
522
}
523
+ #[ cfg( unix) ]
511
524
let mut file = File :: from_raw_fd ( ctx. infd ) ;
525
+ #[ cfg( windows) ]
526
+ let mut file = File :: from_raw_handle ( ctx. infd as _ ) ;
512
527
513
528
// Try to get current position and seek
514
529
let op_result = file. stream_position ( ) ; // Get current pos
@@ -789,16 +804,18 @@ pub unsafe fn buffered_skip(ctx: *mut CcxDemuxer, bytes: u32, ccx_options: &mut
789
804
#[ cfg( test) ]
790
805
mod tests {
791
806
use super :: * ;
807
+ use crate :: libccxr_exports:: demuxer:: copy_demuxer_from_rust_to_c;
792
808
use lib_ccxr:: common:: { Codec , StreamMode , StreamType } ;
793
809
use lib_ccxr:: util:: log:: { set_logger, CCExtractorLogger , DebugMessageMask , OutputTarget } ;
794
- use std:: ffi:: CString ;
795
- // use std::io::{Seek, SeekFrom, Write};
796
- use crate :: libccxr_exports:: demuxer:: copy_demuxer_from_rust_to_c;
797
810
use serial_test:: serial;
811
+ use std:: ffi:: CString ;
798
812
#[ cfg( feature = "sanity_check" ) ]
799
813
use std:: io:: Write ;
800
814
use std:: os:: raw:: { c_char, c_int, c_ulong, c_void} ;
815
+ #[ cfg( unix) ]
801
816
use std:: os:: unix:: io:: IntoRawFd ;
817
+ #[ cfg( windows) ]
818
+ use std:: os:: windows:: io:: IntoRawHandle ;
802
819
use std:: slice;
803
820
use std:: sync:: Once ;
804
821
#[ cfg( feature = "sanity_check" ) ]
0 commit comments