Broken behavior of java.io.File()

Discussion in 'Java' started by Twisted, Feb 23, 2006.

  1. Twisted

    Twisted Guest

    I'm seeing several examples of broken behavior with java.io.File():

    * mkdirs() sometimes returns false, despite succeeding (the directories
    exist afterward on the
    filesystem)
    * exists() and isDirectory() sometimes return false when called on a
    File object right after a
    mkdirs() after which the directory and its parents existed, as
    observed using Winblows
    Exploder.

    What is going on here? Is there even a way to test for the existence of
    a directory with 100% accuracy?
    Twisted, Feb 23, 2006
    #1
    1. Advertising

  2. Twisted

    Twisted Guest

    Bah. My bad again -- the breakpoint was set on if(!dir.isDir()) { and
    not on the next line. So it was tripping when the dirs needed to be
    created, whether or not it was successful. Bah bah bah! I need to sleep
    before I do much more work on this thing...
    Twisted, Feb 23, 2006
    #2
    1. Advertising

  3. Twisted

    Roedy Green Guest

    On 22 Feb 2006 18:14:29 -0800, "Twisted" <> wrote,
    quoted or indirectly quoted someone who said :

    >* mkdirs() sometimes returns false, despite succeeding (the directories
    >exist afterward on the
    > filesystem)


    The alternative would to insist on atomic. If it dies part way
    thorough it has to delete what it created. Then what if that fails?
    having a few extra dirs is not going to hurt anything. I think that
    choice was reasonable given the OS does not support atomic directory
    node chain creation or deletion for that matter.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 23, 2006
    #3
  4. Twisted

    Roedy Green Guest

    On 22 Feb 2006 18:14:29 -0800, "Twisted" <> wrote,
    quoted or indirectly quoted someone who said :

    >What is going on here? Is there even a way to test for the existence of
    >a directory with 100% accuracy?


    that sounds like windows bug. I will speculate an WHY this happens.

    Windows maintains a very expensive statistic, the time last accessed.
    In theory the disks could spend their entire times updating the last
    access date in the directories every time a byte is read anywhere in
    the file tree, or at least is closed. Perhaps it is defined only
    measure the last closed file -- in other words when the directory
    itself was last modified.

    In any case procrastination is definitely called for.

    I suspect though they over did it. They also procrastinated posting
    even the existence of the directory. Recall that Windows NT+ use a
    transaction based system. Transactions to change the directory queue
    up with CODASYL-like processing to make it recover in the even of a
    crash during a multi sector write.

    The directory existence transaction had not yet been processed. Even
    the in RAM cache apparently does not recognize the change until
    officially posted.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 23, 2006
    #4
  5. Twisted

    Roedy Green Guest

    On 22 Feb 2006 18:14:29 -0800, "Twisted" <> wrote,
    quoted or indirectly quoted someone who said :

    >What is going on here? Is there even a way to test for the existence of
    >a directory with 100% accuracy?


    see http://mindprod.com/jgloss/file.html#MKDIRS
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 23, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok Redgormor
    Replies:
    70
    Views:
    1,734
    Dan Pop
    Feb 17, 2004
  2. Steven D'Aprano

    Why are "broken iterators" broken?

    Steven D'Aprano, Sep 21, 2008, in forum: Python
    Replies:
    8
    Views:
    635
  3. Cameron Simpson

    Re: Why are "broken iterators" broken?

    Cameron Simpson, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    569
    Cameron Simpson
    Sep 22, 2008
  4. Fredrik Lundh

    Re: Why are "broken iterators" broken?

    Fredrik Lundh, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    589
    Fredrik Lundh
    Sep 22, 2008
  5. Tron Fu
    Replies:
    4
    Views:
    166
    Tron Fu
    Aug 30, 2010
Loading...

Share This Page