Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

MKLINK and Streams and DEL

Aug
1,917
68
Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  27.00.21 x64   Windows 10 [Version 10.0.19042.867]

I have created a script called CALC.BTM, which, with the help of MKLINK, is also TAPE.BTM

The .BTM stores data into a stream file, TAPE.TXT;
Code:
e:\utils>dir calc.btm /: /km && dir tape.btm /: /km
2021-03-18  11:30             782  calc.btm
                               44    tape.txt:$DATA
2021-03-18  10:59     <SYMLINK>    tape.btm [e:\utils\calc.btm]
                               44    tape.txt:$DATA

A problem arises when I try to DEL the TAPE.BTM:TAPE.TXT file;
Code:
e:\utils>del e:\utils\tape.btm:tape.txt
Deleting E:\utils\tape.btm:tape.txt
TCC: (Sys) The system cannot find the file specified.
 "E:\utils\tape.btm:tape.txt"
     0 files deleted       1 failed
...which seems to me that DEL cannot work with the Stream file of a <SYMLINK> file.

DEL works fine when I;
Code:
e:\utils>del e:\utils\calc.btm:tape.txt
Deleting E:\utils\calc.btm:tape.txt
     1 file deleted

Why can DEL not delete a Stream of a <SYMLINK> file?

Joe

SOURCE CODE:
Code:
@setlocal
@echo off

set Calc=e:\utils\calc.btm
set Tape=e:\utils\tape.btm

if not exist %Tape MKLINK %Tape %Calc > nul

if %_batchname eq %Calc Gosub Calc
if %_batchname eq %Tape Gosub Tape
endlocal
quit

:Calc
iff %# eq 0 then
  echo USAGE: %_batchname 10 + 2
  Return
else
  echo %@formatnc[5.2,%@eval[%$]]
  echo %$ = %@formatnc[5.2,%@eval[%$]] >> %_batchname:tape.txt
endiff
Return

:Tape
iff exist %_batchname:tape.txt then
  switch %#
  case 0
    :: Tape
    tail /n10 %_batchname:tape.txt
  case 1
     switch %1
       case list
         :: Tape View
         *list %_batchname:tape.txt
       case clear
         :: This does not work.
         :: del /q %_batchname:tape.txt
         :: This works.
         del /q %calc:tape.txt
     endswitch
  endswitch
endiff
Return
 
In place of;
Code:
del /q %calc:tape.txt
...I now have;
Code:
del /q %@symlink[%_batchname]:tape.txt
which does what I want.

Joe
 
The Windows API doesn't support deleting a symlink stream. Checking for this situation (by default) in DEL would slow things down (a LOT); I might consider adding a new switch, though that doesn't gain you a lot vs. just using @symlink.
However: +1 from me for a such new switch :-)
 

Similar threads

Back
Top