Example #1
0
  static void checkBasicAttributes(BasicFileAttributes attrs1, BasicFileAttributes attrs2) {
    // check file type
    assertTrue(attrs1.isRegularFile() == attrs2.isRegularFile());
    assertTrue(attrs1.isDirectory() == attrs2.isDirectory());
    assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
    assertTrue(attrs1.isOther() == attrs2.isOther());

    // check last modified time
    long time1 = attrs1.lastModifiedTime().toMillis();
    long time2 = attrs2.lastModifiedTime().toMillis();
    assertTrue(time1 == time2);

    // check size
    if (attrs1.isRegularFile()) assertTrue(attrs1.size() == attrs2.size());
  }
Example #2
0
  static void checkBasicAttributes(BasicFileAttributes attrs1, BasicFileAttributes attrs2) {
    // check file type
    assertTrue(attrs1.isRegularFile() == attrs2.isRegularFile());
    assertTrue(attrs1.isDirectory() == attrs2.isDirectory());
    assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
    assertTrue(attrs1.isOther() == attrs2.isOther());

    // check last modified time if not a symbolic link
    if (!attrs1.isSymbolicLink()) {
      long time1 = attrs1.lastModifiedTime().to(TimeUnit.SECONDS);
      long time2 = attrs2.lastModifiedTime().to(TimeUnit.SECONDS);

      if (time1 != time2) {
        System.err.format("File time for %s is %s\n", attrs1.fileKey(), attrs1.lastModifiedTime());
        System.err.format("File time for %s is %s\n", attrs2.fileKey(), attrs2.lastModifiedTime());
        assertTrue(false);
      }
    }

    // check size
    if (attrs1.isRegularFile()) assertTrue(attrs1.size() == attrs2.size());
  }