summaryrefslogtreecommitdiff
path: root/thunar-volman
diff options
context:
space:
mode:
authorBenedikt Meurer <benny@xfce.org>2007-10-09 19:10:19 +0000
committerBenedikt Meurer <benny@xfce.org>2007-10-09 19:10:19 +0000
commit96e087fd0d320db98a6cc0126ace7e85ca45d920 (patch)
tree85d6a9564fb685831d4b62ceb26b8f8041836e48 /thunar-volman
parent8a33ffef6886c6779b562760d5bc9ada205e64ef (diff)
downloadthunar-volman-96e087fd0d320db98a6cc0126ace7e85ca45d920.tar.gz
2007-10-09 Benedikt Meurer <benny@xfce.org>
* thunar-volman/tvm-block-device.c: Properly ignore case looking for VCD, VIDEO_TS and DCIM folders. Bug #3038. (Old svn revision: 3318)
Diffstat (limited to 'thunar-volman')
-rw-r--r--thunar-volman/tvm-block-device.c74
1 files changed, 49 insertions, 25 deletions
diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c
index 08d7927..4ece845 100644
--- a/thunar-volman/tvm-block-device.c
+++ b/thunar-volman/tvm-block-device.c
@@ -47,6 +47,9 @@
+static gboolean tvm_file_test (const gchar *directory,
+ const gchar *filename,
+ GFileTest test);
static gboolean tvm_block_device_autoipod (TvmPreferences *preferences,
LibHalContext *context,
const gchar *udi,
@@ -79,6 +82,46 @@ static gboolean tvm_block_device_mounted (TvmPreferences *preferences,
static gboolean
+tvm_file_test (const gchar *directory,
+ const gchar *filename,
+ GFileTest test)
+{
+ const gchar *name;
+ gboolean result = FALSE;
+ gchar *path;
+ GDir *dp;
+
+ /* try to open the specified directory */
+ dp = g_dir_open (directory, 0, NULL);
+ if (G_LIKELY (dp != NULL))
+ {
+ while (!result)
+ {
+ /* read the next entry */
+ name = g_dir_read_name (dp);
+ if (G_UNLIKELY (name == NULL))
+ break;
+
+ /* check if we have a potential match */
+ if (g_ascii_strcasecmp (name, filename) == 0)
+ {
+ /* check if test condition met */
+ path = g_build_filename (directory, name, NULL);
+ result = g_file_test (path, test);
+ g_free (path);
+ }
+ }
+
+ /* cleanup */
+ g_dir_close (dp);
+ }
+
+ return result;
+}
+
+
+
+static gboolean
tvm_block_device_autoipod (TvmPreferences *preferences,
LibHalContext *context,
const gchar *udi,
@@ -192,7 +235,6 @@ tvm_block_device_autophoto (TvmPreferences *preferences,
gboolean result = FALSE;
gboolean autophoto;
gchar *autophoto_command;
- gchar *path_dcim;
gint response;
/* check autophoto support is enabled */
@@ -200,8 +242,7 @@ tvm_block_device_autophoto (TvmPreferences *preferences,
if (G_LIKELY (autophoto && autophoto_command != NULL && *autophoto_command != '\0'))
{
/* check if we have photos on the volume */
- path_dcim = g_build_filename (mount_point, "dcim", NULL);
- if (g_file_test (path_dcim, G_FILE_TEST_IS_DIR))
+ if (tvm_file_test (mount_point, "dcim", G_FILE_TEST_IS_DIR))
{
/* add the "content.photos" capability to this device */
libhal_device_add_capability (context, udi, "content.photos", NULL);
@@ -224,7 +265,6 @@ tvm_block_device_autophoto (TvmPreferences *preferences,
result = TRUE;
}
}
- g_free (path_dcim);
}
g_free (autophoto_command);
@@ -248,11 +288,8 @@ tvm_block_device_autorun (TvmPreferences *preferences,
gboolean autoplay;
gboolean autorun;
gchar *autoplay_command;
- gchar *path_video_ts;
gchar *path_autoopen;
- gchar *path_autorun;
gchar line[1024];
- gchar *path_vcd;
gchar *message;
gchar *wine;
gchar **argv;
@@ -265,21 +302,13 @@ tvm_block_device_autorun (TvmPreferences *preferences,
if (G_LIKELY (autoplay))
{
/* check if we have a video CD or video DVD here */
- path_vcd = g_build_filename (mount_point, "vcd", NULL);
- path_video_ts = g_build_filename (mount_point, "video_ts", NULL);
- if (g_file_test (path_vcd, G_FILE_TEST_IS_DIR) || g_file_test (path_video_ts, G_FILE_TEST_IS_DIR))
+ if (tvm_file_test (mount_point, "vcd", G_FILE_TEST_IS_DIR) || tvm_file_test (mount_point, "video_ts", G_FILE_TEST_IS_DIR))
{
/* try to spawn the preferred video CD/DVD-Player */
result = tvm_run_command (context, udi, autoplay_command, device_file, mount_point, error);
g_free (autoplay_command);
- g_free (path_video_ts);
- g_free (path_vcd);
return result;
}
-
- /* cleanup */
- g_free (path_video_ts);
- g_free (path_vcd);
}
g_free (autoplay_command);
@@ -292,9 +321,8 @@ tvm_block_device_autorun (TvmPreferences *preferences,
for (n = 0; n < G_N_ELEMENTS (AUTORUN); ++n)
{
/* check if one of the autorun files is present and executable */
- path_autorun = g_build_filename (mount_point, AUTORUN[n], NULL);
- if (g_file_test (path_autorun, G_FILE_TEST_IS_EXECUTABLE)
- && g_file_test (path_autorun, G_FILE_TEST_IS_REGULAR))
+ if (tvm_file_test (mount_point, AUTORUN[n], G_FILE_TEST_IS_EXECUTABLE)
+ && tvm_file_test (mount_point, AUTORUN[n], G_FILE_TEST_IS_REGULAR))
{
/* prompt the user whether to execute this file */
message = g_strdup_printf (_("Would you like to allow \"%s\" to run?"), AUTORUN[n]);
@@ -310,7 +338,7 @@ tvm_block_device_autorun (TvmPreferences *preferences,
{
/* prepare argv to launch autorun file */
argv = g_new (gchar *, 2);
- argv[0] = path_autorun;
+ argv[0] = g_build_filename (mount_point, AUTORUN[n], NULL);
argv[1] = NULL;
/* try to launch the autorun file */
@@ -323,7 +351,6 @@ tvm_block_device_autorun (TvmPreferences *preferences,
return result;
}
}
- g_free (path_autorun);
}
/* check if wine is present */
@@ -331,8 +358,7 @@ tvm_block_device_autorun (TvmPreferences *preferences,
if (G_UNLIKELY (wine != NULL))
{
/* check if we have an autorun.exe file */
- path_autorun = g_build_filename (mount_point, "autorun.exe", NULL);
- if (g_file_test (path_autorun, G_FILE_TEST_IS_REGULAR))
+ if (tvm_file_test (mount_point, "autorun.exe", G_FILE_TEST_IS_REGULAR))
{
/* prompt the user whether to execute this file */
message = g_strdup_printf (_("Would you like to allow \"%s\" to run?"), "autorun.exe");
@@ -356,14 +382,12 @@ tvm_block_device_autorun (TvmPreferences *preferences,
result = g_spawn_async (mount_point, argv, NULL, 0, NULL, NULL, NULL, error);
/* cleanup */
- g_free (path_autorun);
g_strfreev (argv);
/* outa here */
return result;
}
}
- g_free (path_autorun);
}
g_free (wine);
}