本文整理汇总了Java中org.apache.commons.compress.archivers.tar.TarArchiveEntry.setModTime方法的典型用法代码示例。如果您正苦于以下问题:Java TarArchiveEntry.setModTime方法的具体用法?Java TarArchiveEntry.setModTime怎么用?Java TarArchiveEntry.setModTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.compress.archivers.tar.TarArchiveEntry
的用法示例。
在下文中一共展示了TarArchiveEntry.setModTime方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyInfo
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static void applyInfo ( final TarArchiveEntry entry, final EntryInformation entryInformation, TimestampProvider timestampProvider )
{
if ( entryInformation == null )
{
return;
}
if ( entryInformation.getUser () != null )
{
entry.setUserName ( entryInformation.getUser () );
}
if ( entryInformation.getGroup () != null )
{
entry.setGroupName ( entryInformation.getGroup () );
}
entry.setMode ( entryInformation.getMode () );
entry.setModTime ( timestampProvider.getModTime () );
}
示例2: addControlContent
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addControlContent ( final TarArchiveOutputStream out, final String name, final ContentProvider content, final int mode ) throws IOException
{
if ( content == null || !content.hasContent () )
{
return;
}
final TarArchiveEntry entry = new TarArchiveEntry ( name );
if ( mode >= 0 )
{
entry.setMode ( mode );
}
entry.setUserName ( "root" );
entry.setGroupName ( "root" );
entry.setSize ( content.getSize () );
entry.setModTime ( this.getTimestampProvider ().getModTime () );
out.putArchiveEntry ( entry );
try ( InputStream stream = content.createInputStream () )
{
ByteStreams.copy ( stream, out );
}
out.closeArchiveEntry ();
}
示例3: addControlContent
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private void addControlContent ( final TarArchiveOutputStream out, final String name, final ContentProvider content, final int mode, final Supplier<Instant> timestampSupplier ) throws IOException
{
if ( content == null || !content.hasContent () )
{
return;
}
final TarArchiveEntry entry = new TarArchiveEntry ( name );
if ( mode >= 0 )
{
entry.setMode ( mode );
}
entry.setUserName ( "root" );
entry.setGroupName ( "root" );
entry.setSize ( content.getSize () );
entry.setModTime ( timestampSupplier.get ().toEpochMilli () );
out.putArchiveEntry ( entry );
try ( InputStream stream = content.createInputStream () )
{
IOUtils.copy ( stream, out );
}
out.closeArchiveEntry ();
}
示例4: addFileEntry
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static void addFileEntry(
TarArchiveOutputStream tarOut, String entryName, File file, long modTime) throws IOException {
final TarArchiveEntry tarEntry = new TarArchiveEntry(file, entryName);
if (modTime >= 0) {
tarEntry.setModTime(modTime);
}
tarOut.putArchiveEntry(tarEntry);
try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
final byte[] buf = new byte[BUF_SIZE];
int r;
while ((r = in.read(buf)) != -1) {
tarOut.write(buf, 0, r);
}
}
tarOut.closeArchiveEntry();
}
示例5: compressTar
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static void compressTar(String parent, Resource source,TarArchiveOutputStream tos, int mode) throws IOException {
if(source.isFile()) {
//TarEntry entry = (source instanceof FileResource)?new TarEntry((FileResource)source):new TarEntry(parent);
TarArchiveEntry entry = new TarArchiveEntry(parent);
entry.setName(parent);
// mode
//100777 TODO ist das so ok?
if(mode>0) entry.setMode(mode);
else if((mode=source.getMode())>0) entry.setMode(mode);
entry.setSize(source.length());
entry.setModTime(source.lastModified());
tos.putArchiveEntry(entry);
try {
IOUtil.copy(source,tos,false);
}
finally {
tos.closeArchiveEntry();
}
}
else if(source.isDirectory()) {
compressTar(parent, source.listResources(),tos,mode);
}
}
示例6: getDefaultEntry
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
protected TarArchiveEntry getDefaultEntry(ArchiveContext context, String name, long size) {
StringBuilder entryName = new StringBuilder(context.getRequest().getItemName());
entryName.append("-").append(context.getVersion());
if ( ! name.startsWith(File.separator) ) {
entryName.append(File.separator);
}
entryName.append(name);
TarArchiveEntry entry = new TarArchiveEntry(entryName.toString());
entry.setUserName("root");
entry.setGroupName("root");
entry.setMode(0644);
entry.setSize(size);
entry.setModTime(new Date(System.currentTimeMillis()-(60*60*24*1000)));
return entry;
}
示例7: sendCompressedDirectory
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@Override
protected void sendCompressedDirectory(MCRPath file, BasicFileAttributes attrs,
TarArchiveOutputStream container) throws IOException {
TarArchiveEntry entry = new TarArchiveEntry(getFilename(file), TarArchiveEntry.LF_DIR);
entry.setModTime(attrs.lastModifiedTime().toMillis());
container.putArchiveEntry(entry);
container.closeArchiveEntry();
}
示例8: sendCompressedFile
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@Override
protected void sendCompressedFile(MCRPath file, BasicFileAttributes attrs,
TarArchiveOutputStream container) throws IOException {
TarArchiveEntry entry = new TarArchiveEntry(getFilename(file));
entry.setModTime(attrs.lastModifiedTime().toMillis());
entry.setSize(attrs.size());
container.putArchiveEntry(entry);
try {
Files.copy(file, container);
} finally {
container.closeArchiveEntry();
}
}
示例9: sendMetadataCompressed
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
@Override
protected void sendMetadataCompressed(String fileName, byte[] content, long lastModified,
TarArchiveOutputStream container) throws IOException {
TarArchiveEntry entry = new TarArchiveEntry(fileName);
entry.setModTime(lastModified);
entry.setSize(content.length);
container.putArchiveEntry(entry);
container.write(content);
container.closeArchiveEntry();
}
示例10: createEntry
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
ArchiveEntry createEntry(long size) throws IOException {
// TODO: How to set entry name and indexes.
String name = String.format(entryNamePrefix, baseNum, count++);
switch (format) {
case CPIO:
CpioArchiveEntry cpioEntry = new CpioArchiveEntry(name);
cpioEntry.setSize(size);
cpioEntry.setTime(System.currentTimeMillis());
return cpioEntry;
case JAR:
JarArchiveEntry jarEntry = new JarArchiveEntry(name);
jarEntry.setSize(size);
jarEntry.setTime(System.currentTimeMillis());
return jarEntry;
case TAR:
TarArchiveEntry tarEntry = new TarArchiveEntry(name);
tarEntry.setSize(size);
tarEntry.setModTime(System.currentTimeMillis());
return tarEntry;
case ZIP:
ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
zipEntry.setSize(size);
zipEntry.setTime(System.currentTimeMillis());
return zipEntry;
}
// Normally, this code is not called because of the above switch.
throw new IOException("Format is configured.");
}
示例11: addDirectoryEntry
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
private static void addDirectoryEntry(
TarArchiveOutputStream tarOut, String entryName, File directory, long modTime)
throws IOException {
final TarArchiveEntry tarEntry = new TarArchiveEntry(directory, entryName);
if (modTime >= 0) {
tarEntry.setModTime(modTime);
}
tarOut.putArchiveEntry(tarEntry);
tarOut.closeArchiveEntry();
}
示例12: dirToTarArchiveOutputStream
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
* Helper method for {@link #tar(FileSystem, FileSystem, Path, Path)} that adds a directory entry to a given
* {@link TarArchiveOutputStream}.
*/
private static void dirToTarArchiveOutputStream(Path destDir, TarArchiveOutputStream tarArchiveOutputStream)
throws IOException {
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(formatPathToDir(destDir));
tarArchiveEntry.setModTime(System.currentTimeMillis());
tarArchiveOutputStream.putArchiveEntry(tarArchiveEntry);
tarArchiveOutputStream.closeArchiveEntry();
}
示例13: fileToTarArchiveOutputStream
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
* Helper method for {@link #tar(FileSystem, FileSystem, Path, Path)} that adds a file entry to a given
* {@link TarArchiveOutputStream} and copies the contents of the file to the new entry.
*/
private static void fileToTarArchiveOutputStream(FileStatus fileStatus, FSDataInputStream fsDataInputStream,
Path destFile, TarArchiveOutputStream tarArchiveOutputStream) throws IOException {
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(formatPathToFile(destFile));
tarArchiveEntry.setSize(fileStatus.getLen());
tarArchiveEntry.setModTime(System.currentTimeMillis());
tarArchiveOutputStream.putArchiveEntry(tarArchiveEntry);
try {
IOUtils.copy(fsDataInputStream, tarArchiveOutputStream);
} finally {
tarArchiveOutputStream.closeArchiveEntry();
}
}