File tree 5 files changed +34
-6
lines changed
5 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 251
251
// !!! add recursive delete (?)
252
252
result = OS_DO_DEVICE (& dir , RDC_DELETE );
253
253
///OS_FREE(dir.file.path);
254
- if (result < 0 ) Trap1 (RE_NO_DELETE , path );
255
- return R_ARG2 ;
254
+ if (result >= 0 ) return R_ARG2 ;
255
+ if (result == -2 ) return R_FALSE ;
256
+ // else...
257
+ Trap1 (RE_NO_DELETE , path );
258
+ break ;
256
259
257
260
case A_OPEN :
258
261
// !! If open fails, what if user does a READ w/o checking for error?
Original file line number Diff line number Diff line change @@ -416,6 +416,7 @@ REBINT Mode_Syms[] = {
416
416
REBREQ * file = 0 ;
417
417
REBCNT args = 0 ;
418
418
REBCNT len ;
419
+ REBINT result ;
419
420
REBOOL opened = FALSE; // had to be opened (shortcut case)
420
421
421
422
//Print("FILE ACTION: %r", Get_Action_Word(action));
@@ -542,9 +543,13 @@ REBINT Mode_Syms[] = {
542
543
break ;
543
544
544
545
case A_DELETE :
545
- if (IS_OPEN (file )) Trap1 (RE_NO_DELETE , path );
546
+ if (IS_OPEN (file )) Trap1 (RE_NO_DELETE , path ); // it's not allowed to delete opened file port
546
547
Setup_File (file , 0 , path );
547
- if (OS_DO_DEVICE (file , RDC_DELETE ) < 0 ) Trap1 (RE_NO_DELETE , path );
548
+ result = OS_DO_DEVICE (file , RDC_DELETE );
549
+ if (result >= 0 ) return R_RET ; // returns port so it can be used in chained evaluation
550
+ if (result == -2 ) return R_FALSE ;
551
+ // else...
552
+ Trap1 (RE_NO_DELETE , path );
548
553
break ;
549
554
550
555
case A_RENAME :
Original file line number Diff line number Diff line change @@ -337,6 +337,11 @@ static int Poll_Default(REBDEV *dev)
337
337
Signal_Device (req , EVT_ERROR );
338
338
}
339
339
}
340
+ else if (result < 0 ) {
341
+ result = req -> error ;
342
+ // make sure that we are consistent and error is always negative...
343
+ if (result > 0 ) result = - result ;
344
+ }
340
345
341
346
return result ;
342
347
}
Original file line number Diff line number Diff line change @@ -568,8 +568,6 @@ static int Get_File_Info(REBREQ *file)
568
568
569
569
file -> error = errno ;
570
570
return DR_ERROR ;
571
-
572
- return 0 ;
573
571
}
574
572
575
573
Original file line number Diff line number Diff line change @@ -135,6 +135,10 @@ Rebol [
135
135
not error? delete-dir %units/temp-dir/
136
136
not exists? %units/temp-dir/
137
137
]
138
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/2447
139
+ --assert false? try [delete %not-exists/ ]
140
+ --assert error? try [delete %/ ]
141
+
138
142
--test-- "CHANGE-DIR"
139
143
;@@ https://github.com/Oldes/Rebol-issues/issues/2446
140
144
--assert what-dir = change-dir %.
@@ -330,6 +334,19 @@ if system/platform = 'Windows [
330
334
"test" = read /string %issue-446.txt
331
335
not error? try [delete %issue-446.txt ]
332
336
]
337
+ --test-- "DELETE file"
338
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/2447
339
+ --assert false? try [delete %not-exists ]
340
+ ; create locked file...
341
+ p: open %issue-2447
342
+ ; should not be possible to delete it..
343
+ --assert error? try [delete %issue-2447 ]
344
+ ; close the file handle...
345
+ close p
346
+ ; now it may be deleted..
347
+ --assert port? try [delete %issue-2447 ]
348
+ ; validate...
349
+ --assert not exists? %issue-2447
333
350
334
351
===end-group===
335
352
You can’t perform that action at this time.
0 commit comments