Get the current filesystem

[Autolink] Menu

 
/* sample code to show how to get the filesystem (FAT, HPFS, CDFS     */
/* or LAN) of a drive                                                 */
/* Tested with OS/2 v2.99 WARP BETA 2 (English) and OS/2 Version 3    */
/* WARP (German & English)                                            */
/*                                                                    */
/* Note that there's a function called QLDrives in the DLL RXLANUTIL  */
/* which detects the data about all drives (including the             */
/* filesystem). The new REXXUTIL introduced with Object-Oriented REXX */
/* also contains a function to get the filesystem of a drive.         */

                                /* drives to check                    */
  possibleDrives = "CDEFGHI"

  do i = 1 to length( possibleDrives )
    curdrive = substr( possibleDrives,i,1 )

    say "The filesystem of drive " || curDrive || ": is " || ,
        GetFileSystem( curDrive )
  end /* do i = 1 to ... */
exit 0

/* ------------------------------------------------------------------ */
/* function: Get the filesystem of a drive                            */
/*                                                                    */
/* call:     GetFileSystem( testDrive )                               */
/*                                                                    */
/* where:    testdrive - Name of the drive to test (e.g. "A:")        */
/*                                                                    */
/* returns:  the type of the filesystem or "UNKNOWN"                  */
/*                                                                    */
GetFileSystem: PROCEDURE expose (exposeList)
  parse arg testDrive ":" .

  curFileSystem = "UNKNOWN"

                                /* use an unknown parameter for       */
                                /* CHKDSK to suppress all actions     */
                                /* (except the print of the           */
                                /* filesystem)                        */

                        /* flush the REXX queue                 v3.20 */
  do while queued() <> 0; parse pull; end;

  "@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
  do while queued() <> 0
    curLine = lineIN( "QUEUE:" )
    if abbrev( curLine, "Dateisystemtyp für den Datenträger ist:" ) | ,
       abbrev( curLine, "The type of file system for the disk is" ) then
    do
      curFileSystem = word( curLine, words( curLine ) )
      if right( curFileSystem,1 ) == "." then
        curFileSystem = dbrright( curFileSystem,1 )
    end /* if abbrev( ... */
  end /* do while queued() <> 0 */

RETURN curFileSystem


[Back: Check if a drive is ready]
[Next: Check if a directory exists]