summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2010-04-14 16:01:26 +0000
committerjstebbins <[email protected]>2010-04-14 16:01:26 +0000
commitabeea8ddf0b918eeb48b438d72f8db7a4c166997 (patch)
treeb4631b418888ea342f965c2b6e97e8b0900ac233 /gtk
parent788762ec1d905d4783a62de27863ec8ebf66d284 (diff)
LinGui: fix a mingw build issue
The new multi-instance file locking needs to be ifdef'd for mingw git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3221 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/main.c68
-rw-r--r--gtk/src/presets.c15
2 files changed, 69 insertions, 14 deletions
diff --git a/gtk/src/main.c b/gtk/src/main.c
index fc52e2a1a..3782efe95 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -40,7 +40,6 @@
#else
#include <windows.h>
#include <io.h>
-//#include <pthread/pthread.h>
#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
#endif
@@ -521,6 +520,7 @@ bind_presets_tree_model (signal_user_data_t *ud)
static void
clean_old_logs()
{
+#if !defined(_WIN32)
const gchar *file;
gchar *config;
@@ -543,7 +543,7 @@ clean_old_logs()
path = g_strdup_printf("%s/ghb.pid.%d", config, pid);
if (g_file_test(path, G_FILE_TEST_EXISTS))
{
- fd = g_open(path, O_RDWR);
+ fd = open(path, O_RDWR);
if (fd >= 0)
{
lock = lockf(fd, F_TLOCK, 0);
@@ -570,6 +570,60 @@ clean_old_logs()
g_dir_close(gdir);
}
g_free(config);
+#else
+ const gchar *file;
+ gchar *config;
+
+ config = ghb_get_user_config_dir(NULL);
+
+ if (g_file_test(config, G_FILE_TEST_IS_DIR))
+ {
+ GDir *gdir = g_dir_open(config, 0, NULL);
+ file = g_dir_read_name(gdir);
+ while (file)
+ {
+ if (strncmp(file, "Activity.log.", 13) == 0)
+ {
+ gchar *path;
+ int pid;
+
+ sscanf(file, "Activity.log.%d", &pid);
+
+#if 0
+ int fd, lock = 1;
+
+ path = g_strdup_printf("%s/ghb.pid.%d", config, pid);
+ if (g_file_test(path, G_FILE_TEST_EXISTS))
+ {
+ fd = open(path, O_RDWR);
+ if (fd >= 0)
+ {
+ lock = lockf(fd, F_TLOCK, 0);
+ }
+ g_free(path);
+ close(fd);
+ if (lock == 0)
+ {
+ path = g_strdup_printf("%s/%s", config, file);
+ g_unlink(path);
+ g_free(path);
+ }
+ }
+ else
+#endif
+ {
+ //g_free(path);
+ path = g_strdup_printf("%s/%s", config, file);
+ g_unlink(path);
+ g_free(path);
+ }
+ }
+ file = g_dir_read_name(gdir);
+ }
+ g_dir_close(gdir);
+ }
+ g_free(config);
+#endif
}
static void
@@ -722,11 +776,6 @@ main (int argc, char *argv[])
textdomain (GETTEXT_PACKAGE);
#endif
-#ifdef PTW32_STATIC_LIB
- pthread_win32_process_attach_np();
- pthread_win32_thread_attach_np();
-#endif
-
if (!g_thread_supported())
g_thread_init(NULL);
context = g_option_context_new ("- Rip and encode DVD or MPEG file");
@@ -921,9 +970,6 @@ main (int argc, char *argv[])
notify_uninit();
#endif
g_free(ud);
-#ifdef PTW32_STATIC_LIB
- pthread_win32_thread_detach_np();
- pthread_win32_process_detach_np();
-#endif
+
return 0;
}
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 7d7e84430..66f69a748 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -1211,7 +1211,6 @@ ghb_find_pid_file()
if (strncmp(file, "ghb.pid.", 8) == 0)
{
gchar *path;
- int fd, lock = 1;
pid_t my_pid;
int pid;
@@ -1222,9 +1221,12 @@ ghb_find_pid_file()
file = g_dir_read_name(gdir);
continue;
}
-
path = g_strdup_printf("%s/%s", config, file);
- fd = g_open(path, O_RDWR);
+
+#if !defined(_WIN32)
+ int fd, lock = 1;
+
+ fd = open(path, O_RDWR);
if (fd >= 0)
{
lock = lockf(fd, F_TLOCK, 0);
@@ -1240,6 +1242,13 @@ ghb_find_pid_file()
}
g_free(path);
close(fd);
+#else
+ g_dir_close(gdir);
+ g_unlink(path);
+ g_free(path);
+ g_free(config);
+ return pid;
+#endif
}
file = g_dir_read_name(gdir);
}