示例#1
0
  /** File store properties examined */
  @Test
  public void testRetrieveFileStoreInforamtion() throws IOException {
    FileSystem fs = FileSystems.getDefault();
    assertNotNull(fs);

    List<FileStore> stores = iterableToList(fs.getFileStores());

    // file store is device such a drive, partition or volume
    // in my system I have 3 partitions
    assertEquals(3, stores.size());

    // for storing triples of basic file store identification
    Set<String> storeNames = new HashSet<>();
    for (FileStore store : stores) {
      storeNames.add(store.name() + ";" + store.type() + ";" + store.isReadOnly());
      long total = store.getTotalSpace();
      long unallocated = store.getUnallocatedSpace();
      long usable = store.getUsableSpace();
      assertTrue(total > 0);
      assertTrue(unallocated > 0 && total >= unallocated);
      assertTrue(usable > 0 && total >= usable);
      // Just for notice of NumberFormat class existence :)
      // System.out.println(NumberFormat.getInstance().format(total));
    }

    // environment dependent
    assertEquals(
        cSET("Windows7_OS;NTFS;false", "Data;NTFS;false", "Documents;NTFS;false"), storeNames);

    // can be used for determine if file store supports such attribute view
    assertTrue(stores.get(0).supportsFileAttributeView(BasicFileAttributeView.class));
    assertFalse(stores.get(0).supportsFileAttributeView(PosixFileAttributeView.class));
  }
示例#2
0
 private ArrayList<Path> holeLaufwerkeUnix() {
   ArrayList<Path> laufwerksRoot = new ArrayList<>();
   for (FileStore store : FileSystems.getDefault().getFileStores()) {
     if (store.name().contains("/dev/sd")) {
       laufwerksRoot.add(
           Paths.get(store.toString().substring(0, store.toString().indexOf(' '))));
     }
   }
   return laufwerksRoot;
 }
示例#3
0
  @Test
  public void preallocateTooLarge() throws Exception {
    assumeTrue(Platform.isLinux());
    FileIO fio =
        FileIO.open(file, EnumSet.of(OpenOption.CREATE, OpenOption.MAPPED, OpenOption.PREALLOCATE));

    FileStore fs = Files.getFileStore(file.toPath());
    assumeTrue("ext4".equals(fs.type()) && !fs.name().contains("docker"));

    long len = file.getTotalSpace() * 100L;
    // setLength traps the IOException and prevents resizing / remapping. Not remapping avoids
    // the SIGBUS issue.
    fio.setLength(len);
    assertEquals(0, fio.length());

    fio.close();
  }
  private void setupFooter() {
    try {
      usedFileStore = Files.getFileStore(ToolSettings.NBITES_DIR_PATH);
    } catch (Exception e) {
      e.printStackTrace();
      ;
      throw new Error(e);
    }

    Debug.warn("Tool footer using fileStore: %s", usedFileStore.name());

    display.diskAvailLabel.setText(Utility.progressString(progressSize, 0.5));
    display.jvmAvailLabel.setText(Utility.progressString(progressSize, 0.5));

    footerJvmTimer =
        new Timer(
            1000, // ms
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                footerJvmAction();
              }
            });

    footerJvmTimer.start();

    footerDiskTimer =
        new Timer(
            1000,
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                footerDiskAction();
              }
            });
    footerDiskTimer.start();
  }