From a188b15f2ecc7b334ec3a7995cc72bd634936446 Mon Sep 17 00:00:00 2001 From: Brandon Craig Date: Thu, 19 Feb 2015 14:55:48 -0700 Subject: [PATCH] fix java.io.File.delete() implementation for windows --- classpath/java-io.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index f9d477520f..8df96ee01e 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -383,11 +383,20 @@ extern "C" JNIEXPORT jboolean JNICALL } extern "C" JNIEXPORT void JNICALL - Java_java_io_File_delete(JNIEnv* e, jclass, jstring path) +Java_java_io_File_delete(JNIEnv* e, jclass, jstring path) { string_t chars = getChars(e, path); + int r; if (chars) { - int r = REMOVE(chars); +#ifdef PLATFORM_WINDOWS + if (GetFileAttributes(chars) == FILE_ATTRIBUTE_DIRECTORY) { + r = !RemoveDirectory(chars); + } else { + r = REMOVE(chars); + } +#else + r = REMOVE(chars); +#endif if (r != 0) { throwNewErrno(e, "java/io/IOException"); }