src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java
changeset 54692 22866513a80e
parent 47216 71c04702a3d5
child 55693 9a97b1393e72
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54691:764addae3e37 54692:22866513a80e
     1 /*
     1 /*
     2  * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   399      * fchmod(int fildes, mode_t mode)
   399      * fchmod(int fildes, mode_t mode)
   400      */
   400      */
   401     static native void fchmod(int fd, int mode) throws UnixException;
   401     static native void fchmod(int fd, int mode) throws UnixException;
   402 
   402 
   403     /**
   403     /**
   404      * utimes(conar char* path, const struct timeval times[2])
   404      * utimes(const char* path, const struct timeval times[2])
   405      */
   405      */
   406     static void utimes(UnixPath path, long times0, long times1)
   406     static void utimes(UnixPath path, long times0, long times1)
   407         throws UnixException
   407         throws UnixException
   408     {
   408     {
   409         NativeBuffer buffer = copyToNativeBuffer(path);
   409         NativeBuffer buffer = copyToNativeBuffer(path);
   415     }
   415     }
   416     private static native void utimes0(long pathAddress, long times0, long times1)
   416     private static native void utimes0(long pathAddress, long times0, long times1)
   417         throws UnixException;
   417         throws UnixException;
   418 
   418 
   419     /**
   419     /**
   420      * futimes(int fildes,, const struct timeval times[2])
   420      * futimes(int fildes, const struct timeval times[2])
   421      */
   421      */
   422     static native void futimes(int fd, long times0, long times1) throws UnixException;
   422     static native void futimes(int fd, long times0, long times1) throws UnixException;
       
   423 
       
   424     /**
       
   425      * lutimes(const char* path, const struct timeval times[2])
       
   426      */
       
   427     static void lutimes(UnixPath path, long times0, long times1)
       
   428         throws UnixException
       
   429     {
       
   430         NativeBuffer buffer = copyToNativeBuffer(path);
       
   431         try {
       
   432             lutimes0(buffer.address(), times0, times1);
       
   433         } finally {
       
   434             buffer.release();
       
   435         }
       
   436     }
       
   437     private static native void lutimes0(long pathAddress, long times0, long times1)
       
   438         throws UnixException;
   423 
   439 
   424     /**
   440     /**
   425      * DIR *opendir(const char* dirname)
   441      * DIR *opendir(const char* dirname)
   426      */
   442      */
   427     static long opendir(UnixPath path) throws UnixException {
   443     static long opendir(UnixPath path) throws UnixException {
   576     static native byte[] strerror(int errnum);
   592     static native byte[] strerror(int errnum);
   577 
   593 
   578     /**
   594     /**
   579      * Capabilities
   595      * Capabilities
   580      */
   596      */
   581     private static final int SUPPORTS_OPENAT        = 1 << 1;    // syscalls
   597     private static final int SUPPORTS_OPENAT        = 1 << 1;  // syscalls
   582     private static final int SUPPORTS_FUTIMES       = 1 << 2;
   598     private static final int SUPPORTS_FUTIMES       = 1 << 2;
   583     private static final int SUPPORTS_BIRTHTIME     = 1 << 16;   // other features
   599     private static final int SUPPORTS_LUTIMES       = 1 << 4;
       
   600     private static final int SUPPORTS_BIRTHTIME     = 1 << 16; // other features
   584     private static final int capabilities;
   601     private static final int capabilities;
   585 
   602 
   586     /**
   603     /**
   587      * Supports openat and other *at calls.
   604      * Supports openat and other *at calls.
   588      */
   605      */
   593     /**
   610     /**
   594      * Supports futimes or futimesat
   611      * Supports futimes or futimesat
   595      */
   612      */
   596     static boolean futimesSupported() {
   613     static boolean futimesSupported() {
   597         return (capabilities & SUPPORTS_FUTIMES) != 0;
   614         return (capabilities & SUPPORTS_FUTIMES) != 0;
       
   615     }
       
   616 
       
   617     /**
       
   618      * Supports lutimes
       
   619      */
       
   620     static boolean lutimesSupported() {
       
   621         return (capabilities & SUPPORTS_LUTIMES) != 0;
   598     }
   622     }
   599 
   623 
   600     /**
   624     /**
   601      * Supports file birth (creation) time attribute
   625      * Supports file birth (creation) time attribute
   602      */
   626      */