6.1.0 - 变更包名 新增投影媒体权限开关/tasks模块 扩展内置模块方法 重构内置模块及构建脚本
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.stardust.pio;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
@@ -12,7 +11,6 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Created by Stardust on 2017/10/19.
|
||||
*/
|
||||
|
||||
public class PFile extends File {
|
||||
|
||||
private String mSimplifyPath;
|
||||
@@ -85,47 +83,66 @@ public class PFile extends File {
|
||||
@Override
|
||||
public PFile getParentFile() {
|
||||
String p = this.getParent();
|
||||
if (p == null)
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
return new PFile(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PFile[] listFiles() {
|
||||
String ss[] = list();
|
||||
if (ss == null) return null;
|
||||
ArrayList<PFile> files = new ArrayList<>();
|
||||
for (int i = 0; i < ss.length; i++) {
|
||||
if (!ss[i].startsWith(".")) {
|
||||
files.add(new PFile(this, ss[i]));
|
||||
}
|
||||
}
|
||||
return files.toArray(new PFile[files.size()]);
|
||||
return listFiles((FilenameFilter) null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PFile[] listFiles(FilenameFilter filter) {
|
||||
String ss[] = list();
|
||||
if (ss == null) return null;
|
||||
ArrayList<PFile> files = new ArrayList<>();
|
||||
for (String s : ss)
|
||||
if (!s.startsWith(".") && (filter == null || filter.accept(this, s)))
|
||||
files.add(new PFile(this, s));
|
||||
return files.toArray(new PFile[files.size()]);
|
||||
return listFiles(filter, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PFile[] listFiles(FileFilter filter) {
|
||||
String ss[] = list();
|
||||
if (ss == null) return null;
|
||||
return listFiles(filter, true);
|
||||
}
|
||||
|
||||
public PFile[] listFiles(boolean isShowHidden) {
|
||||
return listFiles((FilenameFilter) null, isShowHidden);
|
||||
}
|
||||
|
||||
public PFile[] listFiles(FilenameFilter filter, boolean isShowHidden) {
|
||||
String[] ss = list();
|
||||
if (ss == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<PFile> files = new ArrayList<>();
|
||||
for (String s : ss) {
|
||||
if (canAddHidden(s, isShowHidden) && (filter == null || filter.accept(this, s))) {
|
||||
files.add(new PFile(this, s));
|
||||
}
|
||||
}
|
||||
return files.toArray(new PFile[0]);
|
||||
}
|
||||
|
||||
public PFile[] listFiles(FileFilter filter, boolean isShowHidden) {
|
||||
String[] ss = list();
|
||||
if (ss == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<PFile> files = new ArrayList<>();
|
||||
for (String s : ss) {
|
||||
PFile f = new PFile(this, s);
|
||||
if (!f.isHidden() && (filter == null || filter.accept(f)))
|
||||
if (canAddHidden(f, isShowHidden) && (filter == null || filter.accept(f))) {
|
||||
files.add(f);
|
||||
}
|
||||
}
|
||||
return files.toArray(new PFile[files.size()]);
|
||||
return files.toArray(new PFile[0]);
|
||||
}
|
||||
|
||||
private boolean canAddHidden(PFile file, boolean override) {
|
||||
return override || !file.isHidden();
|
||||
}
|
||||
|
||||
private boolean canAddHidden(String fileName, boolean override) {
|
||||
return override || !fileName.startsWith(".");
|
||||
}
|
||||
|
||||
public String getSimplifiedName() {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.stardust.pio;
|
||||
/**
|
||||
* Created by Stardust on 2017/12/5.
|
||||
*/
|
||||
|
||||
public interface PFileInterface {
|
||||
String getPath();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Objects;
|
||||
/**
|
||||
* Created by Stardust on 2017/4/1.
|
||||
*/
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class PFiles {
|
||||
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package com.stardust.pio;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/29.
|
||||
*/
|
||||
|
||||
public class PRandomAccessBinaryFile extends RandomAccessFile {
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
||||
/**
|
||||
* Created by Stardust on 2017/4/6.
|
||||
*/
|
||||
|
||||
public class PReadableBinaryFile implements Closeable {
|
||||
|
||||
|
||||
|
||||
@@ -7,14 +7,13 @@ import java.util.List;
|
||||
/**
|
||||
* Created by Stardust on 2017/4/1.
|
||||
*/
|
||||
|
||||
public class PReadableTextFile implements Closeable, PFileInterface {
|
||||
|
||||
private BufferedReader mBufferedReader;
|
||||
private FileInputStream mFileInputStream;
|
||||
private int mBufferingSize;
|
||||
private String mEncoding;
|
||||
private String mPath;
|
||||
private final FileInputStream mFileInputStream;
|
||||
private final int mBufferingSize;
|
||||
private final String mEncoding;
|
||||
private final String mPath;
|
||||
|
||||
public PReadableTextFile(String path) {
|
||||
this(path, PFiles.DEFAULT_ENCODING);
|
||||
@@ -87,7 +86,7 @@ public class PReadableTextFile implements Closeable, PFileInterface {
|
||||
while (mBufferedReader.ready()) {
|
||||
lines.add(mBufferedReader.readLine());
|
||||
}
|
||||
return lines.toArray(new String[lines.size()]);
|
||||
return lines.toArray(new String[0]);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import static com.stardust.pio.PFiles.DEFAULT_BUFFER_SIZE;
|
||||
/**
|
||||
* Created by Stardust on 2017/4/1.
|
||||
*/
|
||||
|
||||
public class PWritableTextFile implements Closeable, PFileInterface {
|
||||
|
||||
public static PWritableTextFile open(String path, String encoding, int bufferSize) {
|
||||
@@ -34,8 +33,8 @@ public class PWritableTextFile implements Closeable, PFileInterface {
|
||||
return new PWritableTextFile(path);
|
||||
}
|
||||
|
||||
private BufferedWriter mBufferedWriter;
|
||||
private String mPath;
|
||||
private final BufferedWriter mBufferedWriter;
|
||||
private final String mPath;
|
||||
|
||||
public PWritableTextFile(String path, String encoding, int bufferingSize, boolean append) {
|
||||
mPath = path;
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.io.IOException;
|
||||
/**
|
||||
* Created by Stardust on 2017/4/1.
|
||||
*/
|
||||
|
||||
public class UncheckedIOException extends RuntimeException {
|
||||
|
||||
public UncheckedIOException(IOException cause) {
|
||||
|
||||
Reference in New Issue
Block a user