src/java.base/share/classes/java/io/FilePermission.java
changeset 52727 396dfb0e8ba5
parent 52427 3c6aa484536c
child 55026 a8673ccddffd
equal deleted inserted replaced
52726:9cfa2e273b77 52727:396dfb0e8ba5
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package java.io;
    26 package java.io;
    27 
    27 
    28 import java.net.URI;
       
    29 import java.nio.file.*;
    28 import java.nio.file.*;
    30 import java.security.*;
    29 import java.security.*;
    31 import java.util.Enumeration;
    30 import java.util.Enumeration;
    32 import java.util.Objects;
    31 import java.util.Objects;
    33 import java.util.StringJoiner;
    32 import java.util.StringJoiner;
   197 //    }
   196 //    }
   198 
   197 
   199     private static final long serialVersionUID = 7930732926638008763L;
   198     private static final long serialVersionUID = 7930732926638008763L;
   200 
   199 
   201     /**
   200     /**
   202      * Always use the internal default file system, in case it was modified
   201      * Use the platform's default file system to avoid recursive initialization
   203      * with java.nio.file.spi.DefaultFileSystemProvider.
   202      * issues when the VM is configured to use a custom file system provider.
   204      */
   203      */
   205     private static final java.nio.file.FileSystem builtInFS =
   204     private static final java.nio.file.FileSystem builtInFS =
   206             DefaultFileSystemProvider.create()
   205         DefaultFileSystemProvider.theFileSystem();
   207                     .getFileSystem(URI.create("file:///"));
       
   208 
   206 
   209     private static final Path here = builtInFS.getPath(
   207     private static final Path here = builtInFS.getPath(
   210             GetPropertyAction.privilegedGetProperty("user.dir"));
   208             GetPropertyAction.privilegedGetProperty("user.dir"));
   211 
   209 
   212     private static final Path EMPTY_PATH = builtInFS.getPath("");
   210     private static final Path EMPTY_PATH = builtInFS.getPath("");
   324 
   322 
   325             this.mask = mask;
   323             this.mask = mask;
   326 
   324 
   327             if (name.equals("<<ALL FILES>>")) {
   325             if (name.equals("<<ALL FILES>>")) {
   328                 allFiles = true;
   326                 allFiles = true;
   329                 npath = builtInFS.getPath("");
   327                 npath = EMPTY_PATH;
   330                 // other fields remain default
   328                 // other fields remain default
   331                 return;
   329                 return;
   332             }
   330             }
   333 
   331 
   334             boolean rememberStar = false;
   332             boolean rememberStar = false;
   349                     directory = true;
   347                     directory = true;
   350                     recursive = !rememberStar;
   348                     recursive = !rememberStar;
   351                     npath = npath.getParent();
   349                     npath = npath.getParent();
   352                 }
   350                 }
   353                 if (npath == null) {
   351                 if (npath == null) {
   354                     npath = builtInFS.getPath("");
   352                     npath = EMPTY_PATH;
   355                 }
   353                 }
   356                 invalid = false;
   354                 invalid = false;
   357             } catch (InvalidPathException ipe) {
   355             } catch (InvalidPathException ipe) {
   358                 // Still invalid. For compatibility reason, accept it
   356                 // Still invalid. For compatibility reason, accept it
   359                 // but make this permission useless.
   357                 // but make this permission useless.