< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  35 /**
  36  * Windows implementation of FileStore.
  37  */
  38 
  39 class WindowsFileStore
  40     extends FileStore
  41 {
  42     private final String root;
  43     private final VolumeInformation volInfo;
  44     private final int volType;
  45     private final String displayName;   // returned by toString
  46 
  47     private WindowsFileStore(String root) throws WindowsException {
  48         assert root.charAt(root.length()-1) == '\\';
  49         this.root = root;
  50         this.volInfo = GetVolumeInformation(root);
  51         this.volType = GetDriveType(root);
  52 
  53         // file store "display name" is the volume name if available
  54         String vol = volInfo.volumeName();
  55         if (vol.length() > 0) {
  56             this.displayName = vol;
  57         } else {
  58             // TBD - should we map all types? Does this need to be localized?
  59             this.displayName = (volType == DRIVE_REMOVABLE) ? "Removable Disk" : "";
  60         }
  61     }
  62 
  63     static WindowsFileStore create(String root, boolean ignoreNotReady)
  64         throws IOException
  65     {
  66         try {
  67             return new WindowsFileStore(root);
  68         } catch (WindowsException x) {
  69             if (ignoreNotReady && x.lastError() == ERROR_NOT_READY)
  70                 return null;
  71             x.rethrowAsIOException(root);
  72             return null; // keep compiler happy
  73         }
  74     }
  75 




  35 /**
  36  * Windows implementation of FileStore.
  37  */
  38 
  39 class WindowsFileStore
  40     extends FileStore
  41 {
  42     private final String root;
  43     private final VolumeInformation volInfo;
  44     private final int volType;
  45     private final String displayName;   // returned by toString
  46 
  47     private WindowsFileStore(String root) throws WindowsException {
  48         assert root.charAt(root.length()-1) == '\\';
  49         this.root = root;
  50         this.volInfo = GetVolumeInformation(root);
  51         this.volType = GetDriveType(root);
  52 
  53         // file store "display name" is the volume name if available
  54         String vol = volInfo.volumeName();
  55         if (!vol.isEmpty()) {
  56             this.displayName = vol;
  57         } else {
  58             // TBD - should we map all types? Does this need to be localized?
  59             this.displayName = (volType == DRIVE_REMOVABLE) ? "Removable Disk" : "";
  60         }
  61     }
  62 
  63     static WindowsFileStore create(String root, boolean ignoreNotReady)
  64         throws IOException
  65     {
  66         try {
  67             return new WindowsFileStore(root);
  68         } catch (WindowsException x) {
  69             if (ignoreNotReady && x.lastError() == ERROR_NOT_READY)
  70                 return null;
  71             x.rethrowAsIOException(root);
  72             return null; // keep compiler happy
  73         }
  74     }
  75 


< prev index next >