1 /*
2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
870 if (GetDiskFreeSpaceExW(volname, &usableSpace, &totalSpace, &freeSpace)) {
871 switch(t) {
872 case java_io_FileSystem_SPACE_TOTAL:
873 rv = long_to_jlong(totalSpace.QuadPart);
874 break;
875 case java_io_FileSystem_SPACE_FREE:
876 rv = long_to_jlong(freeSpace.QuadPart);
877 break;
878 case java_io_FileSystem_SPACE_USABLE:
879 rv = long_to_jlong(usableSpace.QuadPart);
880 break;
881 default:
882 assert(0);
883 }
884 }
885 }
886
887 free(pathbuf);
888 return rv;
889 }
|
1 /*
2 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
870 if (GetDiskFreeSpaceExW(volname, &usableSpace, &totalSpace, &freeSpace)) {
871 switch(t) {
872 case java_io_FileSystem_SPACE_TOTAL:
873 rv = long_to_jlong(totalSpace.QuadPart);
874 break;
875 case java_io_FileSystem_SPACE_FREE:
876 rv = long_to_jlong(freeSpace.QuadPart);
877 break;
878 case java_io_FileSystem_SPACE_USABLE:
879 rv = long_to_jlong(usableSpace.QuadPart);
880 break;
881 default:
882 assert(0);
883 }
884 }
885 }
886
887 free(pathbuf);
888 return rv;
889 }
890
891 // pathname is expected to be either null or to contain the root
892 // of the path terminated by a backslash
893 JNIEXPORT jlong JNICALL
894 Java_java_io_WinNTFileSystem_getNameMax0(JNIEnv *env, jobject this,
895 jstring pathname)
896 {
897 BOOL res = 0;
898 DWORD maxComponentLength;
899
900 if (pathname == NULL) {
901 res = GetVolumeInformationW(NULL,
902 NULL,
903 0,
904 NULL,
905 &maxComponentLength,
906 NULL,
907 NULL,
908 0);
909 } else {
910 WITH_UNICODE_STRING(env, pathname, path) {
911 res = GetVolumeInformationW(path,
912 NULL,
913 0,
914 NULL,
915 &maxComponentLength,
916 NULL,
917 NULL,
918 0);
919 } END_UNICODE_STRING(env, path);
920 }
921
922 if (res == 0) {
923 JNU_ThrowIOExceptionWithLastError(env,
924 "Could not get maximum compnent length");
925 }
926
927 return (jlong)maxComponentLength;
928 }
|