Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions src/java.base/windows/native/libjava/WinNTFileSystem_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls)
/* -- Path operations -- */

extern int wcanonicalize(const WCHAR *path, WCHAR *out, int len);
extern int wcanonicalizeWithPrefix(const WCHAR *canonicalPrefix, const WCHAR *pathWithCanonicalPrefix, WCHAR *out, int len);

/**
* Retrieves the fully resolved (final) path for the given path or NULL
Expand Down Expand Up @@ -296,41 +295,6 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this,
}


JNIEXPORT jstring JNICALL
Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this,
jstring canonicalPrefixString,
jstring pathWithCanonicalPrefixString)
{
jstring rv = NULL;
WCHAR canonicalPath[MAX_PATH_LENGTH];
WITH_UNICODE_STRING(env, canonicalPrefixString, canonicalPrefix) {
WITH_UNICODE_STRING(env, pathWithCanonicalPrefixString, pathWithCanonicalPrefix) {
int len = (int)wcslen(canonicalPrefix) + MAX_PATH;
if (len > MAX_PATH_LENGTH) {
WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR));
if (cp != NULL) {
if (wcanonicalizeWithPrefix(canonicalPrefix,
pathWithCanonicalPrefix,
cp, len) >= 0) {
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
}
free(cp);
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
}
} else if (wcanonicalizeWithPrefix(canonicalPrefix,
pathWithCanonicalPrefix,
canonicalPath, MAX_PATH_LENGTH) >= 0) {
rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
}
} END_UNICODE_STRING(env, pathWithCanonicalPrefix);
} END_UNICODE_STRING(env, canonicalPrefix);
if (rv == NULL && !(*env)->ExceptionCheck(env)) {
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
}
return rv;
}

JNIEXPORT jstring JNICALL
Java_java_io_WinNTFileSystem_getFinalPath0(JNIEnv* env, jobject this, jstring pathname) {
jstring rv = NULL;
Expand Down
58 changes: 0 additions & 58 deletions src/java.base/windows/native/libjava/canonicalize_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,64 +268,6 @@ wcanonicalize(WCHAR *orig_path, WCHAR *result, int size)
return -1;
}

/* Convert a pathname to canonical form. The input prefix is assumed
to be in canonical form already, and the trailing filename must not
contain any wildcard, dot/double dot, or other "tricky" characters
that are rejected by the canonicalize() routine above. This
routine is present to allow the canonicalization prefix cache to be
used while still returning canonical names with the correct
capitalization. */
int
wcanonicalizeWithPrefix(WCHAR *canonicalPrefix, WCHAR *pathWithCanonicalPrefix, WCHAR *result, int size)
{
WIN32_FIND_DATAW fd;
HANDLE h;
WCHAR *src, *dst, *dend;
WCHAR *pathbuf;
int pathlen;

src = pathWithCanonicalPrefix;
dst = result; /* Place results here */
dend = dst + size; /* Don't go to or past here */


if ((pathlen=(int)wcslen(pathWithCanonicalPrefix)) > MAX_PATH - 1) {
pathbuf = getPrefixed(pathWithCanonicalPrefix, pathlen);
h = FindFirstFileW(pathbuf, &fd); /* Look up prefix */
free(pathbuf);
} else
h = FindFirstFileW(pathWithCanonicalPrefix, &fd); /* Look up prefix */
if (h != INVALID_HANDLE_VALUE) {
/* Lookup succeeded; append true name to result and continue */
FindClose(h);
if (!(dst = wcp(dst, dend, L'\0',
canonicalPrefix,
canonicalPrefix + wcslen(canonicalPrefix)))) {
return -1;
}
if (!(dst = wcp(dst, dend, L'\\',
fd.cFileName,
fd.cFileName + wcslen(fd.cFileName)))) {
return -1;
}
} else {
if (!lastErrorReportable()) {
if (!(dst = wcp(dst, dend, L'\0', src, src + wcslen(src)))) {
return -1;
}
} else {
return -1;
}
}

if (dst >= dend) {
errno = ENAMETOOLONG;
return -1;
}
*dst = L'\0';
return 0;
}

/* Non-Wide character version of canonicalize.
Converts to wchar and delegates to wcanonicalize. */
JNIEXPORT int
Expand Down