diff options
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/io/natFileDescriptorWin32.cc | 8 | ||||
-rw-r--r-- | libjava/java/io/natFileWin32.cc | 71 | ||||
-rw-r--r-- | libjava/java/lang/natWin32Process.cc | 48 | ||||
-rw-r--r-- | libjava/java/net/natNetworkInterfaceWin32.cc | 10 |
4 files changed, 75 insertions, 62 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; diff --git a/libjava/java/lang/natWin32Process.cc b/libjava/java/lang/natWin32Process.cc index 56394cf..7337ab3 100644 --- a/libjava/java/lang/natWin32Process.cc +++ b/libjava/java/lang/natWin32Process.cc @@ -173,7 +173,7 @@ ChildProcessPipe::ChildProcessPipe(EType eType): { DWORD dwErrorCode = GetLastError (); throw new java::io::IOException ( - _Jv_WinStrError ("Error creating pipe", dwErrorCode)); + _Jv_WinStrError (_T("Error creating pipe"), dwErrorCode)); } // If this is the read end of the child, we need @@ -220,48 +220,53 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, int cmdLineLen = 0; for (int i = 0; i < progarray->length; ++i) - cmdLineLen += (_Jv_GetStringUTFLength (elts[i]) + 1); + cmdLineLen += (elts[i]->length() + 1); - char *cmdLine = (char *) _Jv_Malloc (cmdLineLen + 1); - char *cmdLineCurPos = cmdLine; + LPTSTR cmdLine = (LPTSTR) _Jv_Malloc ((cmdLineLen + 1) * sizeof(TCHAR)); + LPTSTR cmdLineCurPos = cmdLine; for (int i = 0; i < progarray->length; ++i) { if (i > 0) - *cmdLineCurPos++ = ' '; - jsize s = _Jv_GetStringUTFLength (elts[i]); - _Jv_GetStringUTFRegion (elts[i], 0, elts[i]->length(), cmdLineCurPos); - cmdLineCurPos += s; + *cmdLineCurPos++ = _T(' '); + + jint len = elts[i]->length(); + JV_TEMP_STRING_WIN32(thiselt, elts[i]); + _tcscpy(cmdLineCurPos, thiselt); + cmdLineCurPos += len; } - *cmdLineCurPos = '\0'; + *cmdLineCurPos = _T('\0'); // Get the environment, if any. - char *env = NULL; + LPTSTR env = NULL; if (envp) { elts = elements (envp); int envLen = 0; for (int i = 0; i < envp->length; ++i) - envLen += (_Jv_GetStringUTFLength (elts[i]) + 1); + envLen += (elts[i]->length() + 1); - env = (char *) _Jv_Malloc (envLen + 1); + env = (LPTSTR) _Jv_Malloc ((envLen + 1) * sizeof(TCHAR)); int j = 0; for (int i = 0; i < envp->length; ++i) { - jsize s = _Jv_GetStringUTFLength (elts[i]); - _Jv_GetStringUTFRegion (elts[i], 0, elts[i]->length(), (env + j)); - - j += s; - *(env + j) = '\0'; + jint len = elts[i]->length(); + + JV_TEMP_STRING_WIN32(thiselt, elts[i]); + _tcscpy(env + j, thiselt); + + j += len; + + // Skip past the null terminator that _tcscpy just inserted. j++; } - *(env + j) = '\0'; + *(env + j) = _T('\0'); } // Get the working directory path, if specified. - JV_TEMP_UTF_STRING (wdir, dir ? dir->getPath () : 0); + JV_TEMP_STRING_WIN32 (wdir, dir ? dir->getPath () : 0); errorStream = NULL; inputStream = NULL; @@ -304,12 +309,13 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, // starting a console application; it suppresses the // creation of a console window. This flag is ignored on // Win9X. + if (CreateProcess (NULL, cmdLine, NULL, NULL, 1, - CREATE_NO_WINDOW, + CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT, env, wdir, &si, @@ -317,7 +323,7 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, { DWORD dwErrorCode = GetLastError (); throw new IOException ( - _Jv_WinStrError ("Error creating child process", dwErrorCode)); + _Jv_WinStrError (_T("Error creating child process"), dwErrorCode)); } procHandle = (jint ) pi.hProcess; diff --git a/libjava/java/net/natNetworkInterfaceWin32.cc b/libjava/java/net/natNetworkInterfaceWin32.cc index 20c9a9b..d4c2b17 100644 --- a/libjava/java/net/natNetworkInterfaceWin32.cc +++ b/libjava/java/net/natNetworkInterfaceWin32.cc @@ -70,18 +70,18 @@ winsock2GetRealNetworkInterfaces (jstring* pjstrName, // have access to the real name under Winsock 2, we use // "lo" for the loopback interface and ethX for the // real ones. - char szName[30]; + TCHAR szName[30]; u_long lFlags = arInterfaceInfo[i].iiFlags; if (lFlags & IFF_LOOPBACK) - strcpy (szName, "lo"); + _tcscpy (szName, _T("lo")); else { - strcpy (szName, "eth"); - wsprintf(szName+3, "%d", nCurETHInterface++); + _tcscpy (szName, _T("eth")); + wsprintf(szName+3, _T("%d"), nCurETHInterface++); } - jstring if_name = JvNewStringLatin1 (szName); + jstring if_name = _Jv_Win32NewString (szName); java::net::Inet4Address* address = new java::net::Inet4Address (baddr, JvNewStringLatin1 ("")); pjstrName[i] = if_name; |