Revision 642 libsylph/utils.c
| utils.c (revision 642) | ||
|---|---|---|
| 42 | 42 |
#include <time.h> |
| 43 | 43 |
|
| 44 | 44 |
#ifdef G_OS_WIN32 |
| 45 |
# include <windows.h> |
|
| 45 | 46 |
# include <wchar.h> |
| 46 | 47 |
# include <direct.h> |
| 47 | 48 |
# include <io.h> |
| ... | ... | |
| 426 | 427 |
return dest; |
| 427 | 428 |
} |
| 428 | 429 |
|
| 430 |
/* Similar to g_str_has_suffix() but case-insensitive */ |
|
| 431 |
gboolean str_has_suffix_case(const gchar *str, const gchar *suffix) |
|
| 432 |
{
|
|
| 433 |
size_t len, s_len; |
|
| 434 |
|
|
| 435 |
if (!str || !suffix) |
|
| 436 |
return FALSE; |
|
| 437 |
|
|
| 438 |
len = strlen(str); |
|
| 439 |
s_len = strlen(suffix); |
|
| 440 |
|
|
| 441 |
if (s_len > len) |
|
| 442 |
return FALSE; |
|
| 443 |
|
|
| 444 |
return (g_ascii_strcasecmp(str + (len - s_len), suffix) == 0); |
|
| 445 |
} |
|
| 446 |
|
|
| 429 | 447 |
/* Examine if next block is non-ASCII string */ |
| 430 | 448 |
gboolean is_next_nonascii(const gchar *s) |
| 431 | 449 |
{
|
| ... | ... | |
| 3063 | 3081 |
return ret; |
| 3064 | 3082 |
} |
| 3065 | 3083 |
|
| 3084 |
gint execute_open_file(const gchar *file, const gchar *content_type) |
|
| 3085 |
{
|
|
| 3086 |
g_return_val_if_fail(file != NULL, -1); |
|
| 3087 |
|
|
| 3088 |
#ifdef G_OS_WIN32 |
|
| 3089 |
log_print("opening %s - %s\n", file, content_type ? content_type : "");
|
|
| 3090 |
|
|
| 3091 |
if (G_WIN32_HAVE_WIDECHAR_API()) {
|
|
| 3092 |
wchar_t *wpath; |
|
| 3093 |
|
|
| 3094 |
wpath = g_utf8_to_utf16(file, -1, NULL, NULL, NULL); |
|
| 3095 |
if (wpath == NULL) |
|
| 3096 |
return -1; |
|
| 3097 |
|
|
| 3098 |
ShellExecuteW(NULL, L"open", wpath, NULL, NULL, SW_SHOWNORMAL); |
|
| 3099 |
|
|
| 3100 |
g_free(wpath); |
|
| 3101 |
|
|
| 3102 |
return 0; |
|
| 3103 |
} else {
|
|
| 3104 |
gchar *cp_path; |
|
| 3105 |
|
|
| 3106 |
cp_path = g_locale_from_utf8(file, -1, NULL, NULL, NULL); |
|
| 3107 |
if (cp_path == NULL) |
|
| 3108 |
return -1; |
|
| 3109 |
|
|
| 3110 |
ShellExecuteA(NULL, "open", cp_path, NULL, NULL, SW_SHOWNORMAL); |
|
| 3111 |
|
|
| 3112 |
g_free(cp_path); |
|
| 3113 |
|
|
| 3114 |
return 0; |
|
| 3115 |
} |
|
| 3116 |
#endif |
|
| 3117 |
return 0; |
|
| 3118 |
} |
|
| 3119 |
|
|
| 3066 | 3120 |
gchar *get_command_output(const gchar *cmdline) |
| 3067 | 3121 |
{
|
| 3068 | 3122 |
gchar *child_stdout; |
Also available in: Unified diff