0N/A/*
2362N/A * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.io;
0N/A
0N/A
0N/A/**
0N/A * Package-private abstract class for the local filesystem abstraction.
0N/A */
0N/A
0N/Aabstract class FileSystem {
0N/A
0N/A /**
0N/A * Return the FileSystem object representing this platform's local
0N/A * filesystem.
0N/A */
0N/A public static native FileSystem getFileSystem();
0N/A
0N/A
0N/A /* -- Normalization and construction -- */
0N/A
0N/A /**
0N/A * Return the local filesystem's name-separator character.
0N/A */
0N/A public abstract char getSeparator();
0N/A
0N/A /**
0N/A * Return the local filesystem's path-separator character.
0N/A */
0N/A public abstract char getPathSeparator();
0N/A
0N/A /**
0N/A * Convert the given pathname string to normal form. If the string is
0N/A * already in normal form then it is simply returned.
0N/A */
0N/A public abstract String normalize(String path);
0N/A
0N/A /**
0N/A * Compute the length of this pathname string's prefix. The pathname
0N/A * string must be in normal form.
0N/A */
0N/A public abstract int prefixLength(String path);
0N/A
0N/A /**
0N/A * Resolve the child pathname string against the parent.
0N/A * Both strings must be in normal form, and the result
0N/A * will be in normal form.
0N/A */
0N/A public abstract String resolve(String parent, String child);
0N/A
0N/A /**
0N/A * Return the parent pathname string to be used when the parent-directory
0N/A * argument in one of the two-argument File constructors is the empty
0N/A * pathname.
0N/A */
0N/A public abstract String getDefaultParent();
0N/A
0N/A /**
0N/A * Post-process the given URI path string if necessary. This is used on
0N/A * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string
0N/A * still has slash separators; code in the File class will translate them
0N/A * after this method returns.
0N/A */
0N/A public abstract String fromURIPath(String path);
0N/A
0N/A
0N/A /* -- Path operations -- */
0N/A
0N/A /**
0N/A * Tell whether or not the given abstract pathname is absolute.
0N/A */
0N/A public abstract boolean isAbsolute(File f);
0N/A
0N/A /**
0N/A * Resolve the given abstract pathname into absolute form. Invoked by the
0N/A * getAbsolutePath and getCanonicalPath methods in the File class.
0N/A */
0N/A public abstract String resolve(File f);
0N/A
0N/A public abstract String canonicalize(String path) throws IOException;
0N/A
0N/A
0N/A /* -- Attribute accessors -- */
0N/A
0N/A /* Constants for simple boolean attributes */
0N/A public static final int BA_EXISTS = 0x01;
0N/A public static final int BA_REGULAR = 0x02;
0N/A public static final int BA_DIRECTORY = 0x04;
0N/A public static final int BA_HIDDEN = 0x08;
0N/A
0N/A /**
0N/A * Return the simple boolean attributes for the file or directory denoted
0N/A * by the given abstract pathname, or zero if it does not exist or some
0N/A * other I/O error occurs.
0N/A */
0N/A public abstract int getBooleanAttributes(File f);
0N/A
0N/A public static final int ACCESS_READ = 0x04;
0N/A public static final int ACCESS_WRITE = 0x02;
0N/A public static final int ACCESS_EXECUTE = 0x01;
0N/A
0N/A /**
0N/A * Check whether the file or directory denoted by the given abstract
0N/A * pathname may be accessed by this process. The second argument specifies
0N/A * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check.
0N/A * Return false if access is denied or an I/O error occurs
0N/A */
0N/A public abstract boolean checkAccess(File f, int access);
0N/A /**
0N/A * Set on or off the access permission (to owner only or to all) to the file
0N/A * or directory denoted by the given abstract pathname, based on the parameters
0N/A * enable, access and oweronly.
0N/A */
0N/A public abstract boolean setPermission(File f, int access, boolean enable, boolean owneronly);
0N/A
0N/A /**
0N/A * Return the time at which the file or directory denoted by the given
0N/A * abstract pathname was last modified, or zero if it does not exist or
0N/A * some other I/O error occurs.
0N/A */
0N/A public abstract long getLastModifiedTime(File f);
0N/A
0N/A /**
0N/A * Return the length in bytes of the file denoted by the given abstract
0N/A * pathname, or zero if it does not exist, is a directory, or some other
0N/A * I/O error occurs.
0N/A */
0N/A public abstract long getLength(File f);
0N/A
0N/A
0N/A /* -- File operations -- */
0N/A
0N/A /**
0N/A * Create a new empty file with the given pathname. Return
0N/A * <code>true</code> if the file was created and <code>false</code> if a
0N/A * file or directory with the given pathname already exists. Throw an
0N/A * IOException if an I/O error occurs.
0N/A */
0N/A public abstract boolean createFileExclusively(String pathname)
0N/A throws IOException;
0N/A
0N/A /**
0N/A * Delete the file or directory denoted by the given abstract pathname,
0N/A * returning <code>true</code> if and only if the operation succeeds.
0N/A */
0N/A public abstract boolean delete(File f);
0N/A
0N/A /**
0N/A * List the elements of the directory denoted by the given abstract
0N/A * pathname. Return an array of strings naming the elements of the
0N/A * directory if successful; otherwise, return <code>null</code>.
0N/A */
0N/A public abstract String[] list(File f);
0N/A
0N/A /**
0N/A * Create a new directory denoted by the given abstract pathname,
0N/A * returning <code>true</code> if and only if the operation succeeds.
0N/A */
0N/A public abstract boolean createDirectory(File f);
0N/A
0N/A /**
0N/A * Rename the file or directory denoted by the first abstract pathname to
0N/A * the second abstract pathname, returning <code>true</code> if and only if
0N/A * the operation succeeds.
0N/A */
0N/A public abstract boolean rename(File f1, File f2);
0N/A
0N/A /**
0N/A * Set the last-modified time of the file or directory denoted by the
0N/A * given abstract pathname, returning <code>true</code> if and only if the
0N/A * operation succeeds.
0N/A */
0N/A public abstract boolean setLastModifiedTime(File f, long time);
0N/A
0N/A /**
0N/A * Mark the file or directory denoted by the given abstract pathname as
0N/A * read-only, returning <code>true</code> if and only if the operation
0N/A * succeeds.
0N/A */
0N/A public abstract boolean setReadOnly(File f);
0N/A
0N/A
0N/A /* -- Filesystem interface -- */
0N/A
0N/A /**
0N/A * List the available filesystem roots.
0N/A */
0N/A public abstract File[] listRoots();
0N/A
0N/A /* -- Disk usage -- */
0N/A public static final int SPACE_TOTAL = 0;
0N/A public static final int SPACE_FREE = 1;
0N/A public static final int SPACE_USABLE = 2;
0N/A
0N/A public abstract long getSpace(File f, int t);
0N/A
0N/A /* -- Basic infrastructure -- */
0N/A
0N/A /**
0N/A * Compare two abstract pathnames lexicographically.
0N/A */
0N/A public abstract int compare(File f1, File f2);
0N/A
0N/A /**
0N/A * Compute the hash code of an abstract pathname.
0N/A */
0N/A public abstract int hashCode(File f);
0N/A
0N/A // Flags for enabling/disabling performance optimizations for file
0N/A // name canonicalization
0N/A static boolean useCanonCaches = true;
0N/A static boolean useCanonPrefixCache = true;
0N/A
0N/A private static boolean getBooleanProperty(String prop, boolean defaultVal) {
0N/A String val = System.getProperty(prop);
0N/A if (val == null) return defaultVal;
0N/A if (val.equalsIgnoreCase("true")) {
0N/A return true;
0N/A } else {
0N/A return false;
0N/A }
0N/A }
0N/A
0N/A static {
0N/A useCanonCaches = getBooleanProperty("sun.io.useCanonCaches",
0N/A useCanonCaches);
0N/A useCanonPrefixCache = getBooleanProperty("sun.io.useCanonPrefixCache",
0N/A useCanonPrefixCache);
0N/A }
0N/A}