File tree 2 files changed +14
-11
lines changed
2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -487,7 +487,8 @@ static int Get_File_Info(REBREQ *file)
487
487
{
488
488
ssize_t num_bytes ;
489
489
struct stat info ;
490
-
490
+ file -> actual = 0 ;
491
+
491
492
if (!file -> id ) {
492
493
file -> error = - RFE_NO_HANDLE ;
493
494
return DR_ERROR ;
@@ -505,17 +506,17 @@ static int Get_File_Info(REBREQ *file)
505
506
if (ftruncate (file -> id , file -> file .index )) return DR_ERROR ;
506
507
}
507
508
508
- if (file -> length == 0 ) return DR_DONE ;
509
-
510
- num_bytes = write (file -> id , file -> data , file -> length );
511
- if (num_bytes < 0 ) {
512
- if (errno == ENOSPC ) file -> error = - RFE_DISK_FULL ;
513
- else file -> error = - RFE_BAD_WRITE ;
514
- return DR_ERROR ;
515
- } else {
516
- //SET_FLAG(file->modes, RFM_RESEEK);
517
- file -> actual = (u32 )num_bytes ;
509
+ if (file -> length > 0 ) {
510
+ num_bytes = write (file -> id , file -> data , file -> length );
511
+ if (num_bytes < 0 ) {
512
+ if (errno == ENOSPC ) file -> error = - RFE_DISK_FULL ;
513
+ else file -> error = - RFE_BAD_WRITE ;
514
+ return DR_ERROR ;
515
+ } else {
516
+ file -> actual = (u32 )num_bytes ;
517
+ }
518
518
}
519
+ // update new file info
519
520
if (fstat (file -> id , & info ) == 0 ) {
520
521
file -> file .size = info .st_size ;
521
522
file -> file .time .l = (i32 )(info .st_mtime );
Original file line number Diff line number Diff line change @@ -365,10 +365,12 @@ if system/platform = 'Windows [
365
365
file? write %file-812 "Hello World!"
366
366
port? f: open %file-812
367
367
"Hello World!" = read /string f
368
+ 13 = index? f
368
369
port? clear f ; this actually does not clear the file as we are at the end of the stream
369
370
0 = length? f
370
371
12 = size? f
371
372
"Hello" = read /seek/string/part f 0 5
373
+ 6 = index? f
372
374
7 = length? f
373
375
12 = size? f
374
376
port? clear f ; this should truncate the file
You can’t perform that action at this time.
0 commit comments