diff options
author | jfrijters <jfrijters> | 2011-07-12 16:43:25 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-07-12 16:43:25 +0400 |
commit | dbfae89371b72e1d886784a07d187921213eb6e3 (patch) | |
tree | d6c162c7e7a95678b4188c44a5672b0c60c2768b /openjdk | |
parent | 257720a90dbb90dafe63fd227a05fbad6cb401a2 (diff) |
Implemented delete.
Diffstat (limited to 'openjdk')
-rw-r--r-- | openjdk/sun/nio/fs/NetFileSystemProvider.java | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/openjdk/sun/nio/fs/NetFileSystemProvider.java b/openjdk/sun/nio/fs/NetFileSystemProvider.java index 9eb8d1a9..427cde2e 100644 --- a/openjdk/sun/nio/fs/NetFileSystemProvider.java +++ b/openjdk/sun/nio/fs/NetFileSystemProvider.java @@ -274,6 +274,69 @@ final class NetFileSystemProvider extends AbstractFileSystemProvider boolean implDelete(Path file, boolean failIfNotExists) throws IOException { - throw new NotYetImplementedError(); + String path = NetPath.from(file).path; + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + { + sm.checkDelete(path); + } + try + { + if (false) throw new cli.System.ArgumentException(); + if (false) throw new cli.System.IO.FileNotFoundException(); + if (false) throw new cli.System.IO.DirectoryNotFoundException(); + if (false) throw new cli.System.IO.IOException(); + if (false) throw new cli.System.Security.SecurityException(); + if (false) throw new cli.System.UnauthorizedAccessException(); + int attr = cli.System.IO.File.GetAttributes(path).Value; + if ((attr & cli.System.IO.FileAttributes.Directory) != 0) + { + cli.System.IO.Directory.Delete(path); + return true; + } + else + { + cli.System.IO.File.Delete(path); + return true; + } + } + catch (cli.System.ArgumentException x) + { + throw new FileSystemException(path, null, x.getMessage()); + } + catch (cli.System.IO.FileNotFoundException _) + { + if (failIfNotExists) + { + throw new NoSuchFileException(path); + } + else + { + return false; + } + } + catch (cli.System.IO.DirectoryNotFoundException _) + { + if (failIfNotExists) + { + throw new NoSuchFileException(path); + } + else + { + return false; + } + } + catch (cli.System.IO.IOException x) + { + throw new FileSystemException(path, null, x.getMessage()); + } + catch (cli.System.Security.SecurityException _) + { + throw new AccessDeniedException(path); + } + catch (cli.System.UnauthorizedAccessException _) + { + throw new AccessDeniedException(path); + } } } |