Folder() and non-existent drives & folders on XP


    Apr 04 2006 | 10:22 pm
    I'm trying to test if a drive is mounted on an XP machine by checking the count of files/folders. I can do it with the "folder" object in Max, but it's slow. So I started a js that would be simpler and perhaps faster. However, I get strange results when I check the count of, say "D:/" (I don't have a D:/ drive) - the count is 177! Take a look - theres some more comments in the max patch, too.:
    --------------begin js "foldercheck.js"--------------
    /*
    simple example of checking if a folder is empty
    */
    outlets = 1;
    setoutletassist(0,"info");
    function path(v)
    {
    var f = new Folder(v);
    outlet(0,"path: "+f.pathname);
    outlet(0,"count: "+f.count);
    f.reset();
    f.close();
    }
    --------------end js "foldercheck.js"--------------
    --------------begin MAX patch--------------
    --------------end MAX patch--------------

    • Apr 25 2006 | 12:10 am
      Hi Peter,
      This is known and has been fixed for the next MaxMSP unpdate for Windows.
      Here is a copy of the jsfolder object for you to test for us until the release .
      Cheers
      -Andrew
    • Apr 28 2006 | 4:28 pm
      Great! This is giving counts of 0 for non-existent drives. Thanks for
      the update.
      here's a (slow) way of using js for checking for valid drives on a
      windows system:
      /*
      simple example of checking if a folder is empty
      */
      outlets = 1;
      setoutletassist(0,"info");
      var letters = new Array() ;
      letters[0] = "A" ;
      letters[1] = "B" ;
      letters[2] = "C" ;
      letters[3] = "D" ;
      letters[4] = "E" ;
      letters[5] = "F" ;
      letters[6] = "G" ;
      letters[7] = "H" ;
      letters[8] = "I" ;
      letters[9] = "J" ;
      letters[10] = "K" ;
      letters[11] = "L" ;
      letters[12] = "M" ;
      letters[13] = "N" ;
      letters[14] = "O" ;
      letters[15] = "P" ;
      letters[16] = "Q" ;
      letters[17] = "R" ;
      letters[18] = "S" ;
      letters[19] = "T" ;
      letters[20] = "U" ;
      letters[21] = "V" ;
      letters[22] = "W" ;
      letters[23] = "X" ;
      letters[24] = "Y" ;
      letters[25] = "Z" ;
      function path(v) //input a path, outputs the path and the count
      {
      var f = new Folder(v);
      outlet(0,"path: "+f.pathname);
      outlet(0,"count: "+f.count);
      f.reset();
      f.close();
      }
      function drives() //just send the message "drives" and you'll get the
      drives that have something in them
      {
      for (var i=0;i var check = letters[i]+":/";
      var f = new Folder(check);
      if (f.count > 0) {
      outlet(0, f.pathname);
      }
      }
      }