Initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
|
||||
<fragment
|
||||
id="org.eclipse.platform.source.win32.win32.x86"
|
||||
name="%pluginName"
|
||||
version="3.0.1"
|
||||
provider-name="Eclipse.org"
|
||||
plugin-id="org.eclipse.platform.source"
|
||||
plugin-version="3.0.1">
|
||||
|
||||
<runtime>
|
||||
</runtime>
|
||||
|
||||
<extension point = "org.eclipse.pde.core.source">
|
||||
<location path="src" />
|
||||
</extension>
|
||||
|
||||
</fragment>
|
||||
@@ -0,0 +1,287 @@
|
||||
#include <windows.h>
|
||||
#include "Win32Natives.h"
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FindFirstChangeNotificationW
|
||||
* Signature: (Ljava/lang/String;ZI)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindFirstChangeNotificationW
|
||||
(JNIEnv * env, jclass this, jstring lpPathName, jboolean bWatchSubtree, jint dwNotifyFilter) {
|
||||
jlong result;
|
||||
jsize numberOfChars;
|
||||
jchar *path;
|
||||
const jchar *temp;
|
||||
|
||||
// create a new byte array to hold the prefixed and null terminated path
|
||||
numberOfChars= (*env)->GetStringLength(env, lpPathName);
|
||||
path= malloc((numberOfChars + 5) * sizeof(jchar));
|
||||
//path= malloc((numberOfChars + 4) * sizeof(jchar));
|
||||
|
||||
// get the path characters from the vm, copy them, and release them
|
||||
temp= (*env)->GetStringChars(env, lpPathName, JNI_FALSE);
|
||||
memcpy(path + 4, temp, numberOfChars * sizeof(jchar));
|
||||
(*env)->ReleaseStringChars(env, lpPathName, temp);
|
||||
|
||||
// prefix the path to enable long filenames, and null terminate it
|
||||
path[0] = L'\\';
|
||||
path[1] = L'\\';
|
||||
path[2] = L'?';
|
||||
path[3] = L'\\';
|
||||
path[(numberOfChars + 4)] = L'\0';
|
||||
|
||||
// make the request and free the memory
|
||||
//printf("%S\n", path);
|
||||
result = (jlong) FindFirstChangeNotificationW(path, bWatchSubtree, dwNotifyFilter);
|
||||
free(path);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FindFirstChangeNotificationA
|
||||
* Signature: ([BZI)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindFirstChangeNotificationA
|
||||
(JNIEnv * env, jclass this, jbyteArray lpPathName, jboolean bWatchSubtree, jint dwNotifyFilter) {
|
||||
jlong result;
|
||||
jsize numberOfChars;
|
||||
jbyte *path, *temp;
|
||||
|
||||
// create a new byte array to hold the null terminated path
|
||||
numberOfChars = (*env)->GetArrayLength(env, lpPathName);
|
||||
path = malloc((numberOfChars + 1) * sizeof(jbyte));
|
||||
|
||||
// get the path bytes from the vm, copy them, and release them
|
||||
temp = (*env)->GetByteArrayElements(env, lpPathName, 0);
|
||||
memcpy(path, temp, numberOfChars * sizeof(jbyte));
|
||||
(*env)->ReleaseByteArrayElements(env, lpPathName, temp, 0);
|
||||
|
||||
// null terminate the path, make the request, and release the path memory
|
||||
path[numberOfChars] = '\0';
|
||||
result = (jlong) FindFirstChangeNotificationA(path, bWatchSubtree, dwNotifyFilter);
|
||||
free(path);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FindCloseChangeNotification
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindCloseChangeNotification
|
||||
(JNIEnv *env, jclass this, jlong hChangeHandle){
|
||||
return (jboolean) FindCloseChangeNotification((HANDLE) hChangeHandle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FindNextChangeNotification
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FindNextChangeNotification
|
||||
(JNIEnv *env, jclass this, jlong hChangeHandle){
|
||||
return (jboolean) FindNextChangeNotification((HANDLE) hChangeHandle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: WaitForMultipleObjects
|
||||
* Signature: (I[JZI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_WaitForMultipleObjects
|
||||
(JNIEnv *env, jclass this, jint nCount, jlongArray lpHandles, jboolean bWaitAll, jint dwMilliseconds) {
|
||||
int i;
|
||||
jint result;
|
||||
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
|
||||
jlong *handlePointers = (*env)->GetLongArrayElements(env, lpHandles, 0);
|
||||
|
||||
for (i = 0; i < nCount; i++) {
|
||||
handles[i] = (HANDLE) handlePointers[i];
|
||||
}
|
||||
|
||||
result = WaitForMultipleObjects(nCount, handles, bWaitAll, dwMilliseconds);
|
||||
(*env)->ReleaseLongArrayElements(env, lpHandles, handlePointers, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: IsUnicode
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_IsUnicode
|
||||
(JNIEnv *env, jclass this) {
|
||||
OSVERSIONINFO osvi;
|
||||
memset(&osvi, 0, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (! GetVersionEx (&osvi) )
|
||||
return JNI_FALSE;
|
||||
if (osvi.dwMajorVersion >= 5)
|
||||
return JNI_TRUE;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: GetLastError
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_GetLastError
|
||||
(JNIEnv *env, jclass this){
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FILE_NOTIFY_CHANGE_LAST_WRITE
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1LAST_1WRITE
|
||||
(JNIEnv *env, jclass this) {
|
||||
return FILE_NOTIFY_CHANGE_LAST_WRITE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FILE_NOTIFY_CHANGE_DIR_NAME
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1DIR_1NAME
|
||||
(JNIEnv *env, jclass this) {
|
||||
return FILE_NOTIFY_CHANGE_DIR_NAME;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FILE_NOTIFY_CHANGE_ATTRIBUTES
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1ATTRIBUTES
|
||||
(JNIEnv *env, jclass this) {
|
||||
return FILE_NOTIFY_CHANGE_ATTRIBUTES;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FILE_NOTIFY_CHANGE_SIZE
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1SIZE
|
||||
(JNIEnv *env, jclass this) {
|
||||
return FILE_NOTIFY_CHANGE_SIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FILE_NOTIFY_CHANGE_FILE_NAME
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1FILE_1NAME
|
||||
(JNIEnv *env, jclass this) {
|
||||
return FILE_NOTIFY_CHANGE_FILE_NAME;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: FILE_NOTIFY_CHANGE_SECURITY
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_FILE_1NOTIFY_1CHANGE_1SECURITY
|
||||
(JNIEnv *env, jclass this) {
|
||||
return FILE_NOTIFY_CHANGE_SECURITY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: MAXIMUM_WAIT_OBJECTS
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_MAXIMUM_1WAIT_1OBJECTS
|
||||
(JNIEnv *env, jclass this) {
|
||||
return MAXIMUM_WAIT_OBJECTS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: MAX_PATH
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_MAX_1PATH
|
||||
(JNIEnv *env, jclass this) {
|
||||
return MAX_PATH;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: INFINITE
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_INFINITE
|
||||
(JNIEnv *env, jclass this) {
|
||||
return INFINITE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: WAIT_OBJECT_0
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_WAIT_1OBJECT_10
|
||||
(JNIEnv *env, jclass this) {
|
||||
return WAIT_OBJECT_0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: WAIT_FAILED
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_WAIT_1FAILED
|
||||
(JNIEnv *env, jclass this) {
|
||||
return WAIT_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: WAIT_TIMEOUT
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_WAIT_1TIMEOUT
|
||||
(JNIEnv *env, jclass this) {
|
||||
return WAIT_TIMEOUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: ERROR_INVALID_HANDLE
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_ERROR_1INVALID_1HANDLE
|
||||
(JNIEnv *env, jclass this) {
|
||||
return ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: ERROR_SUCCESS
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_ERROR_1SUCCESS
|
||||
(JNIEnv *env, jclass this) {
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_resources_refresh_win32_Win32Natives
|
||||
* Method: INVALID_HANDLE_VALUE
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_resources_refresh_win32_Win32Natives_INVALID_1HANDLE_1VALUE
|
||||
(JNIEnv * env, jclass this) {
|
||||
return (jlong)INVALID_HANDLE_VALUE;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>20th June, 2002</p>
|
||||
<h3>License</h3>
|
||||
<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
|
||||
For purposes of the CPL, "Program" will mean the Content.</p>
|
||||
|
||||
<h3>Contributions</h3>
|
||||
|
||||
<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
|
||||
made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
|
||||
Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
|
||||
|
||||
<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
|
||||
other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
|
||||
host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
|
||||
to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
|
||||
providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
|
||||
the CPL.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* (c) Copyright IBM Corp. 2000, 2001.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#include <windows.h>
|
||||
#include "core.h"
|
||||
|
||||
/*
|
||||
* Converts a FILETIME in a java long (milliseconds).
|
||||
*/
|
||||
jlong fileTimeToMillis(FILETIME ft) {
|
||||
|
||||
ULONGLONG millis = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||
millis = millis / 10000;
|
||||
// difference in milliseconds between
|
||||
// January 1, 1601 00:00:00 UTC (Windows FILETIME)
|
||||
// January 1, 1970 00:00:00 UTC (Java long)
|
||||
// = 11644473600000
|
||||
millis -= 11644473600000;
|
||||
return millis;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a null-terminated byte array from a java byte array.
|
||||
* The returned bytearray needs to be freed when not used
|
||||
* anymore. Use free(result) to do that.
|
||||
*/
|
||||
jbyte* getByteArray(JNIEnv *env, jbyteArray target) {
|
||||
jsize n;
|
||||
jbyte *temp, *result;
|
||||
|
||||
temp = (*env)->GetByteArrayElements(env, target, 0);
|
||||
n = (*env)->GetArrayLength(env, target);
|
||||
result = malloc((n+1) * sizeof(jbyte));
|
||||
memcpy(result, temp, n * sizeof(jbyte));
|
||||
result[n] = '\0';
|
||||
(*env)->ReleaseByteArrayElements(env, target, temp, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalIsUnicode
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalIsUnicode
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
HANDLE hModule;
|
||||
OSVERSIONINFO osvi;
|
||||
memset(&osvi, 0, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (!GetVersionEx (&osvi))
|
||||
return JNI_FALSE;
|
||||
// only Windows NT 4, Windows 2K and XP support Unicode API calls
|
||||
if (!(osvi.dwMajorVersion >= 5 || (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4)))
|
||||
return JNI_FALSE;
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a null-terminated short array from a java char array.
|
||||
* The returned short array needs to be freed when not used
|
||||
* anymore. Use free(result) to do that.
|
||||
*/
|
||||
jchar* getCharArray(JNIEnv *env, jcharArray target) {
|
||||
jsize n;
|
||||
jchar *temp, *result;
|
||||
|
||||
temp = (*env)->GetCharArrayElements(env, target, 0);
|
||||
n = (*env)->GetArrayLength(env, target);
|
||||
result = malloc((n+1) * sizeof(jchar));
|
||||
memcpy(result, temp, n * sizeof(jchar));
|
||||
result[n] = 0;
|
||||
(*env)->ReleaseCharArrayElements(env, target, temp, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalGetStatW
|
||||
* Signature: ([C)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalGetStatW
|
||||
(JNIEnv *env, jclass clazz, jcharArray target) {
|
||||
int i;
|
||||
HANDLE handle;
|
||||
WIN32_FIND_DATAW info;
|
||||
jlong result = 0; // 0 = failed
|
||||
jchar *name;
|
||||
|
||||
name = getCharArray(env, target);
|
||||
|
||||
handle = FindFirstFileW(name, &info);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
// select interesting information
|
||||
// lastModified
|
||||
result = fileTimeToMillis(info.ftLastWriteTime); // lower bits
|
||||
// valid stat
|
||||
result |= STAT_VALID;
|
||||
// folder or file?
|
||||
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
result |= STAT_FOLDER;
|
||||
// read-only?
|
||||
if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
||||
result |= STAT_READ_ONLY;
|
||||
}
|
||||
|
||||
free(name);
|
||||
FindClose(handle);
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalGetStat
|
||||
* Signature: ([B)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalGetStat
|
||||
(JNIEnv *env, jclass clazz, jbyteArray target) {
|
||||
|
||||
HANDLE handle;
|
||||
WIN32_FIND_DATA info;
|
||||
jlong result = 0; // 0 = failed
|
||||
jbyte *name;
|
||||
|
||||
name = getByteArray(env, target);
|
||||
handle = FindFirstFile(name, &info);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
// select interesting information
|
||||
// lastModified
|
||||
result = fileTimeToMillis(info.ftLastWriteTime); // lower bits
|
||||
// valid stat
|
||||
result |= STAT_VALID;
|
||||
// folder or file?
|
||||
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
result |= STAT_FOLDER;
|
||||
// read-only?
|
||||
if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
||||
result |= STAT_READ_ONLY;
|
||||
}
|
||||
|
||||
free(name);
|
||||
FindClose(handle);
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalSetReadOnly
|
||||
* Signature: ([BZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalSetReadOnly
|
||||
(JNIEnv *env, jclass clazz, jbyteArray target, jboolean readOnly) {
|
||||
|
||||
int code, mode;
|
||||
jbyte *name;
|
||||
|
||||
name = getByteArray(env, target);
|
||||
if (readOnly)
|
||||
mode = S_IREAD;
|
||||
else
|
||||
mode = S_IWRITE;
|
||||
code = chmod(name, mode);
|
||||
|
||||
free(name);
|
||||
return code != -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalSetReadOnlyW
|
||||
* Signature: ([CZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalSetReadOnlyW
|
||||
(JNIEnv *env, jclass clazz, jcharArray target, jboolean readOnly) {
|
||||
|
||||
HANDLE handle;
|
||||
jchar *targetFile;
|
||||
int success = JNI_TRUE;
|
||||
DWORD attributes;
|
||||
|
||||
targetFile = getCharArray(env, target);
|
||||
|
||||
attributes = GetFileAttributesW(targetFile);
|
||||
|
||||
if (readOnly)
|
||||
attributes = attributes | FILE_ATTRIBUTE_READONLY;
|
||||
else
|
||||
attributes = attributes & ~FILE_ATTRIBUTE_READONLY;
|
||||
|
||||
success = SetFileAttributesW(targetFile, attributes);
|
||||
|
||||
free(targetFile);
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalCopyAttributes
|
||||
* Signature: ([B[BZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalCopyAttributes
|
||||
(JNIEnv *env, jclass clazz, jbyteArray source, jbyteArray destination, jboolean copyLastModified) {
|
||||
|
||||
HANDLE handle;
|
||||
WIN32_FIND_DATA info;
|
||||
jbyte *sourceFile, *destinationFile;
|
||||
int success = 1;
|
||||
|
||||
sourceFile = getByteArray(env, source);
|
||||
destinationFile = getByteArray(env, destination);
|
||||
|
||||
handle = FindFirstFile(sourceFile, &info);
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
success = SetFileAttributes(destinationFile, info.dwFileAttributes);
|
||||
if (success != 0 && copyLastModified) {
|
||||
// does not honor copyLastModified
|
||||
// call to SetFileTime should pass file handle instead of file name
|
||||
// success = SetFileTime(destinationFile, &info.ftCreationTime, &info.ftLastAccessTime, &info.ftLastWriteTime);
|
||||
}
|
||||
} else {
|
||||
success = 0;
|
||||
}
|
||||
|
||||
free(sourceFile);
|
||||
free(destinationFile);
|
||||
FindClose(handle);
|
||||
return success;
|
||||
}
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalCopyAttributesW
|
||||
* Signature: ([C[CZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalCopyAttributesW
|
||||
(JNIEnv *env, jclass clazz, jcharArray source, jcharArray destination, jboolean copyLastModified) {
|
||||
|
||||
HANDLE handle;
|
||||
WIN32_FIND_DATAW info;
|
||||
jchar *sourceFile, *destinationFile;
|
||||
int success = 1;
|
||||
|
||||
sourceFile = getCharArray(env, source);
|
||||
destinationFile = getCharArray(env, destination);
|
||||
|
||||
handle = FindFirstFileW(sourceFile, &info);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
success = SetFileAttributesW(destinationFile, info.dwFileAttributes);
|
||||
if (success != 0 && copyLastModified) {
|
||||
// does not honor copyLastModified
|
||||
// call to SetFileTime should pass file handle instead of file name
|
||||
// success = SetFileTime(destinationFile, &info.ftCreationTime, &info.ftLastAccessTime, &info.ftLastWriteTime);
|
||||
}
|
||||
} else {
|
||||
success = 0;
|
||||
}
|
||||
|
||||
free(sourceFile);
|
||||
free(destinationFile);
|
||||
FindClose(handle);
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_ant_core_EclipseProject
|
||||
* Method: internalCopyAttributes
|
||||
* Signature: ([B[BZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_ant_core_EclipseFileUtils_internalCopyAttributes
|
||||
(JNIEnv *env, jclass clazz, jbyteArray source, jbyteArray destination, jboolean copyLastModified) {
|
||||
|
||||
// use the same implementation for both methods
|
||||
return Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalCopyAttributes
|
||||
(env, clazz, source, destination, copyLastModified);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
LIBRARY CORE
|
||||
CODE LOADONCALL
|
||||
|
||||
DESCRIPTION 'core DLL.'
|
||||
|
||||
SEGMENTS
|
||||
.data READ WRITE
|
||||
.text EXECUTE READ WRITE
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* (c) Copyright IBM Corp. 2000, 2003.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for core library */
|
||||
|
||||
#ifndef _Included_CORE_LIBRARY
|
||||
#define _Included_CORE_LIBRARY
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef STAT_VALID
|
||||
#define STAT_VALID 0x4000000000000000l
|
||||
#undef STAT_FOLDER
|
||||
#define STAT_FOLDER 0x2000000000000000l
|
||||
#undef STAT_READ_ONLY
|
||||
#define STAT_READ_ONLY 0x1000000000000000l
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalGetStatW
|
||||
* Signature: ([C)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalGetStatW
|
||||
(JNIEnv *, jclass, jcharArray);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalGetStat
|
||||
* Signature: ([B)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalGetStat
|
||||
(JNIEnv *, jclass, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalIsUnicode
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalIsUnicode
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalSetReadOnly
|
||||
* Signature: ([BZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalSetReadOnly
|
||||
(JNIEnv *, jclass, jbyteArray, jboolean);
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalSetReadOnlyW
|
||||
* Signature: ([CZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalSetReadOnly
|
||||
(JNIEnv *, jclass, jcharArray, jboolean);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalCopyAttributes
|
||||
* Signature: ([B[BZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalCopyAttributes
|
||||
(JNIEnv *, jclass, jbyteArray, jbyteArray, jboolean);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_core_internal_localstore_CoreFileSystemLibrary
|
||||
* Method: internalCopyAttributesW
|
||||
* Signature: ([C[CZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_localstore_CoreFileSystemLibrary_internalCopyAttributesW
|
||||
(JNIEnv *, jclass, jcharArray, jcharArray, jboolean);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_ant_core_EclipseProject
|
||||
* Method: internalCopyAttributes
|
||||
* Signature: ([B[BZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_eclipse_ant_core_EclipseFileUtils_internalCopyAttributes
|
||||
(JNIEnv *, jclass, jbyteArray, jbyteArray, jboolean);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>24 June, 2004</p>
|
||||
<h3>License</h3>
|
||||
<p>Eclipse.org makes available all content in this plug-in ("Content"). With the exception of the files listed below, all Content should be defined as the "SWT" and
|
||||
is provided to you under the terms and conditions of the Common Public License Version 1.0 ("CPL").
|
||||
A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
|
||||
For purposes of the CPL, "Program" shall mean the SWT.</p>
|
||||
|
||||
<h3>Third Party Content</h3>
|
||||
|
||||
<h4>Mozilla Binding</h4>
|
||||
|
||||
<p>The following files shall be defined as the "Mozilla Binding":
|
||||
<ul>
|
||||
<li>os/win32/x86/swt-mozilla-win32-3063.dll</li>
|
||||
<li>ws/win32/swt-mozilla.jar</li>
|
||||
<li>ws/win32/swt-mozillasrc.zip</li>
|
||||
</ul>
|
||||
|
||||
<p>The Mozilla Binding contains portions of Mozilla ("Mozilla"). Mozilla is made available by Mozilla.org. Use of Mozilla is governed by the terms and
|
||||
conditions of the Mozilla Public License Version 1.1 ("MPL"). A copy of the MPL is provided with the Content and is also available at
|
||||
<a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>.</p>
|
||||
|
||||
<h3>Contributions</h3>
|
||||
|
||||
<p>If you wish to provide Contributions related to the SWT, such Contributions shall be made under the terms of the CPL. If you wish to make Contributions related
|
||||
to the Mozilla Binding such Contributions shall be made under the terms of the MPL.</p>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>20th June, 2002</p>
|
||||
<h3>License</h3>
|
||||
<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
|
||||
For purposes of the CPL, "Program" will mean the Content.</p>
|
||||
|
||||
<h3>Contributions</h3>
|
||||
|
||||
<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
|
||||
made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
|
||||
Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
|
||||
|
||||
<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
|
||||
other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
|
||||
host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
|
||||
to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
|
||||
providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
|
||||
the CPL.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>20th June, 2002</p>
|
||||
<h3>License</h3>
|
||||
<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
|
||||
For purposes of the CPL, "Program" will mean the Content.</p>
|
||||
|
||||
<h3>Contributions</h3>
|
||||
|
||||
<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
|
||||
made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
|
||||
Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
|
||||
|
||||
<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
|
||||
other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
|
||||
host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
|
||||
to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
|
||||
providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
|
||||
the CPL.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
|
||||
<fragment
|
||||
id="org.eclipse.update.core.win32"
|
||||
name="%fragmentNameWin"
|
||||
version="3.0.0"
|
||||
provider-name="%providerName"
|
||||
plugin-id="org.eclipse.update.core"
|
||||
plugin-version="3.0.0"
|
||||
match="compatible">
|
||||
|
||||
<runtime>
|
||||
</runtime>
|
||||
|
||||
|
||||
</fragment>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="buildlibrary" default="run" basedir=".">
|
||||
|
||||
<!-- The properties ${eclipse-home} ${jdk-path} should be passed into this script -->
|
||||
<!-- The Path should point to the bin directory of BCC55 -->
|
||||
<!-- http://www.borland.com/products/downloads/download_cbuilder.html -->
|
||||
|
||||
<!-- Set a meaningful default value for when it is not. -->
|
||||
<property name="eclipse-home" value="${basedir}/../.."/>
|
||||
<property name="jdk-path" value="${java.home}"/>
|
||||
<property name="destination" value="${eclipse-home}/org.eclipse.update.core.win32/os/win32/x86/"/>
|
||||
<property name="obj-path" value="${eclipse-home}/org.eclipse.update.core.win32/src"/>
|
||||
<property name="src-path" value="${eclipse-home}/org.eclipse.update.core.win32/src/"/>
|
||||
|
||||
<!-- sets the properties -->
|
||||
<property name="library-name" value="update"/>
|
||||
<property name="library-platform" value="dll"/>
|
||||
<property name="library-file" value="${library-name}.${library-platform}"/>
|
||||
|
||||
<!-- This target holds all initialization code that needs to be done for -->
|
||||
<!-- all tests that are to be run. Initialization for individual tests -->
|
||||
<!-- should be done within the body of the suite target. -->
|
||||
<target name="init">
|
||||
<tstamp/>
|
||||
<delete>
|
||||
<fileset dir="${obj-path}" includes="${library-file}"/>
|
||||
<fileset dir="${obj-path}" includes="${library-name}.obj"/>
|
||||
<fileset dir="${obj-path}" includes="${library-name}.tds"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<!-- This target holds code to cleanup the testing environment after -->
|
||||
<!-- after all of the tests have been run. You can use this target to -->
|
||||
<!-- delete temporary files that have been created. -->
|
||||
<target name="cleanup">
|
||||
<delete>
|
||||
<fileset dir="${obj-path}" includes="${library-file}"/>
|
||||
<fileset dir="${obj-path}" includes="${library-name}.obj"/>
|
||||
<fileset dir="${obj-path}" includes="${library-name}.tds"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- This target runs the test suite. Any actions that need to happen -->
|
||||
<!-- after all the tests have been run should go here. -->
|
||||
<target name="run" depends="init,build,cleanup">
|
||||
</target>
|
||||
|
||||
<!-- This target build the dll -->
|
||||
<target name="build">
|
||||
<echo message="Building ${library-file}"/>
|
||||
|
||||
<property name="header-path" value="${jdk-path}/include"/>
|
||||
<property name="header-windows-path" value="${header-path}/win32" />
|
||||
|
||||
<echo message="bcc32 -I${src-path} -I${header-windows-path} -WD"/>
|
||||
|
||||
<apply executable="bcc32" dest="${eclipse-home}/" parallel="false">
|
||||
<arg value="-I${src-path}"/>
|
||||
<arg value="-I${header-path}"/>
|
||||
<arg value="-I${header-windows-path}"/>
|
||||
<!-- arg value="-DUNICODE" -->
|
||||
<arg value="-w-8057"/>
|
||||
<arg value="-WD"/>
|
||||
<srcfile/>
|
||||
<fileset dir="${src-path}" includes="*.cpp"/>
|
||||
<mapper type="glob" from="*.cpp" to="*.obj"/>
|
||||
</apply>
|
||||
|
||||
<move file="${library-file}" todir="${destination}"/>
|
||||
</target>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,487 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2002 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
# include <update.h>
|
||||
# include <windows.h>
|
||||
# include <winioctl.h> // IOCTL codes: MediaType
|
||||
|
||||
// Windows Version
|
||||
int WIN98 = 0;
|
||||
int WINNT = 1;
|
||||
int WINME = 2;
|
||||
int WIN2000 = 3;
|
||||
int WINXP = 4;
|
||||
|
||||
// set to 1 for DEBUG
|
||||
int DEBUG = 0;
|
||||
|
||||
// set to 0 to run on Windows 95 *Unsupported*
|
||||
int NOWIN95 = 1;
|
||||
|
||||
|
||||
// GLOBAL METHODS
|
||||
// ---------------
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
jstring WindowsTojstring( JNIEnv* jnienv, char* buf )
|
||||
{
|
||||
jstring rtn = 0;
|
||||
wchar_t* buffer = 0;
|
||||
int bufferLen = strlen(buf);
|
||||
if( bufferLen == 0 ){
|
||||
rtn = jnienv ->NewStringUTF(buf);
|
||||
if (DEBUG)
|
||||
printf("WindowsToJString Buffer is empty\n");
|
||||
} else {
|
||||
int length = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)buf, bufferLen, NULL, 0 );
|
||||
buffer = (wchar_t*)malloc( length*2 + 1 );
|
||||
if(int err=MultiByteToWideChar( CP_ACP, 0, (LPCSTR)buf, bufferLen, (LPWSTR)buffer, length ) >0 ){
|
||||
rtn = jnienv->NewString((jchar*)buffer, length );
|
||||
} else {
|
||||
if (DEBUG)
|
||||
printf("MultiByteToWideChar %i\n",err);
|
||||
}
|
||||
}
|
||||
if( buffer )
|
||||
free( buffer );
|
||||
return rtn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* calls GetVolumeInformation to retrive the label of the volume
|
||||
* Returns NULL if an error occurs
|
||||
* @param driveLetter path to the drive "c:\\"
|
||||
* @prama jnienv JNIEnvironment
|
||||
*/
|
||||
jstring getLabel(TCHAR driveLetter[],JNIEnv * jnienv){
|
||||
|
||||
jstring result = NULL;
|
||||
TCHAR buf[128];
|
||||
|
||||
// always return null as UNICODE is not implemented
|
||||
// how can we get the label of a volume as UNICODE char ?
|
||||
return result;
|
||||
|
||||
int err = GetVolumeInformation(
|
||||
driveLetter,
|
||||
buf,
|
||||
sizeof(buf) - 1,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
if (err){
|
||||
result = WindowsTojstring(jnienv, buf);
|
||||
} else {
|
||||
if (DEBUG)
|
||||
printf("Error GetVolumeInformation %i\n",err);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the Version of Windows
|
||||
* int 0 WIN98;
|
||||
* int 1 WINNT;
|
||||
* int 2 WINME;
|
||||
* int 3 WIN2000;
|
||||
* int 4 WINXP;
|
||||
* returns -1 otherwise
|
||||
*/
|
||||
int getWindowsVersion(){
|
||||
OSVERSIONINFOEX osvi;
|
||||
int UNKNOWN = -1;
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
|
||||
if(!(GetVersionEx((OSVERSIONINFO *)&osvi))){
|
||||
if (DEBUG)
|
||||
printf("UNKNOWN VERSION: Cannot execute GetVersionEx\n");
|
||||
// if OSVERSIONEX doesn't work, try OSVERSIONINFO
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if(!(GetVersionEx((OSVERSIONINFO *)&osvi))){
|
||||
if (DEBUG)
|
||||
printf("UNKNOWN VERSION: Cannot execute GetVersionEx\n");
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
switch(osvi.dwPlatformId){
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
if (DEBUG)
|
||||
printf("VERSION NT: Maj %i Min %i\n",osvi.dwMajorVersion,osvi.dwMinorVersion);
|
||||
if(osvi.dwMajorVersion<=4)
|
||||
return WINNT;
|
||||
if(osvi.dwMajorVersion==5){
|
||||
if (osvi.dwMinorVersion==0)
|
||||
return WIN2000;
|
||||
if (osvi.dwMinorVersion==1)
|
||||
return WINXP;
|
||||
} else {
|
||||
return UNKNOWN;
|
||||
};
|
||||
break;
|
||||
case VER_PLATFORM_WIN32_WINDOWS:
|
||||
if (DEBUG)
|
||||
printf("VERSION Non NT: Maj %i Min %i\n",osvi.dwMajorVersion,osvi.dwMinorVersion);
|
||||
if(osvi.dwMajorVersion==4){
|
||||
if (osvi.dwMinorVersion==10)
|
||||
return WIN98;
|
||||
if (osvi.dwMinorVersion==90)
|
||||
return WINME;
|
||||
} else {
|
||||
return UNKNOWN;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (DEBUG)
|
||||
printf("VERSION UNKNOWN: Maj %i Min %i\n",osvi.dwMajorVersion,osvi.dwMinorVersion);
|
||||
return UNKNOWN;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the type of Removable Drive
|
||||
* Returns
|
||||
* org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_3
|
||||
* org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_5
|
||||
* org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOVABLE
|
||||
*/
|
||||
jlong getFloppy(TCHAR driveLetter[]){
|
||||
|
||||
TCHAR floppyPath[8];
|
||||
HANDLE handle;
|
||||
DISK_GEOMETRY geometry[20];
|
||||
DWORD dw;
|
||||
jlong UNKNOWN = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOVABLE;
|
||||
|
||||
sprintf(floppyPath, "\\\\.\\%c:", driveLetter[0]);
|
||||
if (DEBUG)
|
||||
printf("Path %s\n",floppyPath);
|
||||
// BUG 25719
|
||||
SetErrorMode( SEM_FAILCRITICALERRORS );
|
||||
handle=CreateFile(floppyPath,0,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL);
|
||||
if (handle==INVALID_HANDLE_VALUE){
|
||||
if (DEBUG)
|
||||
printf("Invalid Handle %s\n",floppyPath);
|
||||
return UNKNOWN;
|
||||
} else {
|
||||
if(DeviceIoControl(handle,
|
||||
IOCTL_DISK_GET_MEDIA_TYPES,0,0,
|
||||
geometry,sizeof(geometry),&dw,0)
|
||||
&& dw>0) {
|
||||
switch(geometry[0].MediaType){
|
||||
case F5_160_512:
|
||||
case F5_180_512:
|
||||
case F5_320_512:
|
||||
case F5_320_1024:
|
||||
case F5_360_512:
|
||||
case F5_1Pt2_512:
|
||||
if (DEBUG)
|
||||
printf("Found 5 1/4 Drive\n");
|
||||
return org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_5;
|
||||
case F3_720_512:
|
||||
case F3_1Pt44_512:
|
||||
case F3_2Pt88_512:
|
||||
case F3_20Pt8_512:
|
||||
if (DEBUG)
|
||||
printf("Found 3 1/2 Drive\n");
|
||||
return org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_3;
|
||||
default:
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the UNC name of a remote drive
|
||||
* (\\Machine\path\path1\path2$)
|
||||
* returns NULL if an error occurs
|
||||
*/
|
||||
jstring getRemoteNetworkName(TCHAR driveLetter[],JNIEnv * jnienv){
|
||||
|
||||
unsigned long size =256;
|
||||
TCHAR buf[256];
|
||||
TCHAR drivePath[2];
|
||||
DWORD err;
|
||||
jstring result = NULL;
|
||||
|
||||
// always return NULL as UNICODE not implemented
|
||||
// how can we get the label of a remote network name as UNICODE char ?
|
||||
return result;
|
||||
|
||||
sprintf(drivePath, "%c:", driveLetter[0]);
|
||||
err = WNetGetConnection(drivePath,buf,&size);
|
||||
|
||||
if (err==WN_SUCCESS){
|
||||
result = WindowsTojstring(jnienv,buf);
|
||||
} else {
|
||||
if (DEBUG)
|
||||
printf("Error WNEtGetConnection %i",err);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// JNI METHODS
|
||||
// ---------------
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeGetFreeSpace
|
||||
* Signature: (Ljava/io/File;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeGetFreeSpace(
|
||||
JNIEnv * jnienv,
|
||||
jclass javaClass,
|
||||
jobject file) {
|
||||
|
||||
// to retrive the String
|
||||
jclass cls;
|
||||
jmethodID id;
|
||||
jobject obj;
|
||||
|
||||
// java.io.File.getAbsolutePath()
|
||||
const TCHAR * lpDirectoryName;
|
||||
|
||||
// Windows Parameters
|
||||
__int64 i64FreeBytesAvailableToCaller;
|
||||
__int64 i64TotalNumberOfBytes;
|
||||
__int64 i64TotalNumberOfFreeBytes;
|
||||
|
||||
// the result
|
||||
jlong result = org_eclipse_update_configuration_LocalSystemInfo_SIZE_UNKNOWN;
|
||||
|
||||
// first, obtain the Path from the java.io.File parameter
|
||||
cls = jnienv -> GetObjectClass(file);
|
||||
id = jnienv -> GetMethodID(cls, "getAbsolutePath", "()Ljava/lang/String;");
|
||||
obj = jnienv -> CallObjectMethod(file, id);
|
||||
lpDirectoryName = jnienv -> GetStringUTFChars((jstring) obj, 0);
|
||||
if (DEBUG)
|
||||
printf("Directory: [%s]\n",lpDirectoryName);
|
||||
|
||||
if (int win = (int)getWindowsVersion()<0 && NOWIN95){
|
||||
// windows 95 or other
|
||||
if (DEBUG)
|
||||
printf("Unsupported Windows: %i\n",win);
|
||||
return result;
|
||||
}
|
||||
|
||||
int err = GetDiskFreeSpaceEx(
|
||||
lpDirectoryName,
|
||||
(PULARGE_INTEGER) & i64FreeBytesAvailableToCaller,
|
||||
(PULARGE_INTEGER) & i64TotalNumberOfBytes,
|
||||
(PULARGE_INTEGER) & i64TotalNumberOfFreeBytes);
|
||||
|
||||
if (err) {
|
||||
result = (jlong) i64FreeBytesAvailableToCaller;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeGetLabel
|
||||
* Signature: (Ljava/io/File;)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeGetLabel(
|
||||
JNIEnv * jnienv,
|
||||
jclass javaClass,
|
||||
jobject file) {
|
||||
|
||||
// to retrive the String
|
||||
jclass cls;
|
||||
jmethodID id;
|
||||
jobject obj;
|
||||
|
||||
// java.io.File.getAbsolutePath()
|
||||
const TCHAR * lpDirectoryName;
|
||||
|
||||
// obtain the String from the parameter
|
||||
cls = jnienv -> GetObjectClass(file);
|
||||
id = jnienv -> GetMethodID(cls, "getAbsolutePath", "()Ljava/lang/String;");
|
||||
obj = jnienv -> CallObjectMethod(file, id);
|
||||
lpDirectoryName = jnienv -> GetStringUTFChars((jstring) obj, 0);
|
||||
if (DEBUG)
|
||||
printf("Directory: [%s]\n",lpDirectoryName);
|
||||
|
||||
//
|
||||
jstring result = NULL;
|
||||
int floppy;
|
||||
|
||||
if (int win = (int)getWindowsVersion()<0 && NOWIN95){
|
||||
// windows 95 or other
|
||||
if (DEBUG)
|
||||
printf("Unsupported Windows: %i\n",win);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Make sure we have a String of the Form: <letter>:
|
||||
if (':' == lpDirectoryName[1]) {
|
||||
TCHAR driveLetter[4]; // i.e. -> C:\\
|
||||
memcpy(driveLetter, lpDirectoryName, 2);
|
||||
strcpy(driveLetter + 2, "\\");
|
||||
switch (GetDriveType(driveLetter)) {
|
||||
case DRIVE_REMOTE :
|
||||
// check name of machine and path of remote
|
||||
if (DEBUG)
|
||||
printf("Remote Drive");
|
||||
result = getRemoteNetworkName(driveLetter,jnienv);
|
||||
break;
|
||||
default :
|
||||
if (DEBUG)
|
||||
printf("Another Drive at %s", driveLetter);
|
||||
result = getLabel(driveLetter,jnienv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeGetType
|
||||
* Signature: (Ljava/io/File;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeGetType(
|
||||
JNIEnv * jnienv,
|
||||
jclass javaClass,
|
||||
jobject file) {
|
||||
|
||||
// to retrive the String
|
||||
jclass cls;
|
||||
jmethodID id;
|
||||
jobject obj;
|
||||
|
||||
// java.io.File.getAbsolutePath()
|
||||
const TCHAR * lpDirectoryName;
|
||||
|
||||
// obtain the String from the parameter
|
||||
cls = jnienv -> GetObjectClass(file);
|
||||
id = jnienv -> GetMethodID(cls, "getAbsolutePath", "()Ljava/lang/String;");
|
||||
obj = jnienv -> CallObjectMethod(file, id);
|
||||
lpDirectoryName = jnienv -> GetStringUTFChars((jstring) obj, 0);
|
||||
if (DEBUG)
|
||||
printf("Directory: [%s]\n",lpDirectoryName);
|
||||
|
||||
int result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_UNKNOWN;
|
||||
if (int win = (int)getWindowsVersion()<0 && NOWIN95){
|
||||
// windows 95 or other
|
||||
if (DEBUG)
|
||||
printf("Unsupported Windows: %i\n",win);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Make sure we have a String of the Form: <letter>:
|
||||
if (':' == lpDirectoryName[1]) {
|
||||
TCHAR driveLetter[4]; //C:\\
|
||||
memcpy(driveLetter, lpDirectoryName, 2);
|
||||
strcpy(driveLetter + 2, "\\");
|
||||
|
||||
switch (GetDriveType(driveLetter)) {
|
||||
case DRIVE_REMOVABLE :
|
||||
// check if floppy 3.5, floppy 5.25
|
||||
// or other removable device (USB,PCMCIA ...)
|
||||
if (DEBUG)
|
||||
printf("Removable Device");
|
||||
result = getFloppy(driveLetter);
|
||||
break;
|
||||
case DRIVE_CDROM :
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_CDROM;
|
||||
break;
|
||||
case DRIVE_FIXED :
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FIXED;
|
||||
break;
|
||||
case DRIVE_REMOTE :
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOTE;
|
||||
break;
|
||||
case DRIVE_NO_ROOT_DIR :
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_INVALID_PATH;
|
||||
break;
|
||||
case DRIVE_RAMDISK :
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_RAMDISK;
|
||||
break;
|
||||
case DRIVE_UNKNOWN :
|
||||
default :
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
result = org_eclipse_update_configuration_LocalSystemInfo_VOLUME_INVALID_PATH;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeListMountPoints
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeListMountPoints(
|
||||
JNIEnv * jnienv,
|
||||
jclass javaClass) {
|
||||
|
||||
//
|
||||
DWORD logDrives;
|
||||
UINT drive;
|
||||
TCHAR driveName[100];
|
||||
jobjectArray returnArray;
|
||||
int nDrive = 0;
|
||||
|
||||
//
|
||||
jclass stringClass;
|
||||
jobject empty;
|
||||
int index = 0;
|
||||
jobject str;
|
||||
|
||||
|
||||
logDrives = GetLogicalDrives();
|
||||
for (drive = 0; drive < 32; drive++) {
|
||||
if (logDrives & (1 << drive)) {
|
||||
nDrive++;
|
||||
}
|
||||
}
|
||||
|
||||
stringClass = jnienv -> FindClass("java/lang/String");
|
||||
empty = jnienv -> NewStringUTF("");
|
||||
returnArray = jnienv -> NewObjectArray(nDrive, stringClass, empty);
|
||||
|
||||
if (int win = (int)getWindowsVersion()<0 && NOWIN95){
|
||||
// windows 95 or other
|
||||
if (DEBUG)
|
||||
printf("Unsupported Windows: %i\n",win);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (drive = 0; drive < 32; drive++) {
|
||||
if (logDrives & (1 << drive)) {
|
||||
sprintf(driveName, "%c:\\", drive + 'A');
|
||||
str = jnienv -> NewStringUTF(driveName);
|
||||
jnienv -> SetObjectArrayElement(returnArray, index, str);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2002 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
#include <jni.h>
|
||||
/* Header for class org_eclipse_update_configuration_LocalSystemInfo */
|
||||
|
||||
#ifndef _Included_org_eclipse_update_configuration_LocalSystemInfo
|
||||
#define _Included_org_eclipse_update_configuration_LocalSystemInfo
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_SIZE_UNKNOWN
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_SIZE_UNKNOWN -1L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_UNKNOWN
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_UNKNOWN -1L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_INVALID_PATH
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_INVALID_PATH -2L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOVABLE
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOVABLE 1L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FIXED
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FIXED 2L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOTE
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_REMOTE 3L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_CDROM
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_CDROM 4L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_RAMDISK
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_RAMDISK 5L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_5
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_5 6L
|
||||
#undef org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_3
|
||||
#define org_eclipse_update_configuration_LocalSystemInfo_VOLUME_FLOPPY_3 7L
|
||||
/* Inaccessible static: listeners */
|
||||
/* Inaccessible static: hasNatives */
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeGetFreeSpace
|
||||
* Signature: (Ljava/io/File;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeGetFreeSpace
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeGetLabel
|
||||
* Signature: (Ljava/io/File;)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeGetLabel
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeGetType
|
||||
* Signature: (Ljava/io/File;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeGetType
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_update_configuration_LocalSystemInfo
|
||||
* Method: nativeListMountPoints
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_update_configuration_LocalSystemInfo_nativeListMountPoints
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user