home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.security.AccessControlException;
- import java.security.AccessController;
- import java.util.ArrayList;
- import java.util.Random;
- import sun.security.action.GetPropertyAction;
-
- public class File implements Serializable, Comparable {
- // $FF: renamed from: fs java.io.FileSystem
- private static FileSystem field_0 = FileSystem.getFileSystem();
- private String path;
- private transient int prefixLength;
- public static final char separatorChar;
- public static final String separator;
- public static final char pathSeparatorChar;
- public static final String pathSeparator;
- private static final Object tmpFileLock;
- private static int counter;
- private static String tmpdir;
- private static final long serialVersionUID = 301077366599181567L;
-
- int getPrefixLength() {
- return this.prefixLength;
- }
-
- private File(String var1, int var2) {
- this.path = var1;
- this.prefixLength = var2;
- }
-
- public File(String var1) {
- if (var1 == null) {
- throw new NullPointerException();
- } else {
- this.path = field_0.normalize(var1);
- this.prefixLength = field_0.prefixLength(this.path);
- }
- }
-
- public File(String var1, String var2) {
- if (var2 == null) {
- throw new NullPointerException();
- } else {
- if (var1 != null) {
- if (var1.equals("")) {
- this.path = field_0.resolve(field_0.getDefaultParent(), field_0.normalize(var2));
- } else {
- this.path = field_0.resolve(field_0.normalize(var1), field_0.normalize(var2));
- }
- } else {
- this.path = field_0.normalize(var2);
- }
-
- this.prefixLength = field_0.prefixLength(this.path);
- }
- }
-
- public File(File var1, String var2) {
- if (var2 == null) {
- throw new NullPointerException();
- } else {
- if (var1 != null) {
- if (var1.path.equals("")) {
- this.path = field_0.resolve(field_0.getDefaultParent(), field_0.normalize(var2));
- } else {
- this.path = field_0.resolve(var1.path, field_0.normalize(var2));
- }
- } else {
- this.path = field_0.normalize(var2);
- }
-
- this.prefixLength = field_0.prefixLength(this.path);
- }
- }
-
- public String getName() {
- int var1 = this.path.lastIndexOf(separatorChar);
- return var1 < this.prefixLength ? this.path.substring(this.prefixLength) : this.path.substring(var1 + 1);
- }
-
- public String getParent() {
- int var1 = this.path.lastIndexOf(separatorChar);
- if (var1 < this.prefixLength) {
- return this.prefixLength > 0 && this.path.length() > this.prefixLength ? this.path.substring(0, this.prefixLength) : null;
- } else {
- return this.path.substring(0, var1);
- }
- }
-
- public File getParentFile() {
- String var1 = this.getParent();
- return var1 == null ? null : new File(var1, this.prefixLength);
- }
-
- public String getPath() {
- return this.path;
- }
-
- public boolean isAbsolute() {
- return field_0.isAbsolute(this);
- }
-
- public String getAbsolutePath() {
- return field_0.resolve(this);
- }
-
- public File getAbsoluteFile() {
- return new File(this.getAbsolutePath());
- }
-
- public String getCanonicalPath() throws IOException {
- return field_0.canonicalize(field_0.resolve(this));
- }
-
- public File getCanonicalFile() throws IOException {
- return new File(this.getCanonicalPath());
- }
-
- public URL toURL() throws MalformedURLException {
- String var1 = this.getAbsolutePath();
- if (separatorChar != '/') {
- var1 = var1.replace(separatorChar, '/');
- }
-
- if (!var1.startsWith("/")) {
- var1 = "/" + var1;
- }
-
- if (!var1.endsWith("/") && this.isDirectory()) {
- var1 = var1 + "/";
- }
-
- return new URL("file", "", var1);
- }
-
- public boolean canRead() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return field_0.checkAccess(this, false);
- }
-
- public boolean canWrite() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkWrite(this.path);
- }
-
- return field_0.checkAccess(this, true);
- }
-
- public boolean exists() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return (field_0.getBooleanAttributes(this) & 1) != 0;
- }
-
- public boolean isDirectory() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return (field_0.getBooleanAttributes(this) & 4) != 0;
- }
-
- public boolean isFile() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return (field_0.getBooleanAttributes(this) & 2) != 0;
- }
-
- public boolean isHidden() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return (field_0.getBooleanAttributes(this) & 8) != 0;
- }
-
- public long lastModified() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return field_0.getLastModifiedTime(this);
- }
-
- public long length() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return field_0.getLength(this);
- }
-
- public boolean createNewFile() throws IOException {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkWrite(this.path);
- }
-
- return field_0.createFileExclusively(this.path);
- }
-
- public boolean delete() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkDelete(this.path);
- }
-
- return field_0.delete(this);
- }
-
- public void deleteOnExit() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkDelete(this.path);
- }
-
- field_0.deleteOnExit(this);
- }
-
- public String[] list() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkRead(this.path);
- }
-
- return field_0.list(this);
- }
-
- public String[] list(FilenameFilter var1) {
- String[] var2 = this.list();
- if (var2 != null && var1 != null) {
- ArrayList var3 = new ArrayList();
-
- for(int var4 = 0; var4 < var2.length; ++var4) {
- if (var1.accept(this, var2[var4])) {
- var3.add(var2[var4]);
- }
- }
-
- return (String[])var3.toArray(new String[0]);
- } else {
- return var2;
- }
- }
-
- public File[] listFiles() {
- String[] var1 = this.list();
- if (var1 == null) {
- return null;
- } else {
- int var2 = var1.length;
- File[] var3 = new File[var2];
-
- for(int var4 = 0; var4 < var2; ++var4) {
- var3[var4] = new File(this.path, var1[var4]);
- }
-
- return var3;
- }
- }
-
- public File[] listFiles(FilenameFilter var1) {
- String[] var2 = this.list();
- if (var2 == null) {
- return null;
- } else {
- ArrayList var3 = new ArrayList();
-
- for(int var4 = 0; var4 < var2.length; ++var4) {
- if (var1 == null || var1.accept(this, var2[var4])) {
- var3.add(new File(this.path, var2[var4]));
- }
- }
-
- return (File[])var3.toArray(new File[0]);
- }
- }
-
- public File[] listFiles(FileFilter var1) {
- String[] var2 = this.list();
- if (var2 == null) {
- return null;
- } else {
- ArrayList var3 = new ArrayList();
-
- for(int var4 = 0; var4 < var2.length; ++var4) {
- File var5 = new File(this.path, var2[var4]);
- if (var1 == null || var1.accept(var5)) {
- var3.add(var5);
- }
- }
-
- return (File[])var3.toArray(new File[0]);
- }
- }
-
- public boolean mkdir() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkWrite(this.path);
- }
-
- return field_0.createDirectory(this);
- }
-
- public boolean mkdirs() {
- if (this.exists()) {
- return false;
- } else if (this.mkdir()) {
- return true;
- } else {
- String var1 = this.getParent();
- return var1 != null && (new File(var1)).mkdirs() && this.mkdir();
- }
- }
-
- public boolean renameTo(File var1) {
- SecurityManager var2 = System.getSecurityManager();
- if (var2 != null) {
- var2.checkWrite(this.path);
- var2.checkWrite(var1.path);
- }
-
- return field_0.rename(this, var1);
- }
-
- public boolean setLastModified(long var1) {
- if (var1 < 0L) {
- throw new IllegalArgumentException("Negative time");
- } else {
- SecurityManager var3 = System.getSecurityManager();
- if (var3 != null) {
- var3.checkWrite(this.path);
- }
-
- return field_0.setLastModifiedTime(this, var1);
- }
- }
-
- public boolean setReadOnly() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkWrite(this.path);
- }
-
- return field_0.setReadOnly(this);
- }
-
- public static File[] listRoots() {
- return field_0.listRoots();
- }
-
- private static File generateFile(String var0, String var1, File var2) throws IOException {
- if (counter == -1) {
- counter = (new Random()).nextInt() & '\uffff';
- }
-
- ++counter;
- return new File(var2, var0 + Integer.toString(counter) + var1);
- }
-
- private static String getTempDir() {
- if (tmpdir == null) {
- GetPropertyAction var0 = new GetPropertyAction("java.io.tmpdir");
- tmpdir = (String)AccessController.doPrivileged(var0);
- }
-
- return tmpdir;
- }
-
- private static boolean checkAndCreate(String var0, SecurityManager var1) throws IOException {
- if (var1 != null) {
- try {
- var1.checkWrite(var0);
- } catch (AccessControlException var3) {
- throw new SecurityException("Unable to create temporary file");
- }
- }
-
- return field_0.createFileExclusively(var0);
- }
-
- public static File createTempFile(String var0, String var1, File var2) throws IOException {
- if (var0 == null) {
- throw new NullPointerException();
- } else if (var0.length() < 3) {
- throw new IllegalArgumentException("Prefix string too short");
- } else {
- String var3 = var1 == null ? ".tmp" : var1;
- Object var4 = tmpFileLock;
- synchronized(var4) {
- if (var2 == null) {
- var2 = new File(getTempDir());
- }
-
- SecurityManager var5 = System.getSecurityManager();
-
- File var6;
- do {
- var6 = generateFile(var0, var3, var2);
- } while(!checkAndCreate(var6.getPath(), var5));
-
- return var6;
- }
- }
- }
-
- public static File createTempFile(String var0, String var1) throws IOException {
- return createTempFile(var0, var1, (File)null);
- }
-
- public int compareTo(File var1) {
- return field_0.compare(this, var1);
- }
-
- public int compareTo(Object var1) {
- return this.compareTo((File)var1);
- }
-
- public boolean equals(Object var1) {
- if (var1 != null && var1 instanceof File) {
- return this.compareTo((File)var1) == 0;
- } else {
- return false;
- }
- }
-
- public int hashCode() {
- return field_0.hashCode(this);
- }
-
- public String toString() {
- return this.getPath();
- }
-
- private synchronized void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- var1.writeChar(separatorChar);
- }
-
- private synchronized void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
- var1.defaultReadObject();
- char var2 = var1.readChar();
- if (var2 != separatorChar) {
- this.path = this.path.replace(var2, separatorChar);
- }
-
- this.path = field_0.normalize(this.path);
- this.prefixLength = field_0.prefixLength(this.path);
- }
-
- static {
- separatorChar = field_0.getSeparator();
- separator = "" + separatorChar;
- pathSeparatorChar = field_0.getPathSeparator();
- pathSeparator = "" + pathSeparatorChar;
- tmpFileLock = new Object();
- counter = -1;
- }
- }
-