6 Replies Latest reply: Apr 11, 2013 6:04 PM by EJP RSS

    File creation time in OSX with Java 7

    1000720
      I need to get the creation file attribute of a file on OS X Lion. I have tried with Java nio, but it returns the modification time instead:

      BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
      System.out.println("Creation time: " + attr.creationTime());

      I know that some file systems don't support file creation timestamps but HFSP does so shouldn't BasicFileAttributes.creationTime method return the right value on OS X?

      Thanks.
        • 1. Re: File creation time in OSX with Java 7
          jschellSomeoneStoleMyAlias
          So presuming that someone says yes then what?

          A change like that won't be in point release. It might not make it into the next major release.

          So if you need it then you need to look for another solution. If you don't need it then it is really academic. But if the bug system is working (if) then you could submit a bug.
          • 2. Re: File creation time in OSX with Java 7
            1000720
            So you don´t know the answer.

            I know that it could be a bug but also it could be a poor knowledge about java NIO.2 and file systems.

            Maybe java uses the stat() POSIX function to get those attributes on OS X (which does not provide the creation time timestamp) instead of the mdls command and due to this the modification time is the expected value on OS X.

            I wanted to be sure about this before submitting a bug in the bug system and I suppose that the Oracle Discussion Forum should be the right place to discuss it.
            • 3. Re: File creation time in OSX with Java 7
              EJP
              So presuming that someone says yes then what?
              Then it's a bug.
              A change like that won't be in point release.
              Bugs get fixed in point releases. That's what point releases are for.
              • 4. Re: File creation time in OSX with Java 7
                jtahlborn
                user10689537 wrote:
                I need to get the creation file attribute of a file on OS X Lion. I have tried with Java nio, but it returns the modification time instead:

                BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
                System.out.println("Creation time: " + attr.creationTime());

                I know that some file systems don't support file creation timestamps but HFSP does so shouldn't BasicFileAttributes.creationTime method return the right value on OS X?
                there are filesystems which support it where it can be enabled/disabled. do you know that it is enabled on the filesystem you are using?
                • 5. Re: File creation time in OSX with Java 7
                  jschellSomeoneStoleMyAlias
                  EJP wrote:
                  So presuming that someone says yes then what?
                  Then it's a bug.
                  A change like that won't be in point release.
                  Bugs get fixed in point releases. That's what point releases are for.
                  Bugs that are accepted, targeted for a release, and that get fixed, get fixed in the point release.

                  There are many, many bugs that never get fixed.
                  • 6. Re: File creation time in OSX with Java 7
                    EJP
                    So somebody needs to report it to get the process started. Is that your point?