/** * This implementation of <code>nativeToJava</code> converts a platform specific representation of * a list of file names to a java <code>String[]</code>. Each String in the array contains the * absolute path for a single file or directory. For additional information see <code> * Transfer#nativeToJava</code>. * * @param transferData the platform specific representation of the data to be been converted * @return a java <code>String[]</code> containing a list of file names if the conversion was * successful; otherwise null */ public Object nativeToJava(TransferData transferData) { if (!isSupportedType(transferData) || transferData.pIDataObject == 0) return null; // get file names from IDataObject IDataObject dataObject = new IDataObject(transferData.pIDataObject); dataObject.AddRef(); FORMATETC formatetc = new FORMATETC(); formatetc.cfFormat = COM.CF_HDROP; formatetc.ptd = 0; formatetc.dwAspect = COM.DVASPECT_CONTENT; formatetc.lindex = -1; formatetc.tymed = COM.TYMED_HGLOBAL; STGMEDIUM stgmedium = new STGMEDIUM(); stgmedium.tymed = COM.TYMED_HGLOBAL; transferData.result = dataObject.GetData(formatetc, stgmedium); dataObject.Release(); if (transferData.result != COM.S_OK) return null; // How many files are there? int count = OS.DragQueryFile(stgmedium.unionField, 0xFFFFFFFF, null, 0); String[] fileNames = new String[count]; for (int i = 0; i < count; i++) { // How long is the name ? int size = OS.DragQueryFile(stgmedium.unionField, i, null, 0) + 1; TCHAR lpszFile = new TCHAR(0, size); // Get file name and append it to string OS.DragQueryFile(stgmedium.unionField, i, lpszFile, size); fileNames[i] = lpszFile.toString(0, lpszFile.strlen()); } OS.DragFinish(stgmedium.unionField); // frees data associated with HDROP data return fileNames; }
static String getCacheParentPath() { /* Use the character encoding for the default locale */ TCHAR buffer = new TCHAR(0, OS.MAX_PATH); if (OS.SHGetFolderPath(0, OS.CSIDL_LOCAL_APPDATA, 0, OS.SHGFP_TYPE_CURRENT, buffer) == OS.S_OK) { return buffer.toString(0, buffer.strlen()) + Mozilla.SEPARATOR_OS + "eclipse"; // $NON-NLS-1$ } return getProfilePath(); }
static String getProfilePath() { String baseDir; /* Use the character encoding for the default locale */ TCHAR buffer = new TCHAR(0, OS.MAX_PATH); if (OS.SHGetFolderPath(0, OS.CSIDL_APPDATA, 0, OS.SHGFP_TYPE_CURRENT, buffer) == OS.S_OK) { baseDir = buffer.toString(0, buffer.strlen()); } else { baseDir = System.getProperty("user.home"); // $NON-NLS-1$ } return baseDir + Mozilla.SEPARATOR_OS + "Mozilla" + Mozilla.SEPARATOR_OS + "eclipse"; //$NON-NLS-1$ //$NON-NLS-2$ }