зеркало из https://github.com/mono/ikvm-fork.git
First small steps in java.nio.file implementation. Update sun.util.calendar.ZoneInfoFile to OpenJDK 7, because it can now use our java.nio.file implementation.
This commit is contained in:
Родитель
a97a2b8377
Коммит
4d2501e0af
|
@ -200,6 +200,9 @@ sun/nio/ch/Util.java
|
|||
sun/nio/cs/StandardCharsets.java
|
||||
sun/nio/fs/DefaultFileSystemProvider.java
|
||||
sun/nio/fs/DefaultFileTypeDetector.java
|
||||
sun/nio/fs/NetFileSystem.java
|
||||
sun/nio/fs/NetFileSystemProvider.java
|
||||
sun/nio/fs/NetPath.java
|
||||
sun/print/PrintPeer.java
|
||||
sun/print/UnixPrintServiceLookup.java
|
||||
sun/print/Win32PrintJob.java
|
||||
|
@ -13130,7 +13133,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java
|
|||
@OPENJDK7@/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/calendar/TzIDOldMapping.java
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java
|
||||
@OPENJDK6@/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/locale/AsciiUtil.java
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/locale/BaseLocale.java
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/locale/Extension.java
|
||||
|
|
|
@ -727,7 +727,6 @@ assembly.class
|
|||
@OPENJDK7@/jdk/src/share/classes/java/util/prefs/*.class
|
||||
@OPENJDK7@/jdk/src/share/classes/java/util/spi/*.class
|
||||
@OPENJDK7@/jdk/src/share/classes/java/util/zip/*.class
|
||||
@OPENJDK6@/jdk/src/share/classes/sun/util/calendar/*.class
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/calendar/*.class
|
||||
@OPENJDK7@/jdk/src/share/classes/sun/util/resources/*.class
|
||||
@OPENJDK7@/jdk/src/solaris/classes/java/util/prefs/*.class
|
||||
|
|
|
@ -30,6 +30,6 @@ public class DefaultFileSystemProvider
|
|||
{
|
||||
public static FileSystemProvider create()
|
||||
{
|
||||
throw new ikvm.internal.NotYetImplementedError();
|
||||
return new NetFileSystemProvider();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
Copyright (C) 2011 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
|
||||
package sun.nio.fs;
|
||||
|
||||
import ikvm.internal.NotYetImplementedError;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.util.Set;
|
||||
|
||||
final class NetFileSystem extends FileSystem
|
||||
{
|
||||
private final NetFileSystemProvider provider;
|
||||
private final String separator = Character.toString(cli.System.IO.Path.DirectorySeparatorChar);
|
||||
|
||||
NetFileSystem(NetFileSystemProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public FileSystemProvider provider()
|
||||
{
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getSeparator()
|
||||
{
|
||||
return separator;
|
||||
}
|
||||
|
||||
public Iterable<Path> getRootDirectories()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Iterable<FileStore> getFileStores()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Set<String> supportedFileAttributeViews()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path getPath(String first, String... more)
|
||||
{
|
||||
if (more.length == 0)
|
||||
{
|
||||
return new NetPath(this, first);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(first);
|
||||
String sep = sb.length() == 0 ? "" : separator;
|
||||
for (String s : more)
|
||||
{
|
||||
if (s.length() != 0)
|
||||
{
|
||||
sb.append(sep);
|
||||
sb.append(s);
|
||||
sep = separator;
|
||||
}
|
||||
}
|
||||
return new NetPath(this, sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public PathMatcher getPathMatcher(String syntaxAndPattern)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public UserPrincipalLookupService getUserPrincipalLookupService()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public WatchService newWatchService() throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
Copyright (C) 2011 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
|
||||
package sun.nio.fs;
|
||||
|
||||
import ikvm.internal.NotYetImplementedError;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
final class NetFileSystemProvider extends AbstractFileSystemProvider
|
||||
{
|
||||
private final NetFileSystem fs = new NetFileSystem(this);
|
||||
|
||||
public String getScheme()
|
||||
{
|
||||
return "file";
|
||||
}
|
||||
|
||||
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException
|
||||
{
|
||||
throw new FileSystemAlreadyExistsException();
|
||||
}
|
||||
|
||||
public FileSystem getFileSystem(URI uri)
|
||||
{
|
||||
return fs;
|
||||
}
|
||||
|
||||
public Path getPath(URI uri)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public void copy(Path source, Path target, CopyOption... options) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public void move(Path source, Path target, CopyOption... options) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public boolean isSameFile(Path path, Path path2) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public boolean isHidden(Path path) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public FileStore getFileStore(Path path) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public void checkAccess(Path path, AccessMode... modes) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
DynamicFileAttributeView getFileAttributeView(Path file, String name, LinkOption... options)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean implDelete(Path file, boolean failIfNotExists) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
Copyright (C) 2011 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
|
||||
package sun.nio.fs;
|
||||
|
||||
import ikvm.internal.NotYetImplementedError;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.*;
|
||||
import java.util.Iterator;
|
||||
import static ikvm.internal.Util.MACOSX;
|
||||
import static ikvm.internal.Util.WINDOWS;
|
||||
|
||||
final class NetPath extends AbstractPath
|
||||
{
|
||||
private static final char[] invalid = cli.System.IO.Path.GetInvalidFileNameChars();
|
||||
private final NetFileSystem fs;
|
||||
private final String path;
|
||||
|
||||
NetPath(NetFileSystem fs, String path)
|
||||
{
|
||||
StringBuilder sb = null;
|
||||
int separatorCount = 0;
|
||||
boolean prevWasSeparator = false;
|
||||
for (int i = 0; i < path.length(); i++)
|
||||
{
|
||||
char c = path.charAt(i);
|
||||
if (c == cli.System.IO.Path.AltDirectorySeparatorChar)
|
||||
{
|
||||
if (sb == null)
|
||||
{
|
||||
sb = new StringBuilder();
|
||||
sb.append(path, 0, i);
|
||||
}
|
||||
c = cli.System.IO.Path.DirectorySeparatorChar;
|
||||
}
|
||||
if (c == cli.System.IO.Path.DirectorySeparatorChar)
|
||||
{
|
||||
if (prevWasSeparator && (i != 1 || c != '\\'))
|
||||
{
|
||||
if (sb == null)
|
||||
{
|
||||
sb = new StringBuilder();
|
||||
sb.append(path, 0, i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
separatorCount++;
|
||||
prevWasSeparator = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevWasSeparator = false;
|
||||
}
|
||||
if (sb != null)
|
||||
{
|
||||
sb.append(c);
|
||||
}
|
||||
if (c == cli.System.IO.Path.DirectorySeparatorChar)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (c == ':' && i > 0)
|
||||
{
|
||||
char d = path.charAt(0);
|
||||
if (((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z')) && i == 1 && WINDOWS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (MACOSX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (char inv : invalid)
|
||||
{
|
||||
if (inv == c)
|
||||
{
|
||||
throw new InvalidPathException(path, "Illegal char <" + c + ">", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sb != null)
|
||||
{
|
||||
path = sb.toString();
|
||||
}
|
||||
if (path.startsWith("\\\\") && WINDOWS)
|
||||
{
|
||||
if (separatorCount == 2 || (separatorCount == 3 && path.endsWith("\\")))
|
||||
{
|
||||
throw new InvalidPathException(path, "UNC path is missing sharename");
|
||||
}
|
||||
else if (separatorCount == 3)
|
||||
{
|
||||
path += '\\';
|
||||
}
|
||||
}
|
||||
else if (path.length() > 0 && path.charAt(path.length() - 1) == cli.System.IO.Path.DirectorySeparatorChar)
|
||||
{
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
this.fs = fs;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public FileSystem getFileSystem()
|
||||
{
|
||||
return fs;
|
||||
}
|
||||
|
||||
public boolean isAbsolute()
|
||||
{
|
||||
return cli.System.IO.Path.IsPathRooted(path)
|
||||
&& (!WINDOWS || path.startsWith("\\\\") || (path.length() >= 3 && path.charAt(1) == ':' && path.charAt(2) == '\\'));
|
||||
}
|
||||
|
||||
public Path getRoot()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path getFileName()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path getParent()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public int getNameCount()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path getName(int index)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path subpath(int beginIndex, int endIndex)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public boolean startsWith(Path other)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public boolean endsWith(Path other)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path normalize()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path resolve(Path other)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path relativize(Path other)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public URI toUri()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public Path toAbsolutePath()
|
||||
{
|
||||
if (isAbsolute())
|
||||
{
|
||||
return this;
|
||||
}
|
||||
return new NetPath(fs, cli.System.IO.Path.GetFullPath(cli.System.IO.Path.Combine(System.getProperty("user.dir"), path)));
|
||||
}
|
||||
|
||||
public Path toRealPath(LinkOption... options) throws IOException
|
||||
{
|
||||
return new NetPath(fs, toRealPathImpl(path));
|
||||
}
|
||||
|
||||
private static native String toRealPathImpl(String path);
|
||||
|
||||
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public int compareTo(Path other)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
|
@ -5880,6 +5880,62 @@ namespace IKVM.NativeCode.sun.net.spi
|
|||
}
|
||||
}
|
||||
|
||||
namespace IKVM.NativeCode.sun.nio.fs
|
||||
{
|
||||
static class NetPath
|
||||
{
|
||||
public static string toRealPathImpl(string path)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
path = global::java.io.FileSystem.getFileSystem().canonicalize(path);
|
||||
if (VirtualFileSystem.IsVirtualFS(path))
|
||||
{
|
||||
if (VirtualFileSystem.CheckAccess(path, IKVM.NativeCode.java.io.Win32FileSystem.ACCESS_READ))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
throw new global::java.nio.file.NoSuchFileException(path);
|
||||
}
|
||||
try
|
||||
{
|
||||
System.IO.File.GetAttributes(path);
|
||||
return path;
|
||||
}
|
||||
catch (System.IO.FileNotFoundException)
|
||||
{
|
||||
throw new global::java.nio.file.NoSuchFileException(path);
|
||||
}
|
||||
catch (System.IO.DirectoryNotFoundException)
|
||||
{
|
||||
throw new global::java.nio.file.NoSuchFileException(path);
|
||||
}
|
||||
catch (System.UnauthorizedAccessException)
|
||||
{
|
||||
throw new global::java.nio.file.AccessDeniedException(path);
|
||||
}
|
||||
catch (System.Security.SecurityException)
|
||||
{
|
||||
throw new global::java.nio.file.AccessDeniedException(path);
|
||||
}
|
||||
catch (System.ArgumentException x)
|
||||
{
|
||||
throw new global::java.nio.file.FileSystemException(path, null, x.Message);
|
||||
}
|
||||
catch (System.NotSupportedException x)
|
||||
{
|
||||
throw new global::java.nio.file.FileSystemException(path, null, x.Message);
|
||||
}
|
||||
catch (System.IO.IOException x)
|
||||
{
|
||||
throw new global::java.nio.file.FileSystemException(path, null, x.Message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace IKVM.NativeCode.sun.reflect
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
|
|
Загрузка…
Ссылка в новой задаче