Skip to main content
Participating Frequently
February 8, 2011
Question

cfdirectory thinks directory is a file

  • February 8, 2011
  • 2 replies
  • 1066 views

I have a utility that allows the user to select a top-level directory, then displays a list of files in the directory as hyperlinks.  Any subdirectories are displayed separately and the hyperlink changes the default directory to that subdirectory where the process is repeated.  It basically works using <cfdirectory> and using the "type" column in the results to distinguish between files and directories.  It works fine in development but when I moved it to a staging location on the same server my top-level subdirectory gets treated as a file rather than a directory.  I dumped the cfdirectoy query and sure enough the Type for that directory is "File".  Very curious because this directory structure parallels the one on dev which correctly shows the subdirectory with Type = "Dir".  The directories are identical with regard to permissions and also the contents are the same (the top-level subdirectory in each case contains two other subdirectories).  OS is Linux.

This is my cfdirectory tag:

<cfdirectory directory="#ExpandPath('.')#/#strDirectory#" name="qFiles" sort="type desc,name">
where strDirectory is initially set to the top-level directory selected by the user.


This has me stumped - any ideas?

    This topic has been closed for replies.

    2 replies

    Inspiring
    February 9, 2011

    The "directory" isn't a symbolic link, is it?

    --

    Adam

    Participating Frequently
    February 9, 2011

    No, it's not a sym link.  As an update, I removed and recreated the directory in question and I still have the same issue.  I also created a separate

    subdirectory "test" under the same parent and found the same problem with it.

    Fernis
    Inspiring
    February 9, 2011

    Still sounds like a permission issue to me, although I have little to know experience on Linux/Unix platforms and CF.

    You might want to verify with DirectoryExists() that CF thinks such subfolder exists. You also might try to create one with that name, or create another subfolder in your root folder.

    If you also could semi-visually explain how your directory structure looks, and which folder is the problematic one, that'd be great. Like,

    Folder A (ok)

    -> Folder B (shows as type of File)

    ---->Folder C (ok)

    ---->Folder D (ok)

    -> Folder E

    etc... am I close with that example?

    -Fernis

    Participating Frequently
    February 9, 2011

    Thanks for the suggestions.  The directory structure is pretty much as you described, but the top-level directories (Folder A) are hard-coded as only certain ones are used by this app.  And since I can't drill down into Folder B (as it isn't recognized as a directory) the lower ones (C & D) never show up at all.  But I did run some tests and as I expected a cfdirectory of the root shows Folder A correctly as type "Dir" while a cfdirectory of Folder B shows no results at all.  I also verified that DirectoryExists() correctly returns "YES" for Folder B on dev but returns "NO" on the site with the problem.

    I think my next step is to remove and recreate the directory and replace all the contents.  Even if that solves the problem it's kind of scary if I don't know the cause as I won't have the luxury of recreating the directory once it goes into production.