< prev index next >

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

Print this page




 160     }
 161     return ptr_to_jlong(hEvent);
 162 }
 163 
 164 JNIEXPORT jstring JNICALL
 165 Java_sun_nio_fs_WindowsNativeDispatcher_FormatMessage(JNIEnv* env, jclass this, jint errorCode) {
 166     WCHAR message[255];
 167 
 168     DWORD len = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
 169                                NULL,
 170                                (DWORD)errorCode,
 171                                0,
 172                                &message[0],
 173                                255,
 174                                NULL);
 175 
 176 
 177     if (len == 0) {
 178         return NULL;
 179     } else {
 180         if (len > 3) {
 181             // Drop final '.', CR, LF
 182             if (message[len - 1] == L'\n') len--;
 183             if (message[len - 1] == L'\r') len--;
 184             if (message[len - 1] == L'.') len--;
 185             message[len] = L'\0';
 186         }
 187 
 188         return (*env)->NewString(env, (const jchar *)message, (jsize)wcslen(message));
 189     }
 190 }
 191 
 192 JNIEXPORT void JNICALL
 193 Java_sun_nio_fs_WindowsNativeDispatcher_LocalFree(JNIEnv* env, jclass this, jlong address)
 194 {
 195     HLOCAL hMem = (HLOCAL)jlong_to_ptr(address);
 196     LocalFree(hMem);
 197 }
 198 
 199 JNIEXPORT jlong JNICALL
 200 Java_sun_nio_fs_WindowsNativeDispatcher_CreateFile0(JNIEnv* env, jclass this,
 201     jlong address, jint dwDesiredAccess, jint dwShareMode, jlong sdAddress,
 202     jint dwCreationDisposition, jint dwFlagsAndAttributes)
 203 {
 204     HANDLE handle;
 205     LPCWSTR lpFileName = jlong_to_ptr(address);
 206 
 207     SECURITY_ATTRIBUTES securityAttributes;




 160     }
 161     return ptr_to_jlong(hEvent);
 162 }
 163 
 164 JNIEXPORT jstring JNICALL
 165 Java_sun_nio_fs_WindowsNativeDispatcher_FormatMessage(JNIEnv* env, jclass this, jint errorCode) {
 166     WCHAR message[255];
 167 
 168     DWORD len = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
 169                                NULL,
 170                                (DWORD)errorCode,
 171                                0,
 172                                &message[0],
 173                                255,
 174                                NULL);
 175 
 176 
 177     if (len == 0) {
 178         return NULL;
 179     } else {








 180         return (*env)->NewString(env, (const jchar *)message, (jsize)wcslen(message));
 181     }
 182 }
 183 
 184 JNIEXPORT void JNICALL
 185 Java_sun_nio_fs_WindowsNativeDispatcher_LocalFree(JNIEnv* env, jclass this, jlong address)
 186 {
 187     HLOCAL hMem = (HLOCAL)jlong_to_ptr(address);
 188     LocalFree(hMem);
 189 }
 190 
 191 JNIEXPORT jlong JNICALL
 192 Java_sun_nio_fs_WindowsNativeDispatcher_CreateFile0(JNIEnv* env, jclass this,
 193     jlong address, jint dwDesiredAccess, jint dwShareMode, jlong sdAddress,
 194     jint dwCreationDisposition, jint dwFlagsAndAttributes)
 195 {
 196     HANDLE handle;
 197     LPCWSTR lpFileName = jlong_to_ptr(address);
 198 
 199     SECURITY_ATTRIBUTES securityAttributes;


< prev index next >