2004/11/20

For the record:

  1. I re-iterate this advice.
  2. Half-life 2 does rock.
  3. The most exquisite torture device known to man is woman.
  4. Seamlessly opening arbitrary file types with the correct program in Java on Windows is stupidly annoying. This is the Mac version:
    /**
    
    * @author Frederik Zimmer
    */

    public class MacOSXFileLauncher extends AbstractFileLauncher {
    public void launchFile(File file) throws IOException {
    Runtime.getRuntime().exec(
    new String[] { "open", file.getCanonicalPath() });
    }
    }
    And this is the Windows version, accessed via JNI:


    JNIEXPORT jint JNICALL Java_ziga_util_WindowsFileLauncher_launchFile
    
    (JNIEnv *pEnv, jobject, jstring filepath) {

    int length = pEnv->GetStringLength(filepath);
    const jchar* jcstr = pEnv->GetStringChars(filepath, 0);
    char* cFilepath = (char*) malloc(length*2+1);
    int size = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) jcstr, length, cFilepath, (length*2+1), NULL, NULL);
    cFilepath[size] = 0;
    pEnv->ReleaseStringChars(filepath, jcstr);

    HINSTANCE returnCode = ShellExecute(NULL, "open", cFilepath, NULL, NULL, SW_SHOWNORMAL);

    return (jint) returnCode;
    }


    I rest my case.