< prev index next >
src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 57,66 ****
--- 57,68 ----
static jfieldID diskSpace_bytesAvailable;
static jfieldID diskSpace_totalBytes;
static jfieldID diskSpace_totalFree;
+ static jfieldID diskSpace_bytesPerSector;
+
static jfieldID account_domain;
static jfieldID account_name;
static jfieldID account_use;
static jfieldID aclInfo_aceCount;
*** 119,128 ****
--- 121,132 ----
CHECK_NULL(diskSpace_bytesAvailable);
diskSpace_totalBytes = (*env)->GetFieldID(env, clazz, "totalNumberOfBytes", "J");
CHECK_NULL(diskSpace_totalBytes);
diskSpace_totalFree = (*env)->GetFieldID(env, clazz, "totalNumberOfFreeBytes", "J");
CHECK_NULL(diskSpace_totalFree);
+ diskSpace_bytesPerSector = (*env)->GetFieldID(env, clazz, "bytesPerSector", "J");
+ CHECK_NULL(diskSpace_bytesPerSector);
clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$Account");
CHECK_NULL(clazz);
account_domain = (*env)->GetFieldID(env, clazz, "domain", "Ljava/lang/String;");
CHECK_NULL(account_domain);
*** 580,589 ****
--- 584,617 ----
long_to_jlong(totalNumberOfBytes.QuadPart));
(*env)->SetLongField(env, obj, diskSpace_totalFree,
long_to_jlong(totalNumberOfFreeBytes.QuadPart));
}
+ JNIEXPORT void JNICALL
+ Java_sun_nio_fs_WindowsNativeDispatcher_GetDiskFreeSpace0(JNIEnv* env, jclass this,
+ jlong address, jobject obj)
+ {
+ DWORD sectorsPerCluster;
+ DWORD bytesPerSector;
+ DWORD numberOfFreeClusters;
+ DWORD totalNumberOfClusters;
+ LPCWSTR lpRootPathName = jlong_to_ptr(address);
+
+
+ BOOL res = GetDiskFreeSpaceW(lpRootPathName,
+ §orsPerCluster,
+ &bytesPerSector,
+ &numberOfFreeClusters,
+ &totalNumberOfClusters);
+ if (res == 0) {
+ throwWindowsException(env, GetLastError());
+ return;
+ }
+
+ (*env)->SetLongField(env, obj, diskSpace_bytesPerSector,
+ long_to_jlong(bytesPerSector));
+ }
JNIEXPORT jstring JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_GetVolumePathName0(JNIEnv* env, jclass this,
jlong address)
{
< prev index next >