2002-02-07 Tom Tromey <tromey@redhat.com>
+ * java/io/natFile.cc (_access): Don't stack-allocate buffer.
+ Size buffer based on real size of string.
+ (_stat): Likewise.
+ (attr): Likewise.
+ (getCanonicalPath): Likewise.
+ (performList): Likewise.
+ (performMkdir): Likewise.
+ (performSetReadOnly): Likewise.
+ (unixroot): Removed.
+ (performRenameTo): Likewise.
+ (performSetLastModified): Likewise.
+ (performCreate): Likewise.
+ (performDelete): Likewise.
+ (performListRoots): Always return new array.
+
* prims.cc (_Jv_CreateJavaVM): Call _Jv_platform_initialize.
* win32.cc (win32_exception_handler): Now static.
* include/win32.h (_Jv_platform_initialize): Declare.
jboolean
java::io::File::_access (jint query)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
JvAssert (query == READ || query == WRITE || query == EXISTS);
jboolean
java::io::File::_stat (jint query)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
jlong
java::io::File::attr (jint query)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
jstring
java::io::File::getCanonicalPath (void)
{
- char buf[MAXPATHLEN], buf2[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char buf2[MAXPATHLEN];
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
/* Some systems have dirent.h, but no directory reading functions like
opendir. */
#if defined(HAVE_DIRENT_H) && defined(HAVE_OPENDIR)
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
if (! dir)
return NULL;
-
java::util::ArrayList *list = new java::util::ArrayList ();
struct dirent *d;
#ifdef HAVE_READDIR_R
jstring name = JvNewStringUTF (d->d_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);
jboolean
java::io::File::performMkdir (void)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
jboolean
java::io::File::performSetReadOnly (void)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
#endif
}
-static JArray<java::io::File *> *unixroot;
-
JArray< ::java::io::File *>*
java::io::File::performListRoots ()
{
- if (unixroot == NULL)
- {
- ::java::io::File *f = new ::java::io::File (JvNewStringLatin1 ("/"));
- unixroot = reinterpret_cast <JArray<java::io::File *>*>
- (JvNewObjectArray (1, &java::io::File::class$, f));
- elements (unixroot) [0] = f;
- }
+ ::java::io::File *f = new ::java::io::File (JvNewStringLatin1 ("/"));
+ JArray<java::io::File *> *unixroot
+ = reinterpret_cast <JArray<java::io::File *>*>
+ (JvNewObjectArray (1, &java::io::File::class$, f));
+ elements (unixroot) [0] = f;
return unixroot;
}
jboolean
java::io::File::performRenameTo (File *dest)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
- char buf2[MAXPATHLEN];
+ char *buf2 = (char *) _Jv_AllocBytes (JvGetStringUTFLength (dest->path) + 1);
total = JvGetStringUTFRegion (dest->path, 0, dest->path->length(), buf2);
buf2[total] = '\0';
#ifdef HAVE_UTIME
utimbuf tb;
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
jboolean
java::io::File::performCreate (void)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
jboolean
java::io::File::performDelete (void)
{
- char buf[MAXPATHLEN];
+ char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';