< prev index next >

src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c

Print this page




1046 
1047     if (pLuid == NULL) {
1048         JNU_ThrowInternalError(env, "Unable to allocate LUID structure");
1049     } else {
1050         if (LookupPrivilegeValueW(NULL, lpName, pLuid) == 0) {
1051             LocalFree(pLuid);
1052             throwWindowsException(env, GetLastError());
1053             return (jlong)0;
1054         }
1055     }
1056     return ptr_to_jlong(pLuid);
1057 }
1058 
1059 JNIEXPORT void JNICALL
1060 Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env,
1061     jclass this, jlong linkAddress, jlong targetAddress, jint flags)
1062 {
1063     LPCWSTR link = jlong_to_ptr(linkAddress);
1064     LPCWSTR target = jlong_to_ptr(targetAddress);
1065 
1066     if (CreateSymbolicLinkW(link, target, (DWORD)flags) == 0)










1067         throwWindowsException(env, GetLastError());
1068 }
1069 
1070 JNIEXPORT void JNICALL
1071 Java_sun_nio_fs_WindowsNativeDispatcher_CreateHardLink0(JNIEnv* env,
1072     jclass this, jlong newFileAddress, jlong existingFileAddress)
1073 {
1074     LPCWSTR newFile = jlong_to_ptr(newFileAddress);
1075     LPCWSTR existingFile = jlong_to_ptr(existingFileAddress);
1076 
1077     if (CreateHardLinkW(newFile, existingFile, NULL) == 0)
1078         throwWindowsException(env, GetLastError());
1079 }
1080 
1081 JNIEXPORT jstring JNICALL
1082 Java_sun_nio_fs_WindowsNativeDispatcher_GetFullPathName0(JNIEnv *env,
1083                                                          jclass clz,
1084                                                          jlong pathAddress)
1085 {
1086     jstring rv = NULL;




1046 
1047     if (pLuid == NULL) {
1048         JNU_ThrowInternalError(env, "Unable to allocate LUID structure");
1049     } else {
1050         if (LookupPrivilegeValueW(NULL, lpName, pLuid) == 0) {
1051             LocalFree(pLuid);
1052             throwWindowsException(env, GetLastError());
1053             return (jlong)0;
1054         }
1055     }
1056     return ptr_to_jlong(pLuid);
1057 }
1058 
1059 JNIEXPORT void JNICALL
1060 Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env,
1061     jclass this, jlong linkAddress, jlong targetAddress, jint flags)
1062 {
1063     LPCWSTR link = jlong_to_ptr(linkAddress);
1064     LPCWSTR target = jlong_to_ptr(targetAddress);
1065 
1066     // Allow creation of symbolic links when the process is not elevated.
1067     // Developer Mode must be enabled for this option to function, otherwise
1068     // it will be ignored. Check that symbol is available in current build SDK.
1069     DWORD dwFlags = (DWORD)flags;
1070 #ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
1071     dwFlags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
1072 #endif
1073 
1074     // On Windows 64-bit this appears to succeed even when there are
1075     // insufficient privileges
1076     if (CreateSymbolicLinkW(link, target, dwFlags) == 0)
1077         throwWindowsException(env, GetLastError());
1078 }
1079 
1080 JNIEXPORT void JNICALL
1081 Java_sun_nio_fs_WindowsNativeDispatcher_CreateHardLink0(JNIEnv* env,
1082     jclass this, jlong newFileAddress, jlong existingFileAddress)
1083 {
1084     LPCWSTR newFile = jlong_to_ptr(newFileAddress);
1085     LPCWSTR existingFile = jlong_to_ptr(existingFileAddress);
1086 
1087     if (CreateHardLinkW(newFile, existingFile, NULL) == 0)
1088         throwWindowsException(env, GetLastError());
1089 }
1090 
1091 JNIEXPORT jstring JNICALL
1092 Java_sun_nio_fs_WindowsNativeDispatcher_GetFullPathName0(JNIEnv *env,
1093                                                          jclass clz,
1094                                                          jlong pathAddress)
1095 {
1096     jstring rv = NULL;


< prev index next >