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


Java FileHeader类代码示例

本文整理汇总了Java中com.github.junrar.rarfile.FileHeader的典型用法代码示例。如果您正苦于以下问题:Java FileHeader类的具体用法?Java FileHeader怎么用?Java FileHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RarredFile

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
public RarredFile(File f) {
	this.f = f;
	setLastModified(f.lastModified());

	try {
		rarFile = new Archive(f);
		List<FileHeader> headers = rarFile.getFileHeaders();

		for (FileHeader fh : headers) {
			// if (fh.getFullUnpackSize() < MAX_ARCHIVE_ENTRY_SIZE && fh.getFullPackSize() < MAX_ARCHIVE_ENTRY_SIZE)
			addChild(new RarredEntry(fh.getFileNameString(), f, fh.getFileNameString(), fh.getFullUnpackSize()));
		}

		rarFile.close();
	} catch (RarException | IOException e) {
		LOGGER.error(null, e);
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:19,代码来源:RarredFile.java

示例2: parse

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
@Override
public void parse(File file) throws IOException {
    try {
        mArchive = new Archive(file);
    }
    catch (RarException e) {
        throw new IOException("unable to open archive");
    }

    FileHeader header = mArchive.nextFileHeader();
    while (header != null) {
        if (!header.isDirectory()) {
            String name = getName(header);
            if (Utils.isImage(name)) {
                mHeaders.add(header);
            }
        }

        header = mArchive.nextFileHeader();
    }

    Collections.sort(mHeaders, new NaturalOrderComparator() {
        @Override
        public String stringValue(Object o) {
            return getName((FileHeader) o);
        }
    });
}
 
开发者ID:nkanaev,项目名称:bubble,代码行数:29,代码来源:RarParser.java

示例3: getPage

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
@Override
public InputStream getPage(int num) throws IOException {
    if (mArchive.getMainHeader().isSolid()) {
        // solid archives require special treatment
        synchronized (this) {
            if (!mSolidFileExtracted) {
                for (FileHeader h : mArchive.getFileHeaders()) {
                    if (!h.isDirectory() && Utils.isImage(getName(h))) {
                        getPageStream(h);
                    }
                }
                mSolidFileExtracted = true;
            }
        }
    }
    return getPageStream(mHeaders.get(num));
}
 
开发者ID:nkanaev,项目名称:bubble,代码行数:18,代码来源:RarParser.java

示例4: openRarAddMetadata

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
/**
 * Extract information regarding the CBR format
 * 
 * @param result
 *            path information about the file
 * @return more information regarding the file including the page numbers
 *         and size
 * @throws RarException
 * @throws IOException
 */
public ComicBook openRarAddMetadata(ComicBook result) throws RarException, IOException {
	int numberOfPages = 0;
	Archive rar = new Archive(new File(result.getFileSystempath()));
	FileHeader fileHeader = rar.nextFileHeader();
	while (fileHeader != null) {
		if (!fileHeader.isDirectory()) {
			//name = fileHeader.getFileNameString();
			if (fileHeader.getFileNameString().contains(".jpg")) {
				numberOfPages++;
			}
		}
		fileHeader = rar.nextFileHeader();
	}
	result.setNumberOfPages(numberOfPages);
	//TODO: Add more metadata from file if there is one
	rar.close();
	return result;
}
 
开发者ID:sparksmith,项目名称:TheComicBook,代码行数:29,代码来源:MetadataGatherer.java

示例5: createFile

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
/**
 * Creates a file in a specified destination directory
 * @param fh the file to be created
 * @param destination the destination to which the newly created file will be moved to
 * @return
 */
private static File createFile(FileHeader fh, File destination) {
	File f = null;
	String name = null;
	if (fh.isFileHeader() && fh.isUnicode()) {
		name = fh.getFileNameW();
	} else {
		name = fh.getFileNameString();
	}
	f = new File(destination, name);
	if (!f.exists()) {
		try {
			f = makeFile(destination, name);
		} catch (IOException e) {
			logger.error("error creating the new file: " + f.getName(), e);
		}
	}
	return f;
}
 
开发者ID:spgroup,项目名称:groundhog,代码行数:25,代码来源:RarUncompressor.java

示例6: acceptContainedFile

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
@Override
protected boolean acceptContainedFile(FileHeader file) throws IOException {
    // Check our parent class will accept the file
    if (!super.acceptContainedFile(file)) {
        return false;
    }

    final String path = file.getFileNameString();

    // Check the Media file handler will accept the file
    if (!MediaFileHandler.acceptFileExtension(path)) {
        LOG.trace("Rejecting unacceptable file extension: {}", file);
        return false;
    }

    final long size = file.getFullUnpackSize();
    if (!MediaFileHandler.acceptFileSize(size)) {
        LOG.trace("Rejecting too small file: {} ({} bytes)", file, size);
        return false;
    }

    return true;
}
 
开发者ID:reines,项目名称:mediamanager,代码行数:24,代码来源:MediaRarFileHandler.java

示例7: setFile

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
private void setFile(IReadOnlyAccess file, long length) throws IOException {
	totalPackedSize = 0L;
	totalPackedRead = 0L;
	close();
	rof = file;
	try {
		readHeaders(length);
	} catch (Exception e) {
		logger.log(Level.WARNING,
				"exception in archive constructor maybe file is encrypted "
						+ "or currupt", e);
		// ignore exceptions to allow exraction of working files in
		// corrupt archive
	}
	// Calculate size of packed data
	for (BaseBlock block : headers) {
		if (block.getHeaderType() == UnrarHeadertype.FileHeader) {
			totalPackedSize += ((FileHeader) block).getFullPackSize();
		}
	}
	if (unrarCallback != null) {
		unrarCallback.volumeProgressChanged(totalPackedRead,
				totalPackedSize);
	}
}
 
开发者ID:pabloalba,项目名称:komics,代码行数:26,代码来源:Archive.java

示例8: createFile

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
private static File createFile(FileHeader fh, File destination) throws IOException {
    File f = null;
    String name = null;
    if (fh.isFileHeader() && fh.isUnicode()) {
        name = fh.getFileNameW();
    } else {
        name = fh.getFileNameString();
    }
    f = new File(destination, name);
    if (!f.exists()) {
        f = makeFile(destination, name);
    }
    return f;
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:15,代码来源:RarDecompressor.java

示例9: createDirectory

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
private static void createDirectory(FileHeader fh, File destination) {
    File f = null;
    if (fh.isDirectory() && fh.isUnicode()) {
        f = new File(destination, fh.getFileNameW());
        if (!f.exists()) {
            makeDirectory(destination, fh.getFileNameW());
        }
    } else if (fh.isDirectory() && !fh.isUnicode()) {
        f = new File(destination, fh.getFileNameString());
        if (!f.exists()) {
            makeDirectory(destination, fh.getFileNameString());
        }
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:15,代码来源:RarDecompressor.java

示例10: ZipExtractTask

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
public ZipExtractTask(Archive rar, String outputDir, Activity zipViewer, String fileName,boolean zip,FileHeader fileHeader) {
    this.zip=zip;
    this.outputDir = outputDir;
    this.rar = rar;
    this.zipViewer = zipViewer;
    this.fileName = fileName;
    this.header = fileHeader;
}
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:9,代码来源:ZipExtractTask.java

示例11: unzipRAREntry

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
private void unzipRAREntry(Archive zipfile, FileHeader header, String outputDir)
        throws IOException, RarException {

     output = new File(outputDir + "/" + header.getFileNameString().trim());
    FileOutputStream fileOutputStream = new FileOutputStream(output);
    zipfile.extractFile(header, fileOutputStream);
}
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:8,代码来源:ZipExtractTask.java

示例12: compare

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
@Override
public int compare(FileHeader file1, FileHeader file2) {
    if (file1.isDirectory() && !file2.isDirectory()) {
        return -1;


    } else if (file2.isDirectory() && !(file1).isDirectory()) {
        return 1;
    }
    return file1.getFileNameString().compareToIgnoreCase(file2.getFileNameString());
}
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:12,代码来源:RarHelperTask.java

示例13: RarAdapter

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
public RarAdapter(Context c,ArrayList<FileHeader> enter, RarViewer zipViewer) {
    System.out.println(enter.size()+"");
    this.enter = enter;
    for (int i = 0; i < enter.size(); i++) {
        myChecked.put(i, false);
    }  mInflater = (LayoutInflater) c
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    this.c = c;
    folder = c.getResources().getDrawable(R.drawable.ic_grid_folder_new);
    unknown = c.getResources().getDrawable(R.drawable.ic_doc_generic_am);
    this.zipViewer = zipViewer;
}
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:13,代码来源:RarAdapter.java

示例14: headerRequired

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
private FileHeader headerRequired(FileHeader rowItem) {

        for (FileHeader fileHeader : zipViewer.archive.getFileHeaders()) {
            String req = fileHeader.getFileNameString();
            if (rowItem.getFileNameString().equals(req))
                return fileHeader;
        }
        return null;
    }
 
开发者ID:DeFuture,项目名称:AmazeFileManager-master,代码行数:10,代码来源:RarAdapter.java

示例15: doInBackground

import com.github.junrar.rarfile.FileHeader; //导入依赖的package包/类
@Override
protected ArrayList<CompressedObjectParcelable> doInBackground(Void... params) {
    ArrayList<CompressedObjectParcelable> elements = new ArrayList<>();

    try {
        if (createBackItem) {
            elements.add(0, new CompressedObjectParcelable());
        }

        Archive zipfile = new Archive(new File(fileLocation));
        String relativeDirDiffSeparator = relativeDirectory.replace("/", "\\");

        for (FileHeader header : zipfile.getFileHeaders()) {
            String name = header.getFileNameString();//This uses \ as separator, not /
            boolean isInBaseDir = (relativeDirDiffSeparator == null || relativeDirDiffSeparator.equals("")) && !name.contains("\\");
            boolean isInRelativeDir = relativeDirDiffSeparator != null && name.contains("\\")
                    && name.substring(0, name.lastIndexOf("\\")).equals(relativeDirDiffSeparator);

            if (isInBaseDir || isInRelativeDir) {
                elements.add(new CompressedObjectParcelable(RarHelper.convertName(header), 0, header.getDataSize(), header.isDirectory()));
            }
        }
        Collections.sort(elements, new CompressedObjectParcelable.Sorter());
    } catch (RarException | IOException e) {
        e.printStackTrace();
    }

    return elements;
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:30,代码来源:RarHelperTask.java


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