< prev index next >

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileStore.java

Print this page
rev 53034 : 8215472: Cleanups in implementation classes of jdk.zipfs and tests
   1 /*
   2  * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.nio.zipfs;
  27 
  28 import java.io.IOException;
  29 import java.nio.file.Files;
  30 import java.nio.file.FileStore;
  31 import java.nio.file.FileSystems;

  32 import java.nio.file.Path;
  33 import java.nio.file.attribute.BasicFileAttributes;
  34 import java.nio.file.attribute.FileAttributeView;
  35 import java.nio.file.attribute.FileStoreAttributeView;
  36 import java.nio.file.attribute.BasicFileAttributeView;
  37 import java.util.Formatter;
  38 
  39 /*
  40  *
  41  * @author  Xueming Shen, Rajendra Gutupalli, Jaya Hangal
  42  */
  43 
  44 class ZipFileStore extends FileStore {
  45 
  46     private final ZipFileSystem zfs;
  47 
  48     ZipFileStore(ZipPath zpath) {
  49         this.zfs = zpath.getFileSystem();
  50     }
  51 
  52     @Override
  53     public String name() {
  54         return zfs.toString() + "/";
  55     }
  56 
  57     @Override
  58     public String type() {
  59         return "zipfs";
  60     }
  61 
  62     @Override
  63     public boolean isReadOnly() {
  64         return zfs.isReadOnly();
  65     }
  66 
  67     @Override
  68     public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
  69         return (type == BasicFileAttributeView.class ||
  70                 type == ZipFileAttributeView.class);
  71     }
  72 
  73     @Override
  74     public boolean supportsFileAttributeView(String name) {
  75         return name.equals("basic") || name.equals("zip");
  76     }
  77 
  78     @Override
  79     @SuppressWarnings("unchecked")
  80     public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
  81         if (type == null)
  82             throw new NullPointerException();
  83         return (V)null;
  84     }
  85 
  86     @Override
  87     public long getTotalSpace() throws IOException {
  88          return new ZipFileStoreAttributes(this).totalSpace();
  89     }
  90 
  91     @Override
  92     public long getUsableSpace() throws IOException {
  93          return new ZipFileStoreAttributes(this).usableSpace();
  94     }
  95 
  96     @Override
  97     public long getUnallocatedSpace() throws IOException {
  98          return new ZipFileStoreAttributes(this).unallocatedSpace();
  99     }


   1 /*
   2  * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.nio.zipfs;
  27 
  28 import java.io.IOException;

  29 import java.nio.file.FileStore;
  30 import java.nio.file.FileSystems;
  31 import java.nio.file.Files;
  32 import java.nio.file.Path;
  33 import java.nio.file.attribute.BasicFileAttributeView;
  34 import java.nio.file.attribute.FileAttributeView;
  35 import java.nio.file.attribute.FileStoreAttributeView;


  36 
  37 /**
  38  * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal

  39  */

  40 class ZipFileStore extends FileStore {
  41 
  42     private final ZipFileSystem zfs;
  43 
  44     ZipFileStore(ZipPath zpath) {
  45         this.zfs = zpath.getFileSystem();
  46     }
  47 
  48     @Override
  49     public String name() {
  50         return zfs.toString() + "/";
  51     }
  52 
  53     @Override
  54     public String type() {
  55         return "zipfs";
  56     }
  57 
  58     @Override
  59     public boolean isReadOnly() {
  60         return zfs.isReadOnly();
  61     }
  62 
  63     @Override
  64     public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
  65         return (type == BasicFileAttributeView.class ||
  66                 type == ZipFileAttributeView.class);
  67     }
  68 
  69     @Override
  70     public boolean supportsFileAttributeView(String name) {
  71         return name.equals("basic") || name.equals("zip");
  72     }
  73 
  74     @Override

  75     public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
  76         if (type == null)
  77             throw new NullPointerException();
  78         return (V)null;
  79     }
  80 
  81     @Override
  82     public long getTotalSpace() throws IOException {
  83          return new ZipFileStoreAttributes(this).totalSpace();
  84     }
  85 
  86     @Override
  87     public long getUsableSpace() throws IOException {
  88          return new ZipFileStoreAttributes(this).usableSpace();
  89     }
  90 
  91     @Override
  92     public long getUnallocatedSpace() throws IOException {
  93          return new ZipFileStoreAttributes(this).unallocatedSpace();
  94     }


< prev index next >