/* * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
package java.io;
import java.lang.annotation.Native;
/** * Package-private abstract class for the local filesystem abstraction.
*/
abstractclass FileSystem {
/* -- Normalization and construction -- */
/** * Return the local filesystem's name-separator character.
*/ publicabstractchar getSeparator();
/** * Return the local filesystem's path-separator character.
*/ publicabstractchar getPathSeparator();
/** * Convert the given pathname string to normal form. If the string is * already in normal form then it is simply returned.
*/ publicabstract String normalize(String path);
/** * Compute the length of this pathname string's prefix. The pathname * string must be in normal form.
*/ publicabstractint prefixLength(String path);
/** * Resolve the child pathname string against the parent. * Both strings must be in normal form, and the result * will be in normal form.
*/ publicabstract String resolve(String parent, String child);
/** * Return the parent pathname string to be used when the parent-directory * argument in one of the two-argument File constructors is the empty * pathname.
*/ publicabstract String getDefaultParent();
/** * Post-process the given URI path string if necessary. This is used on * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string * still has slash separators; code in the File class will translate them * after this method returns.
*/ publicabstract String fromURIPath(String path);
/* -- Path operations -- */
/** * Tell whether or not the given abstract pathname is absolute.
*/ publicabstractboolean isAbsolute(File f);
/** * Tell whether the given abstract pathname is invalid.
*/ publicabstractboolean isInvalid(File f);
/** * Resolve the given abstract pathname into absolute form. Invoked by the * getAbsolutePath and getCanonicalPath methods in the File class.
*/ publicabstract String resolve(File f);
/** * Return the simple boolean attributes for the file or directory denoted * by the given abstract pathname, or zero if it does not exist or some * other I/O error occurs.
*/ publicabstractint getBooleanAttributes(File f);
/** * Checks if all the given boolean attributes are true for the file or * directory denoted by the given abstract pathname. False if it does not * exist or some other I/O error occurs.
*/ publicboolean hasBooleanAttributes(File f, int attributes) { return (getBooleanAttributes(f) & attributes) == attributes;
}
/** * Check whether the file or directory denoted by the given abstract * pathname may be accessed by this process. The second argument specifies * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check. * Return false if access is denied or an I/O error occurs
*/ publicabstractboolean checkAccess(File f, int access); /** * Set on or off the access permission (to owner only or to all) to the file * or directory denoted by the given abstract pathname, based on the parameters * enable, access and oweronly.
*/ publicabstractboolean setPermission(File f, int access, boolean enable, boolean owneronly);
/** * Return the time at which the file or directory denoted by the given * abstract pathname was last modified, or zero if it does not exist or * some other I/O error occurs.
*/ publicabstractlong getLastModifiedTime(File f);
/** * Return the length in bytes of the file denoted by the given abstract * pathname, or zero if it does not exist, is a directory, or some other * I/O error occurs.
*/ publicabstractlong getLength(File f);
/* -- File operations -- */
/** * Create a new empty file with the given pathname. Return * {@code true} if the file was created and {@code false} if a * file or directory with the given pathname already exists. Throw an * IOException if an I/O error occurs.
*/ publicabstractboolean createFileExclusively(String pathname) throws IOException;
/** * Delete the file or directory denoted by the given abstract pathname, * returning {@code true} if and only if the operation succeeds.
*/ publicabstractbooleandelete(File f);
/** * List the elements of the directory denoted by the given abstract * pathname. Return an array of strings naming the elements of the * directory if successful; otherwise, return {@code null}.
*/ publicabstract String[] list(File f);
/** * Create a new directory denoted by the given abstract pathname, * returning {@code true} if and only if the operation succeeds.
*/ publicabstractboolean createDirectory(File f);
/** * Rename the file or directory denoted by the first abstract pathname to * the second abstract pathname, returning {@code true} if and only if * the operation succeeds.
*/ publicabstractboolean rename(File f1, File f2);
/** * Set the last-modified time of the file or directory denoted by the * given abstract pathname, returning {@code true} if and only if the * operation succeeds.
*/ publicabstractboolean setLastModifiedTime(File f, long time);
/** * Mark the file or directory denoted by the given abstract pathname as * read-only, returning {@code true} if and only if the operation * succeeds.
*/ publicabstractboolean setReadOnly(File f);
/* -- Filesystem interface -- */
/** * List the available filesystem roots.
*/ publicabstract File[] listRoots();
/** * Retrieve the maximum length of a component of a file path. * * @return The maximum length of a file path component.
*/ publicabstractint getNameMax(String path);
/** * Compute the hash code of an abstract pathname.
*/ publicabstractint hashCode(File f);
// Flags for enabling/disabling performance optimizations for file // name canonicalization staticfinalboolean useCanonCaches; staticfinalboolean useCanonPrefixCache;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.28Bemerkung:
(vorverarbeitet)
¤