why would a directory fail the is_dir() test?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence

    #1

    why would a directory fail the is_dir() test?

    In the function below, before I open the directory I first test to
    make sure the address I have is, in fact, a directory. This function
    was working fine on one web server running FreeBSD and PHP 4.06.
    However, today I'm trying to run this software on a new server (RH
    Linux 9, PHP 4.2.3) and the directory is failing the is_dir() test.
    The error message that I have in my code is printing out this error:

    In getListOfAnyDir ectory(), we expected the function to be handed an
    address to a directory, but instead we were given this:
    ppArrangementsP ublic/.


    Now, ppArrangementsP ublic/ looks like a directory to me. So why is it
    failing the test?








    function getListOfAnyDir ectory($address =false) {
    // 03-17-04 - this function should be given an address to a folder.

    $controllerForA ll = & getController() ;
    $resultsObject = & $controllerForA ll->getObject("McR esults", " in
    getListOfAnyDir ectory().");
    $theDirFilesArr ay = array() ;

    $address2 = str_replace("/", "", $address);

    if (is_dir($addres s) || is_dir($address 2)) {
    // open the directory and load all the files into an array
    $theDir = @ opendir($addres s);

    if ($theDir) {
    // We go through the array one element at a time, putting it into a
    new array, minus invisible files
    //marked by "." and ".."

    while ($theDirFiles = readdir ($theDir)) {
    if ($theDirFiles != "." && $theDirFiles != "..") {
    $theDirFilesArr ay[] = $theDirFiles ;
    }
    }

    closedir ($theDir) ;
    return $theDirFilesArr ay;
    } else {
    $resultsObject->error("In getListOfAnyDir ectory(), we tried to open
    the directory at the address $address, but for some reason it didn't
    open.", "getListOfAnyDi rectory");
    }
    } else {
    $resultsObject->error("In getListOfAnyDir ectory(), we expected the
    function to be handed an address to a directory, but instead we were
    given this: $address.", "getListOfAnyDi rectory");
    }
    }
  • Garp

    #2
    Re: why would a directory fail the is_dir() test?


    "lawrence" <lkrubner@geoci ties.com> wrote in message
    news:da7e68e8.0 404301520.1d60f 4c@posting.goog le.com...[color=blue]
    > In the function below, before I open the directory I first test to
    > make sure the address I have is, in fact, a directory. This function
    > was working fine on one web server running FreeBSD and PHP 4.06.
    > However, today I'm trying to run this software on a new server (RH
    > Linux 9, PHP 4.2.3) and the directory is failing the is_dir() test.
    > The error message that I have in my code is printing out this error:
    >
    > In getListOfAnyDir ectory(), we expected the function to be handed an
    > address to a directory, but instead we were given this:
    > ppArrangementsP ublic/.
    >
    >
    > Now, ppArrangementsP ublic/ looks like a directory to me. So why is it
    > failing the test?[/color]

    <snip>

    I can only speculate that your "directory" is not only not a directory, but
    doesn't actually exist at all. Does file_exists() return 1? Can you find it
    using the shell?

    Garp


    Comment

    • FLEB

      #3
      Re: why would a directory fail the is_dir() test?

      Regarding this well-known quote, often attributed to lawrence's famous "30
      Apr 2004 16:20:44 -0700" speech:
      [color=blue]
      > In the function below, before I open the directory I first test to
      > make sure the address I have is, in fact, a directory. This function
      > was working fine on one web server running FreeBSD and PHP 4.06.
      > However, today I'm trying to run this software on a new server (RH
      > Linux 9, PHP 4.2.3) and the directory is failing the is_dir() test.
      > The error message that I have in my code is printing out this error:
      >
      > In getListOfAnyDir ectory(), we expected the function to be handed an
      > address to a directory, but instead we were given this:
      > ppArrangementsP ublic/.
      >
      >
      > Now, ppArrangementsP ublic/ looks like a directory to me. So why is it
      > failing the test?[/color]
      [color=blue]
      > (snip code)[/color]


      Just some shots in the dark here... try sending it
      "./ppArrangementsP ublic/", "./ppArrangementsP ublic", or just
      "ppArrangements Public" (no trailing slash). That might be confusing it.
      Also, make sure your script is running in the current directory you think
      it is.

      --
      -- Rudy Fleminger
      -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
      (put "Hey!" in the Subject line for priority processing!)
      -- http://www.pixelsaredead.com

      Comment

      • lawrence

        #4
        Re: why would a directory fail the is_dir() test?

        FLEB <soon.the.sp@mm ers.and.evil.on es.will.bow-down-to.us> wrote in message news:<1fxhwrw9n doqd.4rnznd6lly hl.dlg@40tude.n et>...[color=blue]
        > Regarding this well-known quote, often attributed to lawrence's famous "30
        > Apr 2004 16:20:44 -0700" speech:
        >[color=green]
        > > In the function below, before I open the directory I first test to
        > > make sure the address I have is, in fact, a directory. This function
        > > was working fine on one web server running FreeBSD and PHP 4.06.
        > > However, today I'm trying to run this software on a new server (RH
        > > Linux 9, PHP 4.2.3) and the directory is failing the is_dir() test.
        > > The error message that I have in my code is printing out this error:
        > >
        > > In getListOfAnyDir ectory(), we expected the function to be handed an
        > > address to a directory, but instead we were given this:
        > > ppArrangementsP ublic/.
        > >
        > >
        > > Now, ppArrangementsP ublic/ looks like a directory to me. So why is it
        > > failing the test?[/color]
        >[color=green]
        > > (snip code)[/color]
        >
        >
        > Just some shots in the dark here... try sending it
        > "./ppArrangementsP ublic/", "./ppArrangementsP ublic", or just
        > "ppArrangements Public" (no trailing slash). That might be confusing it.
        > Also, make sure your script is running in the current directory you think
        > it is.[/color]


        I think the problem was the capitalization, which worked on a Windows
        server but not on a Linux server. Is there a way to get PHP to look
        for directories in a case insensitive manner when it is on Linux?

        Comment

        • FLEB

          #5
          Re: why would a directory fail the is_dir() test?

          Regarding this well-known quote, often attributed to lawrence's famous "3
          May 2004 18:58:21 -0700" speech:
          [color=blue]
          > FLEB <soon.the.sp@mm ers.and.evil.on es.will.bow-down-to.us> wrote in message news:<1fxhwrw9n doqd.4rnznd6lly hl.dlg@40tude.n et>...[color=green]
          >> Regarding this well-known quote, often attributed to lawrence's famous "30
          >> Apr 2004 16:20:44 -0700" speech:
          >>[color=darkred]
          >>> In the function below, before I open the directory I first test to
          >>> make sure the address I have is, in fact, a directory. This function
          >>> was working fine on one web server running FreeBSD and PHP 4.06.
          >>> However, today I'm trying to run this software on a new server (RH
          >>> Linux 9, PHP 4.2.3) and the directory is failing the is_dir() test.
          >>> The error message that I have in my code is printing out this error:
          >>>
          >>> In getListOfAnyDir ectory(), we expected the function to be handed an
          >>> address to a directory, but instead we were given this:
          >>> ppArrangementsP ublic/.
          >>>
          >>>
          >>> Now, ppArrangementsP ublic/ looks like a directory to me. So why is it
          >>> failing the test?[/color]
          >>[color=darkred]
          >>> (snip code)[/color]
          >>
          >>
          >> Just some shots in the dark here... try sending it
          >> "./ppArrangementsP ublic/", "./ppArrangementsP ublic", or just
          >> "ppArrangements Public" (no trailing slash). That might be confusing it.
          >> Also, make sure your script is running in the current directory you think
          >> it is.[/color]
          >
          >
          > I think the problem was the capitalization, which worked on a Windows
          > server but not on a Linux server. Is there a way to get PHP to look
          > for directories in a case insensitive manner when it is on Linux?[/color]

          Hmm... if there isn't a function for that in PHP already, I imagine you
          could iterate through a directory reading and use a case-insensitive string
          match.

          --
          -- Rudy Fleminger
          -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
          (put "Hey!" in the Subject line for priority processing!)
          -- http://www.pixelsaredead.com

          Comment

          Working...