当前位置: 首页>>代码示例>>Java>>正文


Java TarArchiveEntry.setName方法代码示例

本文整理汇总了Java中org.apache.commons.compress.archivers.tar.TarArchiveEntry.setName方法的典型用法代码示例。如果您正苦于以下问题:Java TarArchiveEntry.setName方法的具体用法?Java TarArchiveEntry.setName怎么用?Java TarArchiveEntry.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.compress.archivers.tar.TarArchiveEntry的用法示例。


在下文中一共展示了TarArchiveEntry.setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: addDirToArchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * adds a directory to a gzip file, recursively
 *
 * @param tos TarArchiveOutputStream
 * @param srcFile File
 */
private void addDirToArchive(TarArchiveOutputStream tos, File srcFile) {
    File[] files = srcFile.listFiles();

    for (File file : files) {
        if (file.isDirectory()) {
            addDirToArchive(tos, file);
            continue;
        }

        try {
            logger.debug("Adding file: " + file.getPath());

            TarArchiveEntry entry = new TarArchiveEntry(file.getPath());
            entry.setName(repository.toURI().relativize(file.toURI()).getPath());
            entry.setSize(file.length());
            tos.putArchiveEntry(entry);
            IOUtils.copy(new FileInputStream(file), tos);
            tos.closeArchiveEntry();

        } catch (IOException ioe) {
            logger.error("can not add to gzip file. " + ioe.getMessage());
        }

    }
}
 
开发者ID:da-wen,项目名称:GitBackup,代码行数:32,代码来源:GzipArchiver.java

示例3: addDirToArchive

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
/**
 * adds a directory to a zip file, recursively
 *
 * @param tos TarArchiveOutputStream
 * @param srcFile File
 */
private void addDirToArchive(TarArchiveOutputStream tos, File srcFile) {
    File[] files = srcFile.listFiles();

    for (File file : files) {
        if (file.isDirectory()) {
            addDirToArchive(tos, file);
            continue;
        }

        try {
            logger.debug("Adding file: " + file.getPath());

            TarArchiveEntry entry = new TarArchiveEntry(file.getPath());
            entry.setName(repository.toURI().relativize(file.toURI()).getPath());
            entry.setSize(file.length());
            tos.putArchiveEntry(entry);
            IOUtils.copy(new FileInputStream(file), tos);
            tos.closeArchiveEntry();

        } catch (IOException ioe) {
            logger.error("can not add to tar file. " + ioe.getMessage());
        }

    }
}
 
开发者ID:da-wen,项目名称:GitBackup,代码行数:32,代码来源:TarArchiver.java

示例4: archiveTARFiles

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
public static File archiveTARFiles(File base, Iterable<File> files, String archiveNameWithOutExtension)
        throws IOException {
    File tarFile = new File(FileUtils.getTempDirectoryPath(), archiveNameWithOutExtension + ".tar");
    tarFile.deleteOnExit();
    try (TarArchiveOutputStream tos = new TarArchiveOutputStream(new GZIPOutputStream(new BufferedOutputStream(
            new FileOutputStream(tarFile))))) {
        tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
        for (File file : files) {
            TarArchiveEntry tarEntry = new TarArchiveEntry(file);
            tarEntry.setName(relativize(base, file));

            if (!file.isDirectory() && file.canExecute()) {
                tarEntry.setMode(tarEntry.getMode() | 0755);
            }

            tos.putArchiveEntry(tarEntry);

            if (!file.isDirectory()) {
                FileUtils.copyFile(file, tos);
            }
            tos.closeArchiveEntry();
        }
    }

    return tarFile;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:27,代码来源:CompressArchiveUtil.java

示例5: addToImage

import org.apache.commons.compress.archivers.tar.TarArchiveEntry; //导入方法依赖的package包/类
protected void addToImage(final TarArchiveOutputStream imageOutputStream, final TarArchiveEntry entry,
                          Optional<InputStream> inputStream) throws IOException {

    if (entry.getName().startsWith("/")) {
        entry.setName(ROOTFS_PREFIX + entry.getName());
    } else {
        entry.setName(ROOTFS_PREFIX + "/" + entry.getName());
    }

    imageOutputStream.putArchiveEntry(entry);
    if (inputStream.isPresent()) {
        IOUtils.copy(inputStream.get(), imageOutputStream);
    }
    imageOutputStream.closeArchiveEntry();
}
 
开发者ID:sarnowski,项目名称:aci,代码行数:16,代码来源:Content.java


注:本文中的org.apache.commons.compress.archivers.tar.TarArchiveEntry.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。