/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
public class WindowsFileSystemProvider
extends AbstractFileSystemProvider
{
public WindowsFileSystemProvider() {
}
return "file";
}
throw new IllegalArgumentException("URI does not match this provider");
throw new IllegalArgumentException("Authority component present");
throw new IllegalArgumentException("Path component is undefined");
throw new IllegalArgumentException("Path component should be '/'");
throw new IllegalArgumentException("Query component present");
throw new IllegalArgumentException("Fragment component present");
}
throws IOException
{
throw new FileSystemAlreadyExistsException();
}
return theFileSystem;
}
}
FileAttribute<?>... attrs)
throws IOException
{
throw new NullPointerException();
if (!(path instanceof WindowsPath))
throw new ProviderMismatchException();
try {
return WindowsChannelFactory
} catch (WindowsException x) {
return null;
} finally {
}
}
FileAttribute<?>... attrs)
throws IOException
{
throw new NullPointerException();
if (!(path instanceof WindowsPath))
throw new ProviderMismatchException();
try {
return WindowsChannelFactory
pool);
} catch (WindowsException x) {
return null;
} finally {
}
}
@SuppressWarnings("unchecked")
public <V extends FileAttributeView> V
{
throw new NullPointerException();
if (view == BasicFileAttributeView.class)
if (view == DosFileAttributeView.class)
if (view == AclFileAttributeView.class)
if (view == FileOwnerAttributeView.class)
return (V) new FileOwnerAttributeViewImpl(
if (view == UserDefinedFileAttributeView.class)
return (V) null;
}
@SuppressWarnings("unchecked")
LinkOption... options)
throws IOException
{
if (type == BasicFileAttributes.class)
view = BasicFileAttributeView.class;
else if (type == DosFileAttributes.class)
view = DosFileAttributeView.class;
throw new NullPointerException();
else
throw new UnsupportedOperationException();
}
public DynamicFileAttributeView getFileAttributeView(Path obj, String name, LinkOption... options) {
return new FileOwnerAttributeViewImpl(
return null;
}
FileAttribute<?>... attrs)
throws IOException
{
try {
return WindowsChannelFactory
} catch (WindowsException x) {
return null; // keep compiler happy
} finally {
}
}
file.checkDelete();
try {
// need to know if file is a directory or junction
} else {
}
return true;
} catch (WindowsException x) {
// no-op if file does not exist
if (!failIfNotExists &&
(x.lastError() == ERROR_FILE_NOT_FOUND ||
x.lastError() == ERROR_PATH_NOT_FOUND)) return false;
// ERROR_ALREADY_EXISTS is returned when attempting to delete
// non-empty directory on SAMBA servers.
if (x.lastError() == ERROR_DIR_NOT_EMPTY ||
x.lastError() == ERROR_ALREADY_EXISTS)
{
throw new DirectoryNotEmptyException(
}
}
return false;
}
}
throws IOException
{
options);
}
throws IOException
{
options);
}
/**
* Checks the file security against desired access.
*/
// read security descriptor containing ACL (symlinks are followed)
boolean hasRights = false;
try {
} catch (WindowsException exc) {
} finally {
}
return hasRights;
}
/**
* Checks if the given file(or directory) exists and is readable.
*/
try {
opts,
0L);
} catch (WindowsException exc) {
// Windows errors are very inconsistent when the file is a directory
// (ERROR_PATH_NOT_FOUND returned for root directories for example)
// so we retry by attempting to open it as a directory.
try {
} catch (IOException ioe) {
// translate and throw original exception
}
}
}
boolean r = false;
boolean w = false;
boolean x = false;
switch (mode) {
case READ : r = true; break;
case WRITE : w = true; break;
case EXECUTE : x = true; break;
default: throw new AssertionError("Should not get here");
}
}
// special-case read access to avoid needing to determine effective
// access to file; default if modes not specified
if (!w && !x) {
return;
}
int mask = 0;
if (r) {
mask |= FILE_READ_DATA;
}
if (w) {
file.checkWrite();
mask |= FILE_WRITE_DATA;
}
if (x) {
mask |= FILE_EXECUTE;
}
throw new AccessDeniedException(
"Permissions does not allow requested access");
// for write access we neeed to check if the DOS readonly attribute
// and if the volume is read-only
if (w) {
try {
throw new AccessDeniedException(
"DOS readonly attribute is set");
} catch (WindowsException exc) {
}
throw new AccessDeniedException(
}
}
}
return true;
throw new NullPointerException();
if (!(obj2 instanceof WindowsPath))
return false;
// check security manager access to both files
// open both files and see if they are the same
long h1 = 0L;
try {
} catch (WindowsException x) {
}
try {
try {
} catch (WindowsException x) {
}
long h2 = 0L;
try {
} catch (WindowsException x) {
}
try {
try {
} catch (WindowsException x) {
}
} finally {
}
} finally {
}
}
try {
} catch (WindowsException x) {
}
// DOS hidden attribute not meaningful when set on directories
if (attrs.isDirectory())
return false;
}
}
}
throws IOException
{
dir.checkWrite();
try {
} catch (WindowsException x) {
} finally {
}
}
public DirectoryStream<Path> newDirectoryStream(Path obj, DirectoryStream.Filter<? super Path> filter)
throws IOException
{
throw new NullPointerException();
}
throws IOException
{
throw new UnsupportedOperationException("Symbolic links not supported "
+ "on this operating system");
}
// no attributes allowed
throw new UnsupportedOperationException("Initial file attributes" +
"not supported when creating symbolic link");
}
// permission check
link.checkWrite();
}
/**
* Throw I/O exception for the drive-relative case because Windows
* creates a link with the resolved target for this case.
*/
throw new IOException("Cannot create symbolic link to working directory relative target");
}
/*
* Windows treates symbolic links to directories differently than it
* does to other file types. For that reason we need to check if the
* target is a directory (or a directory junction).
*/
} else {
}
int flags = 0;
try {
} catch (WindowsException x) {
// unable to access target so assume target is not a directory
}
// create the link
try {
flags);
} catch (WindowsException x) {
if (x.lastError() == ERROR_INVALID_REPARSE_DATA) {
} else {
}
}
}
// permission check
link.checkWrite();
}
// create hard link
try {
} catch (WindowsException x) {
}
}
if (!fs.supportsLinks()) {
throw new UnsupportedOperationException("symbolic links not supported");
}
// permission check
}
}
}