3 Replies Latest reply on Feb 19, 2009 1:20 PM by (Kamal_Sharif)

    directory related functions in LrFileUtils

    Level 1
      I've been wanting an "isDirectory()" function for LrFileUtils. Consider this a request to add such in the future.

      I've been trying to fabricate something similar from the existing APIs in the meantime. In the process I have discoverred the following two issues:

      the recursiveDirectoryEntries/recursiveFiles functions (and maybe directoryEntries as well) do not return any error indication if the passed name is for a file, or for something non-existent. It seems like they should. Ideally two different indications for those two different scenarios, so that one could tell the difference.

      isEmptyDirectory() returns true if the name is for a file. I don't think I tested passing it the name of something non-existent. Also, it would be nice to get more information from fileAttributes(), specifically around whether the named thing is a directory.
        • 1. Re: directory related functions in LrFileUtils
          escouten Adobe Employee
          Jay, LrFileUtils.exists will return "directory" or "file" depending on what it finds at the path you provide. I think this should provide the info you're seeking.
          • 2. Re: directory related functions in LrFileUtils
            Level 1
            Doh! :-) Indeed it does. I must confess I saw the method in the summary but never even read it's description, assuming that it would just return a true/false and wasn't useful for what I was doing.

            I've just tried a few examples with it. It mostly works as I expect, with one exception, which you may very will find to be nitpicky. I've found that Lr is usually happy regardless of whether I use "/" or "\" as a separator (on Windows, at least), except that "//foo" and "//foo/bar" return false even though "\\foo" and "\\foo\bar" return true. "//foo/bar/baz" works fine. I really have no clue if this is an Lr quirk or a Windows quirk.

            Regardless, I'm satisfied and moving along. Thanks Eric!
            • 3. Re: directory related functions in LrFileUtils
              (Kamal_Sharif) Level 1
              I created a utility wrapper around this method and basically call
              isFile, isDirectory which return true if it exists and is file/directory and false insteand.
              I also thought LrFileUtils.exists is rather confusing coz it returns two different types, false or string.
              I would rather have a wrapper around it like
              doesFileExist and doesDirectory exist, since then, my life is much easier. :-)

              Kamal