Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Kill a directory in DOS
#26
Hi, new nerd to thread here.

It could be that OP wants to write the code using QB64 in the IDE, then compile it using the QB45 compiler or such?

I don't know, but if it were me OP, you can check for a command existing first, if it exists run it. That's one way...

This would let you use `rd /s` in modern MS OS and `deltree /Y` in DOSBox, etc. You can use `rm -rf` in Linux/Mac.

- DOSBox: shell command: `deltree /y`
- Windows: shell command: 'rd /s`
- Mac/Linux: shell command: `rm -rf`

Not perfect, but might be easier than managing all this other stuff.

BTW @SMcNeill that `direntry.h` file approach is nice, but is it it not possible to do this natively in QB64? We can't walk a directory contents?

Anyway, the way I would approach this is try to detect what the environment you're running in is.

I found a few threads on Vogons about detecting if running DOSBox and am sharing those:
From: https://www.vogons.org/viewtopic.php?t=14619

This is a DB-INFO.BAT script someone wrote. You can see many ways to detect if running in dosbox here - you wouldn't implement the entire .BAT file of course, just pick one of the options, or a few and concatenate to test the result...

And for detecting other OS you can simply use built-ins like $IF: https://github.com/QB64Official/qb64/wiki/%24if

Hope this helps.

Code: (Select All)
@ echo off

goto Main

rem  +--------------------------------------------------
rem  ! DB-INFO 1.0.2 - Show essential DOSBox configuration
rem  ! info.
rem  !
rem  ! By MiniMax
rem  +--------------------------------------------------

:Usage
echo Usage DB-INFO [ /n ]
echo.
echo where /n indicates which page to view.
echo.
echo.  Page 1 = DOSBox version and mount information.
echo.  Page 2 - DOSBox emulated hardware.
echo.  Page 3 - Directory listing of C:\ and D:\
echo.
echo If no page number is given all 3 pages will be shown.
goto End

:Main

rem Validate that DB-INFO is running inside DOSBox.

if not "%COMSPEC%" == "Z:\COMMAND.COM" goto NotDB
if not exist %COMSPEC% goto NotDB
if not exist Z:\LOADFIX.COM goto NotDB
if not exist Z:\MOUNT.COM goto NotDB

rem Figure out which version of DOSBox this is.

if not exist Z:\KEYB.COM goto else1
    rem Version 0.66 introduced the KEYB.COM program, so we
    rem are running 0.66 or later.

    set CONFIG=66+
goto endif1
:else1
    rem Version 0.65 introduced the CONFIG -GET option.
    rem If the get-operation succeeds, the CONFIG-variable
    rem will be set to something, and we are running 0.65.
    rem If not, we are running 0.63 or earlier.

    set CONFIG=
    config -get sdl output > NUL:
    if not "%CONFIG%" == "" set CONFIG=65
    if    "%CONFIG%" == "" set CONFIG=63-
:endif1

rem Check if only a specific page is requested.

if "%1" == "/1" goto Page1
if "%1" == "/2" goto Page2
if "%1" == "/3" goto Page3

:Page0
echo DB-INFO 1.0.2 - Show essential DOSBox configuration info.
echo.

if "%1" == "/?" goto Usage
goto Page1

:Page1
echo +--------------------------------------------------
echo ! Page 1 - DOSBox version and mounts.
echo +--------------------------------------------------
echo.

if "%CONFIG%" == "63-" echo DOSBox version 0.63 or earlier. Reported DOS version 5.0.
if "%CONFIG%" == "65"  echo DOSBox version 0.65. Reported DOS version 5.0
if "%CONFIG%" == "66+" ver
echo.

mount

if %1 == /1 goto End
echo.
pause

:Page2
echo +--------------------------------------------------
echo ! Page 2 - DOSBox emulated hardware.
echo +--------------------------------------------------
echo.

rem If we are running version 0.63 or earlier, we can only
rem report on the BLASTER and GUS variables.

if "%CONFIG%" == "63-" goto Page2a
goto Page2b

:Page2a
rem  +--------------------------------------------------
rem  ! Page 2a - For DOSBox v.0.63 or earlier.
rem  +--------------------------------------------------

rem  The last attribute (T) of the BLASTER variable can tell us
rem  which type of card we have. We will make a best-effort to
rem  determine the card type.
rem
rem  Type of card: 1=SB 1.5, 2=SB Pro I, 3=SB 2.0, 4=SB Pro II,
rem  6=SB 16, 7=SB AWE32.

set CONFIG=unknown

rem  First check the standard IRQ 7 settings:

if "%BLASTER%" == "A220 I7 D1 T1" set CONFIG=sb1
if "%BLASTER%" == "A220 I7 D1 T2" set CONFIG=sbpro1
if "%BLASTER%" == "A220 I7 D1 T3" set CONFIG=sb2
if "%BLASTER%" == "A220 I7 D1 T4" set CONFIG=sbpro2
if "%BLASTER%" == "A220 I7 D1 T6" set CONFIG=sb16
if "%BLASTER%" == "A220 I7 D1 T7" set CONFIG=sbawe32

rem Version 0.62 and later added the HDMA setting.

if "%BLASTER%" == "A220 I7 D1 H5 T1" set CONFIG=sb1
if "%BLASTER%" == "A220 I7 D1 H5 T2" set CONFIG=sbpro1
if "%BLASTER%" == "A220 I7 D1 H5 T3" set CONFIG=sb2
if "%BLASTER%" == "A220 I7 D1 H5 T4" set CONFIG=sbpro2
if "%BLASTER%" == "A220 I7 D1 H5 T6" set CONFIG=sb16
if "%BLASTER%" == "A220 I7 D1 H5 T7" set CONFIG=sbawe32

rem  Many games wants the SoundBlaster to use IRQ5 so we will
rem  try that too:

if "%BLASTER%" == "A220 I5 D1 T1" set CONFIG=sb1
if "%BLASTER%" == "A220 I5 D1 T2" set CONFIG=sbpro1
if "%BLASTER%" == "A220 I5 D1 T3" set CONFIG=sb2
if "%BLASTER%" == "A220 I5 D1 T4" set CONFIG=sbpro2
if "%BLASTER%" == "A220 I5 D1 T6" set CONFIG=sb16
if "%BLASTER%" == "A220 I5 D1 T7" set CONFIG=sbawe32

rem Version 0.62 and later added the HDMA setting.

if "%BLASTER%" == "A220 I5 D1 H5 T1" set CONFIG=sb1
if "%BLASTER%" == "A220 I5 D1 H5 T2" set CONFIG=sbpro1
if "%BLASTER%" == "A220 I5 D1 H5 T3" set CONFIG=sb2
if "%BLASTER%" == "A220 I5 D1 H5 T4" set CONFIG=sbpro2
if "%BLASTER%" == "A220 I5 D1 H5 T6" set CONFIG=sb16
if "%BLASTER%" == "A220 I5 D1 H5 T7" set CONFIG=sbawe32

if not "%BLASTER%" == ""  echo SBlaster sbtype          = %CONFIG%
if not "%BLASTER%" == ""  echo SBlaster BLASTER          = %BLASTER%

if not "%ULTRASND%" == "" echo GUS      gus              = true
if not "%ULTRASND%" == "" echo GUS      ULTRASND        = %ULTRASND%
if not "%ULTRADIR%" == "" echo GUS      ULTRADIR        = %ULTRADIR%

goto EndP2

:Page2b
rem  +--------------------------------------------------
rem  ! Page 2b - For DOSBox v.0.65 or later.
rem  +--------------------------------------------------

rem Graphics settings (SDL and Render).

config -get sdl output > NUL:
echo SDL      output          = %CONFIG%
config -get sdl fullresolution > NUL:
echo SDL      fullresolution  = %CONFIG%
config -get sdl windowresolution > NUL:
echo SDL      windowresolution = %CONFIG%

config -get render scaler > NUL:
echo Render  scaler          = %CONFIG%

rem Hardware settings (CPU, SoundBlaster, Gravis Ultrasound,
rem and joystick).

config -get dosbox machine > NUL:
echo DOSBox  machine          = %CONFIG%
config -get dosbox memsize > NUL:
echo DOSBox  memsize          = %CONFIG%

config -get cpu core > NUL:
echo CPU      core            = %CONFIG%
config -get cpu cycles > NUL:
echo CPU      cycles          = %CONFIG%

config -get sblaster sbtype > NUL:
echo SBlaster sbtype          = %CONFIG%
if %CONFIG% == none goto endif2
echo SBlaster BLASTER          = %BLASTER%
:endif2

config -get gus gus > NUL:
echo GUS      gus              = %CONFIG%
if %CONFIG% == false goto endif3
echo GUS      ULTRASND        = %ULTRASND%
echo GUS      ULTRADIR        = %ULTRADIR%
:endif3

config -get joystick joysticktype > NUL:
echo Joystick joysticktype    = %CONFIG%
config -get joystick timed > NUL:
echo Joystick timed            = %CONFIG%
config -get joystick buttonwrap > NUL:
echo Joystick buttonwrap      = %CONFIG%

config -get dos xms > NUL:
echo DOS      xms              = %CONFIG%
config -get dos ems > NUL:
echo DOS      ems              = %CONFIG%
config -get dos umb > NUL:
echo DOS      umb              = %CONFIG%

:EndP2
if %1 == /2 goto End
echo.
pause

:Page3
echo +--------------------------------------------------
echo ! Page 3 - Directory listing of C:\ and D:\
echo +--------------------------------------------------
echo.

if not exist C:\. echo Drive C: is not mounted.
if    exist C:\. dir C:\ /w
if    exist C:\. echo.

if not exist D:\. echo Drive D: is not mounted.
if    exist D:\. dir D:\ /w

if %1 == /3 goto End
echo.
pause
goto End

:NotDB
echo.
echo .--------------------------------------------------.
echo ! Error: DB-INFO must be run from *inside* DOSBox! !
echo '--------------------------------------------------'
echo.
pause
goto End

:End
Hope this helps somehow.
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply


Messages In This Thread
Kill a directory in DOS - by eoredson - 11-30-2023, 04:16 AM
RE: Kill a directory in DOS - by TerryRitchie - 11-30-2023, 04:26 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 04:35 AM
RE: Kill a directory in DOS - by TerryRitchie - 11-30-2023, 04:38 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 04:44 AM
RE: Kill a directory in DOS - by TerryRitchie - 11-30-2023, 04:47 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 04:50 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 04:53 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 04:58 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 05:01 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 04:59 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 05:03 AM
RE: Kill a directory in DOS - by mnrvovrfc - 11-30-2023, 06:58 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 05:10 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 05:13 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 05:40 AM
RE: Kill a directory in DOS - by TerryRitchie - 11-30-2023, 05:37 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 05:40 AM
RE: Kill a directory in DOS - by TerryRitchie - 11-30-2023, 06:36 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 06:07 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 06:30 AM
RE: Kill a directory in DOS - by eoredson - 11-30-2023, 06:44 AM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 06:44 AM
RE: Kill a directory in DOS - by mnrvovrfc - 11-30-2023, 07:08 AM
RE: Kill a directory in DOS - by SpriggsySpriggs - 11-30-2023, 12:22 PM
RE: Kill a directory in DOS - by grymmjack - 11-30-2023, 12:48 PM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 02:17 PM
RE: Kill a directory in DOS - by mnrvovrfc - 11-30-2023, 02:35 PM
RE: Kill a directory in DOS - by Kernelpanic - 11-30-2023, 09:05 PM
RE: Kill a directory in DOS - by SMcNeill - 11-30-2023, 09:25 PM
RE: Kill a directory in DOS - by eoredson - 12-01-2023, 06:54 AM



Users browsing this thread: 13 Guest(s)