aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io/natFileWin32.cc
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>2001-04-01 11:16:40 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2001-04-01 12:16:40 +0100
commitf40475404235a392b16bb7db048fc18c56af3604 (patch)
tree64ffcb42dcabba681035f83df8bad41e16ad89de /libjava/java/io/natFileWin32.cc
parente74061a981cd8d62e366c6bc96454250e7da0450 (diff)
downloadgcc-f40475404235a392b16bb7db048fc18c56af3604.zip
gcc-f40475404235a392b16bb7db048fc18c56af3604.tar.gz
gcc-f40475404235a392b16bb7db048fc18c56af3604.tar.bz2
1.3-Compliant Implementation of java.io.File.
* java/lang/natSystem.cc (init_properties): Get "file.separator", "path.separator", and "java.io.tmpdir" from the File class, instead of setting them explicitly. * java/io/File.java: Do not canonicalize paths for security manager checks. Call init_native() from static initializer. Do not pass path argument to native methods. New native method declarations. Some security manager checks moved to checkWrite(). (equals): Check file system case sensitivity and act appropriatly. (hashCode): Likewise. (isHidden): New method implemented. (performList): Changed prototype. Now takes a class argument specifying the class of the returned array: Strings or File objects. Also added FileFilter argument. (listFiles): New variants with "File" return type implemented. (createTempFile): Use createNewFile(). Use maxPathLen. (setReadOnly): New method implemented. (listRoots): Likewise. (compareTo): Likewise. (setLastModified): Likewise. (checkWrite): New method. (setPath): Removed. * java/io/natFile.cc: Various functions no longer take canonical path argument. (stat): Handle ISHIDDEN query. (isAbsolute): Remove WIN32 cruft. (performList): New arguments. Handle returning either File[] or String[] arrays. Check with FileFilter or FilenameFilter arguments as appropriate. Use an ArrayList, not a Vector, for the temporary list. (performSetReadOnly): New method implemented. (performListRoots): Likewise. (performSetLastModified): Likewise. (performCreate): Likewise. (init_native): New initialization function. * java/io/natFileWin32.cc: Various functions no longer take canonical path argument. (stat): Add FIXME about ISHIDDEN query. (performList): New arguments. Handle returning either File[] or String[] arrays. Check with FileFilter or FilenameFilter arguments as appropriate. Use an ArrayList, not a Vector, for the temporary list. (performSetReadOnly): New. Stubbed. (performListRoots): Likewise. (performSetLastModified): Likewise. (performCreate): Likewise. (init_native) New initialization function. * configure.in: Check for utime() and chmod(). * configure: Rebuilt. * include/config.h.in: Rebuilt. Resolves PR libgcj/1759. From-SVN: r40985
Diffstat (limited to 'libjava/java/io/natFileWin32.cc')
-rw-r--r--libjava/java/io/natFileWin32.cc96
1 files changed, 71 insertions, 25 deletions
diff --git a/libjava/java/io/natFileWin32.cc b/libjava/java/io/natFileWin32.cc
index 95be487..2f0b8af 100644
--- a/libjava/java/io/natFileWin32.cc
+++ b/libjava/java/io/natFileWin32.cc
@@ -1,6 +1,6 @@
-// natFileWin32.cc - Native part of File class.
+// natFileWin32.cc - Native part of File class for Win32.
-/* Copyright (C) 1998, 1999 Red Hat, Inc.
+/* Copyright (C) 1998, 1999, 2001 Red Hat, Inc.
This file is part of libgcj.
@@ -25,12 +25,10 @@ details. */
#include <java/lang/System.h>
jboolean
-java::io::File::access (jstring canon, jint query)
+java::io::File::access (jint query)
{
- if (! canon)
- return false;
char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
// FIXME?
buf[total] = '\0';
@@ -48,15 +46,15 @@ java::io::File::access (jstring canon, jint query)
}
jboolean
-java::io::File::stat (jstring canon, jint query)
+java::io::File::stat (jint query)
{
- if (! canon)
- return false;
char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
// FIXME?
buf[total] = '\0';
+ // FIXME: Need to handle ISHIDDEN query.
+
JvAssert (query == DIRECTORY || query == ISFILE);
DWORD attributes = GetFileAttributes (buf);
@@ -70,12 +68,10 @@ java::io::File::stat (jstring canon, jint query)
}
jlong
-java::io::File::attr (jstring canon, jint query)
+java::io::File::attr (jint query)
{
- if (! canon)
- return false;
char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
// FIXME?
buf[total] = '\0';
@@ -128,12 +124,12 @@ java::io::File::isAbsolute (void)
}
jstringArray
-java::io::File::performList (jstring canon, FilenameFilter *filter)
+java::io::File::performList (java::io::FilenameFilter *filter,
+ java::io::FileFilter *fileFilter,
+ java::lang::Class *result_type)
{
- if (! canon)
- return NULL;
char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
+ jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
// FIXME?
strcpy(&buf[total], "\\*.*");
@@ -142,16 +138,28 @@ java::io::File::performList (jstring canon, FilenameFilter *filter)
if (handle == INVALID_HANDLE_VALUE)
return NULL;
- java::util::Vector *vec = new java::util::Vector ();
+ java::util::ArrayList *list = new java::util::ArrayList ();
do
{
if (strcmp (data.cFileName, ".") && strcmp (data.cFileName, ".."))
{
jstring name = JvNewStringUTF (data.cFileName);
- if (! filter || (filter && filter->accept(this, name)))
- vec->addElement (name);
- }
+
+ if (filter && ! filter->accept(this, name))
+ continue;
+
+ if (result_type == &java::io::File::class$)
+ {
+ java::io::File *file = new java::io::File (this, name);
+ if (fileFilter && ! fileFilter->accept(file))
+ continue;
+
+ list->add(file);
+ }
+ else
+ list->add(name);
+ }
}
while (FindNextFile (handle, &data));
@@ -160,7 +168,7 @@ java::io::File::performList (jstring canon, FilenameFilter *filter)
FindClose (handle);
- jobjectArray ret = JvNewObjectArray (vec->size(), canon->getClass(), NULL);
+ jobjectArray ret = JvNewObjectArray (vec->size(), path->getClass(), NULL);
vec->copyInto (ret);
return reinterpret_cast<jstringArray> (ret);
}
@@ -177,6 +185,20 @@ java::io::File::performMkdir (void)
}
jboolean
+java::io::File::performSetReadOnly (void)
+{
+ // PLEASE IMPLEMENT ME
+ return false;
+}
+
+JArray< ::java::io::File *>*
+java::io::File::performListRoots ()
+{
+ // PLEASE IMPLEMENT ME
+ return NULL;
+}
+
+jboolean
java::io::File::performRenameTo (File *dest)
{
char buf[MAX_PATH];
@@ -192,10 +214,24 @@ java::io::File::performRenameTo (File *dest)
}
jboolean
-java::io::File::performDelete (jstring canon)
+java::io::File::performSetLastModified (jlong time)
+{
+ // PLEASE IMPLEMENT ME
+ return false;
+}
+
+jboolean
+java::io::File::performCreate (void)
+{
+ // PLEASE IMPLEMENT ME
+ return false;
+}
+
+jboolean
+java::io::File::performDelete ()
{
char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion(canon, 0, canon->length(), buf);
+ jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf);
// FIXME?
buf[total] = '\0';
@@ -208,3 +244,13 @@ java::io::File::performDelete (jstring canon)
else
return (DeleteFile (buf)) ? true : false;
}
+
+void
+java::io::File::init_native ()
+{
+ separator = JvNewStringLatin1 ("\\");
+ pathSeparator = JvNewStringLatin1 (";");
+ tmpdir = JvNewStringLatin1 ("C:\\temp"); // FIXME?
+ maxPathLen = MAX_PATH;
+ caseSensitive = false;
+}