コード例 #1
0
ファイル: PrefixMapper.java プロジェクト: Oakie3CR/jdeb
  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;
  }
コード例 #2
0
ファイル: DebAntTaskTestCase.java プロジェクト: patduin/jdeb
  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();
  }
コード例 #3
0
ファイル: PrefixMapper.java プロジェクト: jeroenr/jdeb
/*