aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io
diff options
context:
space:
mode:
authorMohan Embar <gnustuff@thisiscool.com>2003-12-02 22:26:50 +0000
committerMohan Embar <membar@gcc.gnu.org>2003-12-02 22:26:50 +0000
commit83c02e38a3bf8e6d547a292754a581096021b594 (patch)
tree4db34f47c7611b5c83b79334f47f1a5411fbbc44 /libjava/java/io
parent5f8a45f75c9e3785bb7146721910d6ffe4e9d7e6 (diff)
downloadgcc-83c02e38a3bf8e6d547a292754a581096021b594.zip
gcc-83c02e38a3bf8e6d547a292754a581096021b594.tar.gz
gcc-83c02e38a3bf8e6d547a292754a581096021b594.tar.bz2
configure.in: Added new MinGW-specific configure flag --with-win32-nlsapi.
* configure.in: Added new MinGW-specific configure flag --with-win32-nlsapi. Added new AC_DEFINE MINGW_LIBGCJ_UNICODE. Add -lunicows to MinGW SYSTEMSPEC if --with-win32-nlsapi is set to unicows. * configure: Rebuilt. * include/config.h.in: Rebuilt. * win32.cc (_Jv_Win32NewString): Implemented. (nativeToUnicode): New helper function defined only for non-UNICODE builds. (unicodeToNative): Likewise. (_Jv_Win32TempString): Implemented. (lots): Refactored using tchar.h macros. (WSAEventWrapper): Use _Jv_Win32NewString. (_Jv_platform_initialize): Use GetModuleFileNameA instead of GetModuleFileName. (_Jv_platform_initProperties): Use _Jv_Win32NewString. Use temporary stack buffer instead of a heap buffer. * include/win32.h Added defines for UNICODE and _UNICODE if MINGW_LIBGCJ_UNICODE is defined; added tchar.h include. (_Jv_Win32TempString): Declared new helper class. (JV_TEMP_STRING_WIN32): New helper macro. (_Jv_Win32NewString): Declared new helper method. * java/io/natFileDescriptorWin32.cc (open): Use JV_TEMP_STRING_WIN32 instead of JV_TEMP_UTF_STRING. (write): Reformatted slightly. * java/io/natFileWin32.cc (lots): Use tchar.h macros; use JV_TEMP_STRING_WIN32 instead of JV_TEMP_UTF_STRING. (getCanonicalPath): Use _Jv_Win32NewString instead of JvNewStringUTF. (performList): Likewise. * java/lang/natWin32Process.cc (ChildProcessPipe): Use tchar.h macros. (startProcess): Use tchar.h macros, JV_TEMP_STRING_WIN32, and UNICODE environment flag for CreateProcess. * java/net/natNetworkInterfaceWin32.cc (winsock2GetRealNetworkInterfaces): Use tchar.h macros and _Jv_Win32NewString. From-SVN: r74201
Diffstat (limited to 'libjava/java/io')
-rw-r--r--libjava/java/io/natFileDescriptorWin32.cc8
-rw-r--r--libjava/java/io/natFileWin32.cc71
2 files changed, 43 insertions, 36 deletions
diff --git a/libjava/java/io/natFileDescriptorWin32.cc b/libjava/java/io/natFileDescriptorWin32.cc
index 465d755..7811a73 100644
--- a/libjava/java/io/natFileDescriptorWin32.cc
+++ b/libjava/java/io/natFileDescriptorWin32.cc
@@ -87,7 +87,7 @@ java::io::FileDescriptor::open (jstring path, jint jflags) {
DWORD access = 0;
DWORD create = OPEN_EXISTING;
- JV_TEMP_UTF_STRING(cpath, path)
+ JV_TEMP_STRING_WIN32(cpath, path)
JvAssert((jflags & READ) || (jflags & WRITE));
@@ -115,7 +115,8 @@ java::io::FileDescriptor::open (jstring path, jint jflags) {
create = CREATE_ALWAYS;
}
- handle = CreateFile(cpath, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, create, 0, NULL);
+ handle = CreateFile(cpath, access, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, create, 0, NULL);
if (handle == INVALID_HANDLE_VALUE)
{
@@ -174,13 +175,14 @@ java::io::FileDescriptor::write(jbyteArray b, jint offset, jint len)
jbyte *buf = elements (b) + offset;
DWORD bytesWritten;
+
if (WriteFile ((HANDLE)fd, buf, len, &bytesWritten, NULL))
{
if (java::lang::Thread::interrupted())
{
InterruptedIOException *iioe = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
iioe->bytesTransferred = bytesWritten;
- throw iioe;
+ throw iioe;
}
}
else
diff --git a/libjava/java/io/natFileWin32.cc b/libjava/java/io/natFileWin32.cc
index 1559043..cff86dd 100644
--- a/libjava/java/io/natFileWin32.cc
+++ b/libjava/java/io/natFileWin32.cc
@@ -40,7 +40,7 @@ details. */
jboolean
java::io::File::_access (jint query)
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;
@@ -54,13 +54,14 @@ java::io::File::_access (jint query)
if ((query == EXISTS) || (query == READ))
return (attributes == 0xffffffff) ? false : true;
else
- return ((attributes != 0xffffffff) && ((attributes & FILE_ATTRIBUTE_READONLY) == 0)) ? true : false;
+ return ((attributes != 0xffffffff) &&
+ ((attributes & FILE_ATTRIBUTE_READONLY) == 0)) ? true : false;
}
jboolean
java::io::File::_stat (jint query)
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;
@@ -79,7 +80,7 @@ java::io::File::_stat (jint query)
jlong
java::io::File::attr (jint query)
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;
@@ -108,21 +109,19 @@ java::io::File::attr (jint query)
jstring
java::io::File::getCanonicalPath (void)
{
- JV_TEMP_UTF_STRING (cpath, path);
+ JV_TEMP_STRING_WIN32 (cpath, path);
// If the filename is blank, use the current directory.
- const char* thepath = cpath.buf();
- if (*thepath == '\0')
- thepath = ".";
+ LPCTSTR thepath = cpath.buf();
+ if (*thepath == 0)
+ thepath = _T(".");
LPTSTR unused;
- char buf2[MAX_PATH];
+ TCHAR buf2[MAX_PATH];
if(!GetFullPathName(thepath, MAX_PATH, buf2, &unused))
throw new IOException (JvNewStringLatin1 ("GetFullPathName failed"));
- // FIXME: what encoding to assume for file names? This affects many
- // calls.
- return JvNewStringUTF(buf2);
+ return _Jv_Win32NewString (buf2);
}
jboolean
@@ -161,12 +160,17 @@ java::io::File::performList (java::io::FilenameFilter *filter,
jstring canon = getCanonicalPath();
if (! canon)
return NULL;
- char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 5);
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- if (buf[total-1] == '\\')
- strcpy (&buf[total], "*.*");
+
+ int len = canon->length();
+ TCHAR buf[len + 5];
+
+ JV_TEMP_STRING_WIN32(canonstr, canon);
+
+ _tcscpy(buf, canonstr);
+ if (buf[len - 1] == _T('\\'))
+ _tcscpy (&buf[len], _T("*.*"));
else
- strcpy (&buf[total], "\\*.*");
+ _tcscpy (&buf[len], _T("\\*.*"));
WIN32_FIND_DATA data;
HANDLE handle = FindFirstFile (buf, &data);
@@ -177,21 +181,22 @@ java::io::File::performList (java::io::FilenameFilter *filter,
do
{
- if (strcmp (data.cFileName, ".") && strcmp (data.cFileName, ".."))
+ if (_tcscmp (data.cFileName, _T(".")) &&
+ _tcscmp (data.cFileName, _T("..")))
{
- jstring name = JvNewStringUTF (data.cFileName);
+ jstring name = _Jv_Win32NewString (data.cFileName);
if (filter && !filter->accept(this, name))
- continue;
+ continue;
if (clazz == &java::io::File::class$)
- {
+ {
java::io::File *file = new java::io::File (this, name);
if (fileFilter && !fileFilter->accept(file))
- continue;
- vec->addElement (file);
- }
- else
- vec->addElement (name);
+ continue;
+ vec->addElement (file);
+ }
+ else
+ vec->addElement (name);
}
}
while (FindNextFile (handle, &data));
@@ -209,22 +214,22 @@ java::io::File::performList (java::io::FilenameFilter *filter,
jboolean
java::io::File::performMkdir (void)
{
- JV_TEMP_UTF_STRING (cpath, path);
+ JV_TEMP_STRING_WIN32 (cpath, path);
return (CreateDirectory(cpath, NULL)) ? true : false;
}
jboolean
java::io::File::performRenameTo (File *dest)
{
- JV_TEMP_UTF_STRING (pathFrom, path);
- JV_TEMP_UTF_STRING (pathTo, dest->path);
+ JV_TEMP_STRING_WIN32 (pathFrom, path);
+ JV_TEMP_STRING_WIN32 (pathTo, dest->path);
return (MoveFile(pathFrom, pathTo)) ? true : false;
}
jboolean
java::io::File::performDelete ()
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;
@@ -240,7 +245,7 @@ java::io::File::performDelete ()
jboolean java::io::File::performCreate (void)
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;
@@ -262,7 +267,7 @@ jboolean java::io::File::performCreate (void)
jboolean java::io::File::performSetReadOnly ()
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;
@@ -280,7 +285,7 @@ jboolean java::io::File::performSetReadOnly ()
jboolean java::io::File::performSetLastModified (jlong time)
{
- JV_TEMP_UTF_STRING (canon, getCanonicalPath());
+ JV_TEMP_STRING_WIN32 (canon, getCanonicalPath());
if (!canon)
return false;