Skip to content

Commit 4e8e55d

Browse files
author
Brian Burkhalter
committed
8370633: Remove dead code for Windows file path canonicalization functions
Reviewed-by: alanb, iris
1 parent 70aa367 commit 4e8e55d

File tree

2 files changed

+0
-94
lines changed

2 files changed

+0
-94
lines changed

src/java.base/windows/native/libjava/WinNTFileSystem_md.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls)
6060
/* -- Path operations -- */
6161

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

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

298297

299-
JNIEXPORT jstring JNICALL
300-
Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this,
301-
jstring canonicalPrefixString,
302-
jstring pathWithCanonicalPrefixString)
303-
{
304-
jstring rv = NULL;
305-
WCHAR canonicalPath[MAX_PATH_LENGTH];
306-
WITH_UNICODE_STRING(env, canonicalPrefixString, canonicalPrefix) {
307-
WITH_UNICODE_STRING(env, pathWithCanonicalPrefixString, pathWithCanonicalPrefix) {
308-
int len = (int)wcslen(canonicalPrefix) + MAX_PATH;
309-
if (len > MAX_PATH_LENGTH) {
310-
WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR));
311-
if (cp != NULL) {
312-
if (wcanonicalizeWithPrefix(canonicalPrefix,
313-
pathWithCanonicalPrefix,
314-
cp, len) >= 0) {
315-
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
316-
}
317-
free(cp);
318-
} else {
319-
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
320-
}
321-
} else if (wcanonicalizeWithPrefix(canonicalPrefix,
322-
pathWithCanonicalPrefix,
323-
canonicalPath, MAX_PATH_LENGTH) >= 0) {
324-
rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
325-
}
326-
} END_UNICODE_STRING(env, pathWithCanonicalPrefix);
327-
} END_UNICODE_STRING(env, canonicalPrefix);
328-
if (rv == NULL && !(*env)->ExceptionCheck(env)) {
329-
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
330-
}
331-
return rv;
332-
}
333-
334298
JNIEXPORT jstring JNICALL
335299
Java_java_io_WinNTFileSystem_getFinalPath0(JNIEnv* env, jobject this, jstring pathname) {
336300
jstring rv = NULL;

src/java.base/windows/native/libjava/canonicalize_md.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -268,64 +268,6 @@ wcanonicalize(WCHAR *orig_path, WCHAR *result, int size)
268268
return -1;
269269
}
270270

271-
/* Convert a pathname to canonical form. The input prefix is assumed
272-
to be in canonical form already, and the trailing filename must not
273-
contain any wildcard, dot/double dot, or other "tricky" characters
274-
that are rejected by the canonicalize() routine above. This
275-
routine is present to allow the canonicalization prefix cache to be
276-
used while still returning canonical names with the correct
277-
capitalization. */
278-
int
279-
wcanonicalizeWithPrefix(WCHAR *canonicalPrefix, WCHAR *pathWithCanonicalPrefix, WCHAR *result, int size)
280-
{
281-
WIN32_FIND_DATAW fd;
282-
HANDLE h;
283-
WCHAR *src, *dst, *dend;
284-
WCHAR *pathbuf;
285-
int pathlen;
286-
287-
src = pathWithCanonicalPrefix;
288-
dst = result; /* Place results here */
289-
dend = dst + size; /* Don't go to or past here */
290-
291-
292-
if ((pathlen=(int)wcslen(pathWithCanonicalPrefix)) > MAX_PATH - 1) {
293-
pathbuf = getPrefixed(pathWithCanonicalPrefix, pathlen);
294-
h = FindFirstFileW(pathbuf, &fd); /* Look up prefix */
295-
free(pathbuf);
296-
} else
297-
h = FindFirstFileW(pathWithCanonicalPrefix, &fd); /* Look up prefix */
298-
if (h != INVALID_HANDLE_VALUE) {
299-
/* Lookup succeeded; append true name to result and continue */
300-
FindClose(h);
301-
if (!(dst = wcp(dst, dend, L'\0',
302-
canonicalPrefix,
303-
canonicalPrefix + wcslen(canonicalPrefix)))) {
304-
return -1;
305-
}
306-
if (!(dst = wcp(dst, dend, L'\\',
307-
fd.cFileName,
308-
fd.cFileName + wcslen(fd.cFileName)))) {
309-
return -1;
310-
}
311-
} else {
312-
if (!lastErrorReportable()) {
313-
if (!(dst = wcp(dst, dend, L'\0', src, src + wcslen(src)))) {
314-
return -1;
315-
}
316-
} else {
317-
return -1;
318-
}
319-
}
320-
321-
if (dst >= dend) {
322-
errno = ENAMETOOLONG;
323-
return -1;
324-
}
325-
*dst = L'\0';
326-
return 0;
327-
}
328-
329271
/* Non-Wide character version of canonicalize.
330272
Converts to wchar and delegates to wcanonicalize. */
331273
JNIEXPORT int

0 commit comments

Comments
 (0)