提交 f94f7f20 编写于 作者: A alanb

6983520: java/io/pathNames/GeneralWin32.java fails with jdk7-b108 (win)

Reviewed-by: sherman
上级 db044453
......@@ -815,7 +815,7 @@ Java_java_io_WinNTFileSystem_getDriveDirectory(JNIEnv *env, jobject this,
jint drive)
{
jstring ret = NULL;
jchar *p = _wgetdcwd(drive, NULL, MAX_PATH);
jchar *p = currentDir(drive);
jchar *pf = p;
if (p == NULL) return NULL;
if (iswalpha(*p) && (p[1] == L':')) p += 2;
......
......@@ -66,6 +66,25 @@ fileToNTPath(JNIEnv *env, jobject file, jfieldID id) {
return pathToNTPath(env, path, JNI_FALSE);
}
/* Returns the working directory for the given drive, or NULL */
WCHAR*
currentDir(int di) {
UINT dt;
WCHAR root[4];
// verify drive is valid as _wgetdcwd in the VC++ 2010 runtime
// library does not handle invalid drives.
root[0] = L'A' + (WCHAR)(di - 1);
root[1] = L':';
root[2] = L'\\';
root[3] = L'\0';
dt = GetDriveTypeW(root);
if (dt == DRIVE_UNKNOWN || dt == DRIVE_NO_ROOT_DIR) {
return NULL;
} else {
return _wgetdcwd(di, NULL, MAX_PATH);
}
}
/* We cache the length of current working dir here to avoid
calling _wgetcwd() every time we need to resolve a relative
path. This piece of code needs to be revisited if chdir
......@@ -83,7 +102,7 @@ currentDirLength(const WCHAR* ps, int pathlen) {
if ((d >= L'a') && (d <= L'z')) di = d - L'a' + 1;
else if ((d >= L'A') && (d <= L'Z')) di = d - L'A' + 1;
else return 0; /* invalid drive name. */
dir = _wgetdcwd(di, NULL, MAX_PATH);
dir = currentDir(di);
if (dir != NULL){
dirlen = wcslen(dir);
free(dir);
......
......@@ -33,6 +33,7 @@
WCHAR* pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE);
WCHAR* fileToNTPath(JNIEnv *env, jobject file, jfieldID id);
WCHAR* getPrefixed(const WCHAR* path, int pathlen);
WCHAR* currentDir(int di);
int currentDirLength(const WCHAR* path, int pathlen);
void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
int handleAvailable(jlong fd, jlong *pbytes);
......
......@@ -22,7 +22,7 @@
*/
/* @test
@bug 4032066 4039597 4046914 4054511 4065189 4109131 4875229
@bug 4032066 4039597 4046914 4054511 4065189 4109131 4875229 6983520
@summary General exhaustive test of win32 pathname handling
@author Mark Reinhold
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册