home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / autobk2.zip / FileType.CMD < prev    next >
OS/2 REXX Batch file  |  1995-11-20  |  5KB  |  110 lines

  1. /*********************************************************************/
  2. /*     REXX Function to determine partition file type                */
  3. /*********************************************************************/
  4. Parse Upper Arg partition .
  5.  
  6. /*********************************************************************/
  7. /* Validate partition is two characters, the second must be a colon  */
  8. /* and the first must be an alphabetic character from A-Z.           */
  9. /*********************************************************************/
  10. If Length(partition) <> 2 | ,
  11.      Pos(':',partition) <> 2 | ,
  12.      \Datatype(Substr(partition,1,1),'U') Then
  13.      filetype = 'ERROR'
  14. Else
  15.    Do
  16.  
  17. /*********************************************************************/
  18. /*           Initialize REXXUtil environment (if not present)        */
  19. /*********************************************************************/
  20.       rxload = RxFuncQuery('SysLoadFuncs')
  21.       If rxload Then
  22.          Do
  23.             Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  24.             Call sysloadfuncs
  25.          End
  26.  
  27. /*********************************************************************/
  28. /*    Drives A: and B: can only be "FAT".                            */
  29. /*********************************************************************/
  30.       If partition = 'A:' | partition = 'B:' Then
  31.          filetype = 'FAT'
  32.       Else
  33.          Do
  34.  
  35. /*********************************************************************/
  36. /*   Get a list of all available local drives and validate the one   */
  37. /*   we were passed.                                                 */
  38. /*********************************************************************/
  39.             drives = SysDriveMap('C:', 'LOCAL')
  40.             If Wordpos(partition,drives) > 0 Then
  41.                Select
  42.  
  43. /*********************************************************************/
  44. /*   Check if the specified drive letter refers to a DCF/2 Virtual   */
  45. /*   Disk Unit (VDU).  If so, flag it as such before proceeding.     */
  46. /*********************************************************************/
  47.                   When Value('DCF2_VDU_'||Substr(partition,1,1),,'OS2ENVIRONMENT') <> '' Then
  48.                      filetype = 'VDU'
  49.  
  50. /*********************************************************************/
  51. /*   If it is not a VDU, make sure the device is actually available  */
  52. /*   and ready, otherwise return 'NOT READY' to the caller.          */
  53. /*********************************************************************/
  54.                   When SysDriveInfo(partition) = '' Then
  55.                      filetype = 'NOT READY'
  56.  
  57. /*********************************************************************/
  58. /*   If it is not a VDU, then check to see what kind of file system  */
  59. /*   was used.                                                       */
  60. /*********************************************************************/
  61.                   Otherwise
  62.                      Do
  63.  
  64. /*********************************************************************/
  65. /*   Attempt to create a subdirectory that won't work on a FAT vol   */
  66. /*********************************************************************/
  67.                         result = SysMkDir(partition'\willonlyworkonHPFS')
  68.                         Select
  69.  
  70. /*********************************************************************/
  71. /*   If the function was successful, it must be HPFS.  Remove the    */
  72. /*   directory we created.                                           */
  73. /*********************************************************************/
  74.                            When result = 0 Then
  75.                               Do
  76.                                  filetype = 'HPFS'
  77.                                  rc = SysRmDir(partition'\willonlyworkonHPFS')
  78.                               End
  79.  
  80. /*********************************************************************/
  81. /*   If the function indicates an illegal name, it must be FAT       */
  82. /*********************************************************************/
  83.                            When result = 206 Then
  84.                               filetype = 'FAT'
  85.  
  86. /*********************************************************************/
  87. /*    Otherwise it must be a CD-ROM.                                 */
  88. /*********************************************************************/
  89.                            Otherwise
  90.                               filetype = 'CD-ROM'
  91.                         End
  92.                      End
  93.                End
  94.  
  95. /*********************************************************************/
  96. /*  If we take this condition, the specified partition doesn't exist */
  97. /*********************************************************************/
  98.             Else
  99.                filetype = 'ERROR'
  100.          End
  101.  
  102. /*********************************************************************/
  103. /*      If we loaded REXXUtil, unload it, then exit, passing back    */
  104. /*      the filetype to the calling routine.                         */
  105. /*********************************************************************/
  106.       If rxload Then
  107.          Call SysDropFuncs
  108.    End
  109. Return filetype
  110.