Check if a name describes a device or a file

[Autolink] Menu

 
/* check if a name is the name of a file or the name of a device      */
/*                                                                    */
/* note:                                                        v2.40 */
/*                                                                    */
/*  Another method to test if a name is a device name or filename is  */
/*                                                                    */
/*   testName = stream( testFileName, "c", "QUERY EXISTS" )           */
/*   if fileSpec( "P", testName ) = "\DEV\" then                      */
/*      say testFileName || " is a device."                           */
/*   else                                                             */
/*      say testFileName || " can be a file or directory."            */
/*                                                                    */

  if stream( testFileName, "c", "QUERY EXISTS" ) <> "" then  /* v2.00 */
    if stream( testFileName, "c", "QUERY DATETIME" ) = "" then
      say TestFileName || " is a device!"
    else
      say TestFileName || " is a file!"
  else                                                       /* v2.00 */
    say TestFileName || " does not exist!"                   /* v2.00 */


[Back: Delete a directory(-tree)]
[Next: Check if a file exist]