本文整理汇总了Java中com.github.junrar.rarfile.FileHeader.isDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileHeader.isDirectory方法的具体用法?Java FileHeader.isDirectory怎么用?Java FileHeader.isDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.junrar.rarfile.FileHeader
的用法示例。
在下文中一共展示了FileHeader.isDirectory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
});
}
示例2: 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));
}
示例3: 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;
}
示例4: 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());
}
}
}
示例5: 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());
}
示例6: unzipRAREntry
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private void unzipRAREntry(@NonNull final Context context, Archive zipFile, FileHeader entry, String outputDir)
throws RarException, IOException {
String name = entry.getFileNameString();
name = name.replaceAll("\\\\", "/");
if (entry.isDirectory()) {
FileUtil.mkdir(new File(outputDir, name), context);
return;
}
File outputFile = new File(outputDir, name);
if (!outputFile.getParentFile().exists()) {
FileUtil.mkdir(outputFile.getParentFile(), context);
}
// Log.i("Amaze", "Extracting: " + entry);
BufferedInputStream inputStream = new BufferedInputStream(
zipFile.getInputStream(entry));
BufferedOutputStream outputStream = new BufferedOutputStream(
FileUtil.getOutputStream(outputFile, context, entry.getFullUnpackSize()));
try {
int len;
byte buf[] = new byte[GenericCopyUtil.DEFAULT_BUFFER_SIZE];
while ((len = inputStream.read(buf)) > 0) {
outputStream.write(buf, 0, len);
ServiceWatcherUtil.POSITION += len;
}
} finally {
outputStream.close();
inputStream.close();
}
}
示例7: createDirectory
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
/**
* Creates a directory within another specified directory
* @param fh
* @param destination the directory where the new directory will be placed
*/
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());
}
}
}
示例8: getAllImagesNamesFromFile
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
public static ArrayList<String> getAllImagesNamesFromFile(File file,
File outputDir) {
ArrayList<String> fileNames = new ArrayList<String>();
try {
Archive arch = new Archive(file);
FileHeader fh = null;
while (true) {
fh = arch.nextFileHeader();
if (fh == null) {
break;
}
if ((fh != null)
&& (!fh.isDirectory())
&& (Utils.isSupportedFile(fh.getFileNameString(),
AppConstant.IMAGE_EXTN))) {
fileNames
.add(outputDir.getAbsolutePath()
+ File.separator
+ Utils.absolutePathToString(fh
.getFileNameString()));
}
}
arch.close();
} catch (Exception e) {
Log.e("Decompress", "unrar", e);
}
Collections.sort(fileNames);
return fileNames;
}
示例9: onActionItemClicked
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.all:zipAdapter.toggleChecked(true,"");
mode.invalidate();
return true;
case R.id.ex:
try {
Toast.makeText(getActivity(), new Futils().getString(getActivity(), R.string.extracting), Toast.LENGTH_SHORT).show();
FileOutputStream fileOutputStream;
for(int i:zipAdapter.getCheckedItemPositions()) {
if(!elements.get(i).isDirectory()){File f1=new File(f.getParent() +
"/" + elements.get(i).getFileNameString().trim().replaceAll("\\\\","/"));
if(!f1.getParentFile().exists())f1.getParentFile().mkdirs();
fileOutputStream = new FileOutputStream(f1);
archive.extractFile(elements.get(i), fileOutputStream);
}else{
String name=elements.get(i).getFileNameString().trim();
Log.d("rarViewer", " parent " + name);
for(FileHeader v:archive.getFileHeaders()){
if(v.getFileNameString().trim().contains(name+"\\") ||
v.getFileNameString().trim().equals(name)) {
File f2 = new File(f.getParent() +
"/" + v.getFileNameString().trim().replaceAll("\\\\", "/"));
if (v.isDirectory()) f2.mkdirs();
else {
if (!f2.getParentFile().exists())
f2.getParentFile().mkdirs();
fileOutputStream = new FileOutputStream(f2);
archive.extractFile(v, fileOutputStream);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();}
mode.finish();
return true;
}
return false;
}
示例10: unzipRAREntry
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
private void unzipRAREntry(int id,String a, Archive zipfile, FileHeader entry, String outputDir)
throws IOException, RarException {
String name=entry.getFileNameString();
name=name.replaceAll("\\\\","/");
if (entry.isDirectory()) {
createDir(new File(outputDir, name));
return;
}
File outputFile = new File(outputDir, name);
if (!outputFile.getParentFile().exists()) {
createDir(outputFile.getParentFile());
}
// Log.i("Amaze", "Extracting: " + entry);
BufferedInputStream inputStream = new BufferedInputStream(
zipfile.getInputStream(entry));
BufferedOutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(outputFile));
try {
int len;
byte buf[] = new byte[20480];
while ((len = inputStream.read(buf)) > 0) {
//System.out.println(id + " " + hash.get(id));
if (hash.get(id)) {
outputStream.write(buf, 0, len);
copiedbytes=copiedbytes+len;
int p=(int) ((copiedbytes / (float) totalbytes) * 100);
if(p!=lastpercent || lastpercent==0){
publishResults(a,p,id,totalbytes,copiedbytes,false);
publishResults(true);
}
lastpercent=p;
} else {
publishResults(a,100,id,totalbytes,copiedbytes,true);
publishResults(false);
stopSelf(id);
}
}
}finally {
outputStream.close();
inputStream.close();
}
}
示例11: read
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
/**
* Read from compressed file
*
* @param srcPath
* path of compressed file
* @param fileCompressor
* FileCompressor object
* @throws Exception
*/
@Override
public void read(String srcPath, FileCompressor fileCompressor)
throws Exception {
long t1 = System.currentTimeMillis();
byte[] data = FileUtil.convertFileToByte(srcPath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Archive arch = new Archive(new File(srcPath));
try {
if (arch.isEncrypted()) {
FileCompressor.LOGGER.error(fileCompressor.hashCode()
+ " Archive is encrypted. Cannot read <" + srcPath
+ ">");
return;
}
FileHeader entry = null;
while (true) {
entry = arch.nextFileHeader();
if (entry == null)
break;
if (entry.isDirectory()) {
continue;
}
String name = entry.isUnicode() ? entry.getFileNameW() : entry
.getFileNameString();
if (entry.isEncrypted()) {
FileCompressor.LOGGER.error(fileCompressor.hashCode()
+ " File is encrypted. Cannot read <" + name + ">");
continue;
}
long t2 = System.currentTimeMillis();
baos = new ByteArrayOutputStream();
arch.extractFile(entry, baos);
BinaryFile binaryFile = new BinaryFile(name, baos.toByteArray());
fileCompressor.addBinaryFile(binaryFile);
LogUtil.createAddFileLog(fileCompressor, binaryFile, t2,
System.currentTimeMillis());
}
} catch (Exception e) {
FileCompressor.LOGGER.error("Error on get compressor file", e);
} finally {
arch.close();
baos.close();
}
LogUtil.createReadLog(fileCompressor, srcPath, data.length, t1,
System.currentTimeMillis());
}
示例12: convertName
import com.github.junrar.rarfile.FileHeader; //导入方法依赖的package包/类
public static String convertName(FileHeader file) {
String name = file.getFileNameString().replace('\\', '/');
if(file.isDirectory()) return name + "/";
else return name;
}