예제 #1
0
  public void testTarFileSet() throws Exception {
    project.executeTarget("tarfileset");

    File deb = new File("target/test-classes/test.deb");
    assertTrue("package not build", deb.exists());

    ArArchiveInputStream in = new ArArchiveInputStream(new FileInputStream(deb));
    ArArchiveEntry entry;
    while ((entry = in.getNextArEntry()) != null) {
      if (entry.getName().equals("data.tar.gz")) {
        TarInputStream tar = new TarInputStream(new GZIPInputStream(new NonClosingInputStream(in)));
        TarEntry tarentry;
        while ((tarentry = tar.getNextEntry()) != null) {
          assertTrue("prefix", tarentry.getName().startsWith("./foo/"));
          if (tarentry.isDirectory()) {
            assertEquals("directory mode (" + tarentry.getName() + ")", 040700, tarentry.getMode());
          } else {
            assertEquals("file mode (" + tarentry.getName() + ")", 0100600, tarentry.getMode());
          }
          assertEquals("user", "ebourg", tarentry.getUserName());
          assertEquals("group", "ebourg", tarentry.getGroupName());
        }
        tar.close();
      } else {
        // skip to the next entry
        long skip = entry.getLength();
        while (skip > 0) {
          long skipped = in.skip(skip);
          if (skipped == -1) {
            throw new IOException("Failed to skip");
          }
          skip -= skipped;
        }
      }
    }
    in.close();
  }
예제 #2
0
  public TarEntry map(final TarEntry pEntry) {

    final String name = pEntry.getName();

    final TarEntry newEntry = new TarEntry(prefix + '/' + Utils.stripPath(strip, name));

    newEntry.setUserId(pEntry.getUserId());
    newEntry.setGroupId(pEntry.getGroupId());
    newEntry.setUserName(pEntry.getUserName());
    newEntry.setGroupName(pEntry.getGroupName());
    newEntry.setMode(pEntry.getMode());
    newEntry.setSize(pEntry.getSize());

    return newEntry;
  }
예제 #3
0
/*