RFR: 8151430: (fs) BasicFileAttributeView.setTimes should support setting file create time on OS X [v4]

Alan Bateman alanb at openjdk.org
Sat Aug 6 08:46:05 UTC 2022


On Fri, 5 Aug 2022 17:54:28 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Use the BSD system call `setattrlist(2)` to set file modification, access, and creation time attributes on macOS.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8151430: Override setTimes() in the new BsdPosixFileAttributeView class

The updated approach looks maintainable but it misses the "Unix" view so setTimes won't work. In terms of organization then maybe just use the same approach as UnixFileAttributeViews to encapsulate the implementation, e.g.


class BsdFileAttributeViews {
    static class Basic extends UnixFileAttributeViews.Basic {
        Basic(UnixPath file, boolean followLinks) {
            super(file, followLinks);
        }
    }

    static class Posix extends UnixFileAttributeViews.Posix {
        Posix(UnixPath file, boolean followLinks) {
            super(file, followLinks);
        }
    }

    static class Unix extends UnixFileAttributeViews.Basic {
        Unix(UnixPath file, boolean followLinks) {
            super(file, followLinks);
        }
    }
}

src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java line 73:

> 71:     static void setattrlist(UnixPath path, int commonattr, long modTime,
> 72:                             long accTime, long createTime, long options)
> 73:         throws UnixException {

minor nit but the "{" at the end of line looks a bit odd here.

-------------

PR: https://git.openjdk.org/jdk/pull/9762


More information about the nio-dev mailing list