2012-03-12 19:43:27 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Copyright (c) 2001, Sven Eberhardt
|
|
|
|
* Copyright (c) 2010-2013, The OpenClonk Team and contributors
|
2012-03-12 19:43:27 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
2012-03-12 19:43:27 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
2012-03-12 19:43:27 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
2012-03-12 19:43:27 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-03 18:07:56 +00:00
|
|
|
#include "C4Include.h"
|
2012-03-12 19:43:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2016-04-03 18:07:56 +00:00
|
|
|
#include "platform/C4windowswrapper.h"
|
2012-03-12 19:43:27 +00:00
|
|
|
#include <shellapi.h>
|
|
|
|
bool OpenURL(const char *szURL)
|
|
|
|
{
|
|
|
|
return (intptr_t)ShellExecuteW(NULL, L"open", GetWideChar(szURL), NULL, NULL, SW_SHOW) > 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EraseItemSafe(const char *szFilename)
|
|
|
|
{
|
|
|
|
char Filename[_MAX_PATH+1];
|
|
|
|
SCopy(szFilename, Filename, _MAX_PATH);
|
|
|
|
Filename[SLen(Filename)+1]=0;
|
2016-01-24 05:43:09 +00:00
|
|
|
auto wide_filename = GetWideChar(Filename, true); // wide_filename holds the buffer
|
2012-03-12 19:43:27 +00:00
|
|
|
SHFILEOPSTRUCTW shs;
|
|
|
|
shs.hwnd=0;
|
|
|
|
shs.wFunc=FO_DELETE;
|
2016-01-24 05:43:09 +00:00
|
|
|
shs.pFrom = wide_filename;
|
2012-03-12 19:43:27 +00:00
|
|
|
shs.pTo=NULL;
|
|
|
|
shs.fFlags=FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT;
|
|
|
|
shs.fAnyOperationsAborted=false;
|
|
|
|
shs.hNameMappings=0;
|
|
|
|
shs.lpszProgressTitle=NULL;
|
2016-01-24 05:43:09 +00:00
|
|
|
auto error = SHFileOperationW(&shs);
|
|
|
|
return !error;
|
2012-03-12 19:43:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsGermanSystem()
|
|
|
|
{
|
|
|
|
return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_GERMAN;
|
|
|
|
}
|
|
|
|
#elif !defined(__APPLE__)
|
|
|
|
|
|
|
|
bool IsGermanSystem()
|
|
|
|
{
|
|
|
|
if (strstr(setlocale(LC_MESSAGES, 0), "de"))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EraseItemSafe(const char *szFilename)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-22 22:29:51 +00:00
|
|
|
#ifdef USE_GTK
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
bool OpenURL(const char *szURL)
|
|
|
|
{
|
|
|
|
GError *error = 0;
|
|
|
|
if (gtk_show_uri(NULL, szURL, GDK_CURRENT_TIME, &error))
|
|
|
|
return true;
|
|
|
|
if (error != NULL)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "Unable to open URL: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
const char * argv[][3] =
|
|
|
|
{
|
|
|
|
{ "xdg-open", szURL, 0 },
|
|
|
|
{ "sensible-browser", szURL, 0 },
|
|
|
|
{ "firefox", szURL, 0 },
|
|
|
|
{ "mozilla", szURL, 0 },
|
|
|
|
{ "konqueror", szURL, 0 },
|
|
|
|
{ "epiphany", szURL, 0 },
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
};
|
|
|
|
for (int i = 0; argv[i][0]; ++i)
|
|
|
|
{
|
|
|
|
error = 0;
|
|
|
|
if (g_spawn_async (g_get_home_dir(), const_cast<char**>(argv[i]), 0, G_SPAWN_SEARCH_PATH, 0, 0, 0, &error))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#else
|
2012-03-12 19:43:27 +00:00
|
|
|
bool OpenURL(char const*) {return 0;}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|