當前位置: 首頁>>代碼示例>>Java>>正文


Java TarArchiveEntry.setModTime方法代碼示例

本文整理匯總了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 () );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:19,代碼來源:DebianPackageWriter.java

示例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 ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:25,代碼來源:DebianPackageWriter.java

示例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 ();
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:25,代碼來源:DebianPackageWriter.java

示例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();
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:17,代碼來源:TarUtils.java

示例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);
    }
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:27,代碼來源:CompressUtil.java

示例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;
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:17,代碼來源:AbstractArchiveBasedConfigItem.java

示例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();
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:9,代碼來源:MCRTarServlet.java

示例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();
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:14,代碼來源:MCRTarServlet.java

示例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();
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:11,代碼來源:MCRTarServlet.java

示例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.");
}
 
開發者ID:hata,項目名稱:embulk-encoder-commons-compress,代碼行數:31,代碼來源:CommonsCompressArchiveProvider.java

示例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();
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:11,代碼來源:TarUtils.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-gobblin,代碼行數:12,代碼來源:StreamUtils.java

示例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();
  }
}
 
開發者ID:apache,項目名稱:incubator-gobblin,代碼行數:18,代碼來源:StreamUtils.java


注:本文中的org.apache.commons.compress.archivers.tar.TarArchiveEntry.setModTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。