com.sun.jna.platform.win32.ShlObj Java Examples

The following examples show how to use com.sun.jna.platform.win32.ShlObj. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Settings.java    From gtasa-savegame-editor with MIT License 6 votes vote down vote up
private static File getSettingsFile() {
    if (WINDOWS) {
        char[] path = new char[]{};
        if (Shell32.INSTANCE.SHGetSpecialFolderPath(null, path, ShlObj.CSIDL_LOCAL_APPDATA, false)) {
            configDir = String.valueOf(path) + File.separator + "gta-sa_savegame_editor";
        } else {
            log.warn("Unable to determine appdata folder! Falling back to old config dir!");
            return new File(System.getProperty("user.home"), ".gta_sa_savegame_editor");
        }
    } else {
        String xdgConfigHome = System.getenv("XDG_CONFIG_HOME");
        if (xdgConfigHome == null || xdgConfigHome.isBlank() || xdgConfigHome.isEmpty()) {
            configDir = System.getProperty("user.home") + File.separator + ".config" + File.separator + "gta-sa_savegame_editor";
        } else {
            configDir = xdgConfigHome + File.separator + "gta-sa_savegame_editor";
        }
    }
    return new File(configDir, "config");
}
 
Example #2
Source File: Unity3dPackageWatcher.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<String> getUnityUserPaths()
{
	List<String> paths = new SmartList<>();
	if(SystemInfo.isWinVistaOrNewer)
	{
		paths.add(Shell32Util.getFolderPath(ShlObj.CSIDL_LOCAL_APPDATA) + "\\Unity");

		PointerByReference pointerByReference = new PointerByReference();
		// LocalLow
		WinNT.HRESULT hresult = Shell32.INSTANCE.SHGetKnownFolderPath(Guid.GUID.fromString("{A520A1A4-1780-4FF6-BD18-167343C5AF16}"), 0, null, pointerByReference);

		if(hresult.longValue() == 0)
		{
			paths.add(pointerByReference.getValue().getWideString(0) + "\\Unity");
		}
	}
	else if(SystemInfo.isMac)
	{
		paths.add(SystemProperties.getUserHome() + "/Library/Unity");
	}
	else if(SystemInfo.isLinux)
	{
		paths.add(SystemProperties.getUserHome() + "/.config/unity3d");
	}

	return paths;
}
 
Example #3
Source File: DefaultPaths.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public File getExternalPlatformDirectory(@Nonnull File defaultPath) {
  return new File(Shell32Util.getFolderPath(ShlObj.CSIDL_APPDATA), "Consulo Platform");
}
 
Example #4
Source File: DefaultPaths.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected String getDocumentsDirNoPrefix() {
  return Shell32Util.getFolderPath(ShlObj.CSIDL_PERSONAL);
}
 
Example #5
Source File: DefaultPaths.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected String getLocalSettingsDirNoPrefix() {
  // will return path like C:\Users\{user.name}\AppData\Local
  return Shell32Util.getFolderPath(ShlObj.CSIDL_LOCAL_APPDATA);
}
 
Example #6
Source File: DefaultPaths.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected String getRoamingSettingsDirNoPrefix() {
  // will return path like C:\Users\{user.name}\AppData\Roaming
  return Shell32Util.getFolderPath(ShlObj.CSIDL_APPDATA);
}