fix access violation introduced in last commit

This commit is contained in:
Joel Dice 2011-09-14 13:27:17 -06:00
parent 446c09dd33
commit 916c96c2b9
2 changed files with 9 additions and 5 deletions

View File

@ -346,14 +346,15 @@ Java_java_io_File_length(JNIEnv* e, jclass, jstring path)
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
LARGE_INTEGER fileSize; LARGE_INTEGER fileSize;
HANDLE file = CreateFileW((wchar_t *)e->GetStringChars(path, 0), FILE_READ_DATA, FILE_SHARE_READ, 0, string_t chars = getChars(e, path);
OPEN_EXISTING, 0, 0); HANDLE file = CreateFileW
e->ReleaseStringChars(path, 0); (chars, FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
releaseChars(e, path, chars);
if (file != INVALID_HANDLE_VALUE) if (file != INVALID_HANDLE_VALUE)
GetFileSizeEx(file, &fileSize); GetFileSizeEx(file, &fileSize);
else return -1; else return 0;
CloseHandle(file); CloseHandle(file);
return (jlong)fileSize.QuadPart; return static_cast<jlong>(fileSize.QuadPart);
#else #else

View File

@ -10,6 +10,9 @@ public class Zip {
for (File file: directory.listFiles()) { for (File file: directory.listFiles()) {
if (file.isFile()) { if (file.isFile()) {
if (file.getName().endsWith(".jar")) { if (file.getName().endsWith(".jar")) {
System.out.println
("found " + file.getAbsolutePath() + " length " + file.length());
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
} else if (file.isDirectory()) { } else if (file.isDirectory()) {