本文整理汇总了Java中org.apache.tools.zip.UnixStat类的典型用法代码示例。如果您正苦于以下问题:Java UnixStat类的具体用法?Java UnixStat怎么用?Java UnixStat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnixStat类属于org.apache.tools.zip包,在下文中一共展示了UnixStat类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnixMode
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
/**
* Determine a Resource's Unix mode or return the given default
* value if not available.
*/
private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) {
int unixMode = defaultMode;
if (zf != null) {
final ZipEntry ze = zf.getEntry(r.getName());
unixMode = ze.getUnixMode();
if ((unixMode == 0 || unixMode == UnixStat.DIR_FLAG)
&& !preserve0Permissions) {
unixMode = defaultMode;
}
} else if (r instanceof ArchiveResource) {
unixMode = ((ArchiveResource) r).getMode();
}
return unixMode;
}
示例2: packMetadata
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void packMetadata(TaskOutputOriginWriter writeMetadata, TarOutputStream outputStream) throws IOException {
TarEntry entry = new TarEntry(METADATA_PATH);
entry.setMode(UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writeMetadata.execute(baos);
entry.setSize(baos.size());
outputStream.putNextEntry(entry);
try {
outputStream.write(baos.toByteArray());
} finally {
outputStream.closeEntry();
}
}
示例3: storeDirectoryEntry
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void storeDirectoryEntry(FileVisitDetails dirDetails, String propertyRoot, TarOutputStream outputStream) throws IOException {
String path = dirDetails.getRelativePath().getPathString();
TarEntry entry = new TarEntry(propertyRoot + path + "/");
storeModificationTime(entry, dirDetails.getLastModified());
entry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
outputStream.putNextEntry(entry);
outputStream.closeEntry();
}
示例4: storeFileEntry
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void storeFileEntry(File file, String path, long lastModified, long size, int mode, TarOutputStream outputStream) throws IOException {
TarEntry entry = new TarEntry(path);
storeModificationTime(entry, lastModified);
entry.setSize(size);
entry.setMode(UnixStat.FILE_FLAG | mode);
outputStream.putNextEntry(entry);
try {
Files.copy(file, outputStream);
} finally {
outputStream.closeEntry();
}
}
示例5: visitFile
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void visitFile(FileCopyDetails fileDetails) {
try {
TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString());
archiveEntry.setModTime(fileDetails.getLastModified());
archiveEntry.setSize(fileDetails.getSize());
archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode());
tarOutStr.putNextEntry(archiveEntry);
fileDetails.copyTo(tarOutStr);
tarOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e);
}
}
示例6: visitDir
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void visitDir(FileCopyDetails dirDetails) {
try {
// Trailing slash on name indicates entry is a directory
TarEntry archiveEntry = new TarEntry(dirDetails.getRelativePath().getPathString() + '/');
archiveEntry.setModTime(dirDetails.getLastModified());
archiveEntry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
tarOutStr.putNextEntry(archiveEntry);
tarOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to TAR '%s'.", dirDetails, tarFile), e);
}
}
示例7: visitFile
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void visitFile(FileCopyDetails fileDetails) {
try {
ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
archiveEntry.setTime(fileDetails.getLastModified());
archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
zipOutStr.putNextEntry(archiveEntry);
fileDetails.copyTo(zipOutStr);
zipOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
}
}
示例8: visitDir
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
private void visitDir(FileCopyDetails dirDetails) {
try {
// Trailing slash in name indicates that entry is a directory
ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
archiveEntry.setTime(dirDetails.getLastModified());
archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
zipOutStr.putNextEntry(archiveEntry);
zipOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
}
}
示例9: testTarFileSet
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
@Test
public void testTarFileSet() throws IOException {
buildRule.executeTarget("testTarFileSet");
org.apache.tools.zip.ZipFile zf = null;
try {
zf = new org.apache.tools.zip.ZipFile(new File(buildRule.getProject().getProperty("output"), "test3.zip"));
org.apache.tools.zip.ZipEntry ze = zf.getEntry("asf-logo.gif");
assertEquals(UnixStat.FILE_FLAG | 0446, ze.getUnixMode());
} finally {
if (zf != null) {
zf.close();
}
}
}
示例10: testRewriteZeroPermissions
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
@Test
public void testRewriteZeroPermissions() throws IOException {
buildRule.executeTarget("rewriteZeroPermissions");
org.apache.tools.zip.ZipFile zf = null;
try {
zf = new org.apache.tools.zip.ZipFile(new File(buildRule.getProject().getProperty("output"), "test3.zip"));
org.apache.tools.zip.ZipEntry ze = zf.getEntry("testdir/test.txt");
assertEquals(UnixStat.FILE_FLAG | 0644, ze.getUnixMode());
} finally {
if (zf != null) {
zf.close();
}
}
}
示例11: testForBugzilla34764
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
@Test
public void testForBugzilla34764() throws IOException {
buildRule.executeTarget("testForBugzilla34764");
org.apache.tools.zip.ZipFile zf = null;
try {
zf = new org.apache.tools.zip.ZipFile(new File(buildRule.getProject().getProperty("output"), "test3.zip"));
org.apache.tools.zip.ZipEntry ze = zf.getEntry("file1");
assertEquals(UnixStat.FILE_FLAG | 0644, ze.getUnixMode());
} finally {
if (zf != null) {
zf.close();
}
}
}
示例12: integerSetFileMode
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
/**
* specify the user, group and
* other modes in the standard Unix fashion;
* optional, default=0644
*
* <p>We use the strange name so this method doesn't appear in
* IntrospectionHelpers list of attribute setters.</p>
* @param mode a <code>int</code> value
* @since Ant 1.7
*/
public void integerSetFileMode(int mode) {
fileModeHasBeenSet = true;
this.fileMode = UnixStat.FILE_FLAG | mode;
}
示例13: integerSetDirMode
import org.apache.tools.zip.UnixStat; //导入依赖的package包/类
/**
* specify the user, group and
* other modes in the standard Unix fashion;
* optional, default=0755
* <p>We use the strange name so this method doesn't appear in
* IntrospectionHelpers list of attribute setters.</p>
* @param mode a <code>int</code> value
* @since Ant 1.7
*/
public void integerSetDirMode(int mode) {
dirModeHasBeenSet = true;
this.dirMode = UnixStat.DIR_FLAG | mode;
}