< prev index next >

src/java.base/share/classes/java/io/FilePermission.java

Print this page




 184     private void init(int mask) {
 185         if ((mask & ALL) != mask)
 186                 throw new IllegalArgumentException("invalid actions mask");
 187 
 188         if (mask == NONE)
 189                 throw new IllegalArgumentException("invalid actions mask");
 190 
 191         if ((cpath = getName()) == null)
 192                 throw new NullPointerException("name can't be null");
 193 
 194         this.mask = mask;
 195 
 196         if (cpath.equals("<<ALL FILES>>")) {
 197             directory = true;
 198             recursive = true;
 199             cpath = "";
 200             return;
 201         }
 202 
 203         // store only the canonical cpath if possible
 204         cpath = AccessController.doPrivileged(new PrivilegedAction<String>() {
 205             public String run() {
 206                 try {
 207                     String path = cpath;
 208                     if (cpath.endsWith("*")) {
 209                         // call getCanonicalPath with a path with wildcard character
 210                         // replaced to avoid calling it with paths that are
 211                         // intended to match all entries in a directory
 212                         path = path.substring(0, path.length()-1) + "-";
 213                         path = new File(path).getCanonicalPath();
 214                         return path.substring(0, path.length()-1) + "*";
 215                     } else {
 216                         return new File(path).getCanonicalPath();
 217                     }
 218                 } catch (IOException ioe) {
 219                     return cpath;
 220                 }
 221             }
 222         });
 223 
 224         int len = cpath.length();




 184     private void init(int mask) {
 185         if ((mask & ALL) != mask)
 186                 throw new IllegalArgumentException("invalid actions mask");
 187 
 188         if (mask == NONE)
 189                 throw new IllegalArgumentException("invalid actions mask");
 190 
 191         if ((cpath = getName()) == null)
 192                 throw new NullPointerException("name can't be null");
 193 
 194         this.mask = mask;
 195 
 196         if (cpath.equals("<<ALL FILES>>")) {
 197             directory = true;
 198             recursive = true;
 199             cpath = "";
 200             return;
 201         }
 202 
 203         // store only the canonical cpath if possible
 204         cpath = AccessController.doPrivileged(new PrivilegedAction<>() {
 205             public String run() {
 206                 try {
 207                     String path = cpath;
 208                     if (cpath.endsWith("*")) {
 209                         // call getCanonicalPath with a path with wildcard character
 210                         // replaced to avoid calling it with paths that are
 211                         // intended to match all entries in a directory
 212                         path = path.substring(0, path.length()-1) + "-";
 213                         path = new File(path).getCanonicalPath();
 214                         return path.substring(0, path.length()-1) + "*";
 215                     } else {
 216                         return new File(path).getCanonicalPath();
 217                     }
 218                 } catch (IOException ioe) {
 219                     return cpath;
 220                 }
 221             }
 222         });
 223 
 224         int len = cpath.length();


< prev index next >