提交 42bafc48 编写于 作者: D dxu

7186817: Remove Windows 95/98/ME Support

Reviewed-by: alanb
上级 ece58d0b
#
# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -64,13 +64,11 @@ include FILES_java.gmk
include Exportedfiles.gmk
ifeq ($(PLATFORM),windows)
FILES_java += java/io/Win32FileSystem.java \
java/io/WinNTFileSystem.java \
FILES_java += java/io/WinNTFileSystem.java \
java/util/prefs/WindowsPreferences.java \
java/util/prefs/WindowsPreferencesFactory.java
FILES_c += ProcessImpl_md.c \
Win32FileSystem_md.c \
WinNTFileSystem_md.c \
canonicalize_md.c \
dirent_md.c \
......
......@@ -209,7 +209,6 @@ ifeq ($(OPENJDK_TARGET_OS),windows)
else
LIBJAVA_EXCLUDE_FILES += \
ProcessImpl_md.c \
Win32FileSystem_md.c \
WinNTFileSystem_md.c \
dirent_md.c \
WindowsPreferences.c \
......
/*
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -27,16 +27,8 @@
#include "jni.h"
#include "jni_util.h"
extern jboolean onNT;
extern void initializeWindowsVersion();
JNIEXPORT jobject JNICALL
Java_java_io_FileSystem_getFileSystem(JNIEnv *env, jclass ignored)
{
initializeWindowsVersion();
if (onNT) {
return JNU_NewObjectByName(env, "java/io/WinNTFileSystem", "()V");
} else {
return JNU_NewObjectByName(env, "java/io/Win32FileSystem", "()V");
}
return JNU_NewObjectByName(env, "java/io/WinNTFileSystem", "()V");
}
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <direct.h>
#include <windows.h>
#include <io.h>
#include "jvm.h"
#include "jni.h"
#include "jni_util.h"
#include "jlong.h"
#include "io_util.h"
#include "dirent_md.h"
#include "java_io_FileSystem.h"
/* This macro relies upon the fact that JNU_GetStringPlatformChars always makes
a copy of the string */
#define WITH_NATIVE_PATH(env, object, id, var) \
WITH_FIELD_PLATFORM_STRING(env, object, id, var) \
JVM_NativePath((char *)var);
#define END_NATIVE_PATH(env, var) END_PLATFORM_STRING(env, var)
static struct {
jfieldID path;
} ids;
JNIEXPORT void JNICALL
Java_java_io_Win32FileSystem_initIDs(JNIEnv *env, jclass cls)
{
jclass fileClass = (*env)->FindClass(env, "java/io/File");
if (!fileClass) return;
ids.path = (*env)->GetFieldID(env, fileClass,
"path", "Ljava/lang/String;");
}
/* -- Path operations -- */
extern int canonicalize(char *path, const char *out, int len);
extern int canonicalizeWithPrefix(const char* canonicalPrefix, const char *pathWithCanonicalPrefix, char *out, int len);
JNIEXPORT jstring JNICALL
Java_java_io_Win32FileSystem_canonicalize0(JNIEnv *env, jobject this,
jstring pathname)
{
jstring rv = NULL;
WITH_PLATFORM_STRING(env, pathname, path) {
char canonicalPath[JVM_MAXPATHLEN];
if (canonicalize(JVM_NativePath((char *)path),
canonicalPath, JVM_MAXPATHLEN) < 0) {
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
} else {
rv = JNU_NewStringPlatform(env, canonicalPath);
}
} END_PLATFORM_STRING(env, path);
return rv;
}
JNIEXPORT jstring JNICALL
Java_java_io_Win32FileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this,
jstring canonicalPrefixString,
jstring pathWithCanonicalPrefixString)
{
jstring rv = NULL;
char canonicalPath[JVM_MAXPATHLEN];
WITH_PLATFORM_STRING(env, canonicalPrefixString, canonicalPrefix) {
WITH_PLATFORM_STRING(env, pathWithCanonicalPrefixString, pathWithCanonicalPrefix) {
if (canonicalizeWithPrefix(canonicalPrefix,
pathWithCanonicalPrefix,
canonicalPath, JVM_MAXPATHLEN) < 0) {
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
} else {
rv = JNU_NewStringPlatform(env, canonicalPath);
}
} END_PLATFORM_STRING(env, pathWithCanonicalPrefix);
} END_PLATFORM_STRING(env, canonicalPrefix);
return rv;
}
/* -- Attribute accessors -- */
/* Check whether or not the file name in "path" is a Windows reserved
device name (CON, PRN, AUX, NUL, COM[1-9], LPT[1-9]) based on the
returned result from GetFullPathName. If the file name in the path
is indeed a reserved device name GetFuulPathName returns
"\\.\[ReservedDeviceName]".
*/
BOOL isReservedDeviceName(const char* path) {
#define BUFSIZE 9
char buf[BUFSIZE];
char *lpf = NULL;
DWORD retLen = GetFullPathName(path,
BUFSIZE,
buf,
&lpf);
if ((retLen == BUFSIZE - 1 || retLen == BUFSIZE - 2) &&
buf[0] == '\\' && buf[1] == '\\' &&
buf[2] == '.' && buf[3] == '\\') {
char* dname = _strupr(buf + 4);
if (strcmp(dname, "CON") == 0 ||
strcmp(dname, "PRN") == 0 ||
strcmp(dname, "AUX") == 0 ||
strcmp(dname, "NUL") == 0)
return TRUE;
if ((strncmp(dname, "COM", 3) == 0 ||
strncmp(dname, "LPT", 3) == 0) &&
dname[3] - '0' > 0 &&
dname[3] - '0' <= 9)
return TRUE;
}
return FALSE;
}
JNIEXPORT jint JNICALL
Java_java_io_Win32FileSystem_getBooleanAttributes(JNIEnv *env, jobject this,
jobject file)
{
jint rv = 0;
WITH_NATIVE_PATH(env, file, ids.path, path) {
WIN32_FILE_ATTRIBUTE_DATA wfad;
if (!isReservedDeviceName(path) &&
GetFileAttributesEx(path, GetFileExInfoStandard, &wfad)) {
rv = (java_io_FileSystem_BA_EXISTS
| ((wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
? java_io_FileSystem_BA_DIRECTORY
: java_io_FileSystem_BA_REGULAR)
| ((wfad.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
? java_io_FileSystem_BA_HIDDEN : 0));
}
} END_NATIVE_PATH(env, path);
return rv;
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_checkAccess(JNIEnv *env, jobject this,
jobject file, jint a)
{
jboolean rv = JNI_FALSE;
int mode;
switch (a) {
case java_io_FileSystem_ACCESS_READ:
case java_io_FileSystem_ACCESS_EXECUTE:
mode = 4;
break;
case java_io_FileSystem_ACCESS_WRITE:
mode = 2;
break;
default: assert(0);
}
WITH_NATIVE_PATH(env, file, ids.path, path) {
if (access(path, mode) == 0) {
rv = JNI_TRUE;
}
} END_NATIVE_PATH(env, path);
return rv;
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_setPermission(JNIEnv *env, jobject this,
jobject file,
jint access,
jboolean enable,
jboolean owneronly)
{
jboolean rv = JNI_FALSE;
if (access == java_io_FileSystem_ACCESS_READ ||
access == java_io_FileSystem_ACCESS_EXECUTE) {
return enable;
}
WITH_NATIVE_PATH(env, file, ids.path, path) {
DWORD a;
a = GetFileAttributes(path);
if (a != INVALID_FILE_ATTRIBUTES) {
if (enable)
a = a & ~FILE_ATTRIBUTE_READONLY;
else
a = a | FILE_ATTRIBUTE_READONLY;
if (SetFileAttributes(path, a))
rv = JNI_TRUE;
}
} END_NATIVE_PATH(env, path);
return rv;
}
JNIEXPORT jlong JNICALL
Java_java_io_Win32FileSystem_getLastModifiedTime(JNIEnv *env, jobject this,
jobject file)
{
jlong rv = 0;
WITH_NATIVE_PATH(env, file, ids.path, path) {
/* Win95, Win98, WinME */
WIN32_FIND_DATA fd;
jlong temp = 0;
LARGE_INTEGER modTime;
HANDLE h = FindFirstFile(path, &fd);
if (h != INVALID_HANDLE_VALUE) {
FindClose(h);
modTime.LowPart = (DWORD) fd.ftLastWriteTime.dwLowDateTime;
modTime.HighPart = (LONG) fd.ftLastWriteTime.dwHighDateTime;
rv = modTime.QuadPart / 10000;
rv -= 11644473600000;
}
} END_NATIVE_PATH(env, path);
return rv;
}
JNIEXPORT jlong JNICALL
Java_java_io_Win32FileSystem_getLength(JNIEnv *env, jobject this,
jobject file)
{
jlong rv = 0;
WITH_NATIVE_PATH(env, file, ids.path, path) {
struct _stati64 sb;
if (_stati64(path, &sb) == 0) {
rv = sb.st_size;
}
} END_NATIVE_PATH(env, path);
return rv;
}
/* -- File operations -- */
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_createFileExclusively(JNIEnv *env, jclass cls,
jstring pathname)
{
jboolean rv = JNI_FALSE;
DWORD a;
WITH_PLATFORM_STRING(env, pathname, path) {
int orv;
int error;
JVM_NativePath((char *)path);
orv = JVM_Open(path, JVM_O_RDWR | JVM_O_CREAT | JVM_O_EXCL, 0666);
if (orv < 0) {
if (orv != JVM_EEXIST) {
error = GetLastError();
// If a directory by the named path already exists,
// return false (behavior of solaris and linux) instead of
// throwing an exception
a = GetFileAttributes(path);
if ((a == INVALID_FILE_ATTRIBUTES) ||
!(a & FILE_ATTRIBUTE_DIRECTORY)) {
SetLastError(error);
JNU_ThrowIOExceptionWithLastError(env, path);
}
}
} else {
JVM_Close(orv);
rv = JNI_TRUE;
}
} END_PLATFORM_STRING(env, path);
return rv;
}
static int
removeFileOrDirectory(const char *path) /* Returns 0 on success */
{
DWORD a;
SetFileAttributes(path, 0);
a = GetFileAttributes(path);
if (a == INVALID_FILE_ATTRIBUTES) {
return 1;
} else if (a & FILE_ATTRIBUTE_DIRECTORY) {
return !RemoveDirectory(path);
} else {
return !DeleteFile(path);
}
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_delete0(JNIEnv *env, jobject this,
jobject file)
{
jboolean rv = JNI_FALSE;
WITH_NATIVE_PATH(env, file, ids.path, path) {
if (removeFileOrDirectory(path) == 0) {
rv = JNI_TRUE;
}
} END_NATIVE_PATH(env, path);
return rv;
}
/* ## Clean this up to use direct Win32 calls */
JNIEXPORT jobjectArray JNICALL
Java_java_io_Win32FileSystem_list(JNIEnv *env, jobject this,
jobject file)
{
DIR *dir;
struct dirent *ptr;
int len, maxlen;
jobjectArray rv, old;
WITH_NATIVE_PATH(env, file, ids.path, path) {
dir = opendir(path);
} END_NATIVE_PATH(env, path);
if (dir == NULL) return NULL;
/* Allocate an initial String array */
len = 0;
maxlen = 16;
rv = (*env)->NewObjectArray(env, maxlen, JNU_ClassString(env), NULL);
if (rv == NULL) goto error;
/* Scan the directory */
while ((ptr = readdir(dir)) != NULL) {
jstring name;
if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, ".."))
continue;
if (len == maxlen) {
old = rv;
rv = (*env)->NewObjectArray(env, maxlen <<= 1,
JNU_ClassString(env), NULL);
if (rv == NULL) goto error;
if (JNU_CopyObjectArray(env, rv, old, len) < 0) goto error;
(*env)->DeleteLocalRef(env, old);
}
name = JNU_NewStringPlatform(env, ptr->d_name);
if (name == NULL) goto error;
(*env)->SetObjectArrayElement(env, rv, len++, name);
(*env)->DeleteLocalRef(env, name);
}
closedir(dir);
/* Copy the final results into an appropriately-sized array */
old = rv;
rv = (*env)->NewObjectArray(env, len, JNU_ClassString(env), NULL);
if (rv == NULL) goto error;
if (JNU_CopyObjectArray(env, rv, old, len) < 0) goto error;
return rv;
error:
closedir(dir);
return NULL;
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_createDirectory(JNIEnv *env, jobject this,
jobject file)
{
jboolean rv = JNI_FALSE;
WITH_NATIVE_PATH(env, file, ids.path, path) {
if (mkdir(path) == 0) {
rv = JNI_TRUE;
}
} END_NATIVE_PATH(env, path);
return rv;
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_rename0(JNIEnv *env, jobject this,
jobject from, jobject to)
{
jboolean rv = JNI_FALSE;
WITH_NATIVE_PATH(env, from, ids.path, fromPath) {
WITH_NATIVE_PATH(env, to, ids.path, toPath) {
if (rename(fromPath, toPath) == 0) {
rv = JNI_TRUE;
}
} END_NATIVE_PATH(env, toPath);
} END_NATIVE_PATH(env, fromPath);
return rv;
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_setLastModifiedTime(JNIEnv *env, jobject this,
jobject file, jlong time)
{
jboolean rv = JNI_FALSE;
WITH_NATIVE_PATH(env, file, ids.path, path) {
HANDLE h;
h = CreateFile(path, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 0);
if (h != INVALID_HANDLE_VALUE) {
LARGE_INTEGER modTime;
FILETIME t;
modTime.QuadPart = (time + 11644473600000L) * 10000L;
t.dwLowDateTime = (DWORD)modTime.LowPart;
t.dwHighDateTime = (DWORD)modTime.HighPart;
if (SetFileTime(h, NULL, NULL, &t)) {
rv = JNI_TRUE;
}
CloseHandle(h);
}
} END_NATIVE_PATH(env, path);
return rv;
}
JNIEXPORT jboolean JNICALL
Java_java_io_Win32FileSystem_setReadOnly(JNIEnv *env, jobject this,
jobject file)
{
jboolean rv = JNI_FALSE;
WITH_NATIVE_PATH(env, file, ids.path, path) {
DWORD a;
a = GetFileAttributes(path);
if (a != INVALID_FILE_ATTRIBUTES) {
if (SetFileAttributes(path, a | FILE_ATTRIBUTE_READONLY))
rv = JNI_TRUE;
}
} END_NATIVE_PATH(env, path);
return rv;
}
/* -- Filesystem interface -- */
JNIEXPORT jobject JNICALL
Java_java_io_Win32FileSystem_getDriveDirectory(JNIEnv *env, jclass ignored,
jint drive)
{
char buf[_MAX_PATH];
char *p = _getdcwd(drive, buf, sizeof(buf));
if (p == NULL) return NULL;
if (isalpha(*p) && (p[1] == ':')) p += 2;
return JNU_NewStringPlatform(env, p);
}
JNIEXPORT jint JNICALL
Java_java_io_Win32FileSystem_listRoots0(JNIEnv *env, jclass ignored)
{
return GetLogicalDrives();
}
JNIEXPORT jlong JNICALL
Java_java_io_Win32FileSystem_getSpace0(JNIEnv *env, jobject this,
jobject file, jint t)
{
jlong rv = 0L;
WITH_NATIVE_PATH(env, file, ids.path, path) {
ULARGE_INTEGER totalSpace, freeSpace, usableSpace;
if (GetDiskFreeSpaceEx(path, &usableSpace, &totalSpace, &freeSpace)) {
switch(t) {
case java_io_FileSystem_SPACE_TOTAL:
rv = long_to_jlong(totalSpace.QuadPart);
break;
case java_io_FileSystem_SPACE_FREE:
rv = long_to_jlong(freeSpace.QuadPart);
break;
case java_io_FileSystem_SPACE_USABLE:
rv = long_to_jlong(usableSpace.QuadPart);
break;
default:
assert(0);
}
}
} END_NATIVE_PATH(env, path);
return rv;
}
......@@ -828,6 +828,12 @@ Java_java_io_WinNTFileSystem_getDriveDirectory(JNIEnv *env, jobject this,
return ret;
}
JNIEXPORT jint JNICALL
Java_java_io_WinNTFileSystem_listRoots0(JNIEnv *env, jclass ignored)
{
return GetLogicalDrives();
}
JNIEXPORT jlong JNICALL
Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
jobject file, jint t)
......
/*
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -40,22 +40,8 @@
#include <limits.h>
#include <wincon.h>
extern jboolean onNT = JNI_FALSE;
static DWORD MAX_INPUT_EVENTS = 2000;
void
initializeWindowsVersion() {
OSVERSIONINFO ver;
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
onNT = JNI_TRUE;
} else {
onNT = JNI_FALSE;
}
}
/* If this returns NULL then an exception is pending */
WCHAR*
fileToNTPath(JNIEnv *env, jobject file, jfieldID id) {
......@@ -247,27 +233,21 @@ winFileHandleOpen(JNIEnv *env, jstring path, int flags)
const DWORD flagsAndAttributes = maybeWriteThrough | maybeDeleteOnClose;
HANDLE h = NULL;
if (onNT) {
WCHAR *pathbuf = pathToNTPath(env, path, JNI_TRUE);
if (pathbuf == NULL) {
/* Exception already pending */
return -1;
}
h = CreateFileW(
pathbuf, /* Wide char path name */
access, /* Read and/or write permission */
sharing, /* File sharing flags */
NULL, /* Security attributes */
disposition, /* creation disposition */
flagsAndAttributes, /* flags and attributes */
NULL);
free(pathbuf);
} else {
WITH_PLATFORM_STRING(env, path, _ps) {
h = CreateFile(_ps, access, sharing, NULL, disposition,
flagsAndAttributes, NULL);
} END_PLATFORM_STRING(env, _ps);
WCHAR *pathbuf = pathToNTPath(env, path, JNI_TRUE);
if (pathbuf == NULL) {
/* Exception already pending */
return -1;
}
h = CreateFileW(
pathbuf, /* Wide char path name */
access, /* Read and/or write permission */
sharing, /* File sharing flags */
NULL, /* Security attributes */
disposition, /* creation disposition */
flagsAndAttributes, /* flags and attributes */
NULL);
free(pathbuf);
if (h == INVALID_HANDLE_VALUE) {
int error = GetLastError();
if (error == ERROR_TOO_MANY_OPEN_FILES) {
......
......@@ -40,72 +40,6 @@
*/
#define PIPE_SIZE (4096+24)
char *
extractExecutablePath(JNIEnv *env, char *source)
{
char *p, *r;
/* If no spaces, then use entire thing */
if ((p = strchr(source, ' ')) == NULL)
return source;
/* If no quotes, or quotes after space, return up to space */
if (((r = strchr(source, '"')) == NULL) || (r > p)) {
*p = 0;
return source;
}
/* Quotes before space, return up to space after next quotes */
p = strchr(r, '"');
if ((p = strchr(p, ' ')) == NULL)
return source;
*p = 0;
return source;
}
DWORD
selectProcessFlag(JNIEnv *env, jstring cmd0)
{
char buf[MAX_PATH];
DWORD newFlag = 0;
char *exe, *p, *name;
unsigned char buffer[2];
long headerLoc = 0;
int fd = 0;
exe = (char *)JNU_GetStringPlatformChars(env, cmd0, 0);
exe = extractExecutablePath(env, exe);
if (exe != NULL) {
if ((p = strchr(exe, '\\')) == NULL) {
SearchPath(NULL, exe, ".exe", MAX_PATH, buf, &name);
} else {
p = strrchr(exe, '\\');
*p = 0;
p++;
SearchPath(exe, p, ".exe", MAX_PATH, buf, &name);
}
}
fd = _open(buf, _O_RDONLY);
if (fd > 0) {
_read(fd, buffer, 2);
if (buffer[0] == 'M' && buffer[1] == 'Z') {
_lseek(fd, 60L, SEEK_SET);
_read(fd, buffer, 2);
headerLoc = (long)buffer[1] << 8 | (long)buffer[0];
_lseek(fd, headerLoc, SEEK_SET);
_read(fd, buffer, 2);
if (buffer[0] == 'P' && buffer[1] == 'E') {
newFlag = DETACHED_PROCESS;
}
}
_close(fd);
}
JNU_ReleaseStringPlatformChars(env, cmd0, exe);
return newFlag;
}
static void
win32Error(JNIEnv *env, const char *functionName)
{
......@@ -151,15 +85,8 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored,
const jchar* penvBlock = NULL;
jlong *handles = NULL;
jlong ret = 0;
OSVERSIONINFO ver;
jboolean onNT = JNI_FALSE;
DWORD processFlag;
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT)
onNT = JNI_TRUE;
assert(cmd != NULL);
pcmd = (*env)->GetStringChars(env, cmd, NULL);
if (pcmd == NULL) goto Catch;
......@@ -229,10 +156,7 @@ Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored,
}
SetHandleInformation(si.hStdError, HANDLE_FLAG_INHERIT, TRUE);
if (onNT)
processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT;
else
processFlag = selectProcessFlag(env, cmd) | CREATE_UNICODE_ENVIRONMENT;
processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT;
ret = CreateProcessW(0, /* executable name */
(LPWSTR)pcmd, /* command line */
0, /* process security attribute */
......
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -65,8 +65,6 @@ static void *keyNames[] = {
#define STANDARD_NAME 0
#define STD_NAME 2
static int isNT = FALSE; /* TRUE if it is NT. */
/*
* Calls RegQueryValueEx() to get the value for the specified key. If
* the platform is NT, 2000 or XP, it calls the Unicode
......@@ -95,12 +93,10 @@ getValueInRegistry(HKEY hKey,
int len;
*typePtr = 0;
if (isNT) {
ret = RegQueryValueExW(hKey, (WCHAR *) keyNames[keyIndex], NULL,
typePtr, buf, bufLengthPtr);
if (ret == ERROR_SUCCESS && *typePtr == REG_SZ) {
return ret;
}
ret = RegQueryValueExW(hKey, (WCHAR *) keyNames[keyIndex], NULL,
typePtr, buf, bufLengthPtr);
if (ret == ERROR_SUCCESS && *typePtr == REG_SZ) {
return ret;
}
valSize = sizeof(val);
......@@ -180,8 +176,7 @@ static int getWinTimeZone(char *winZoneName, char *winMapID)
*/
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
isNT = ver.dwPlatformId == VER_PLATFORM_WIN32_NT;
isVista = isNT && ver.dwMajorVersion >= 6;
isVista = ver.dwMajorVersion >= 6;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_CURRENT_TZ_KEY, 0,
KEY_READ, (PHKEY)&hKey);
......
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/* @test
* @bug 6344646
* @summary tests that Win32FileSystem.hashCode() uses
* @summary tests that WinNTFileSystem.hashCode() uses
* locale independent case mapping.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册