summaryrefslogtreecommitdiff
path: root/thunar-volman
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2010-07-19 19:33:22 +0200
committerJannis Pohlmann <jannis@xfce.org>2010-07-25 19:42:29 +0200
commit81c12834783b92f0784dca25a82277ee5afb20bc (patch)
tree84497804ff850cfca9b390d671bf4f847b8bfa87 /thunar-volman
parent4fee95888fe46deab053be73b121323467168ede (diff)
downloadthunar-volman-81c12834783b92f0784dca25a82277ee5afb20bc.tar.gz
Make tvm_file_test() case insensitive so that video_ts equals VIDEO_TS.
This fixes a few problems with video CD/DVD autoplay.
Diffstat (limited to 'thunar-volman')
-rw-r--r--thunar-volman/tvm-block-device.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c
index 118e383..5d919a0 100644
--- a/thunar-volman/tvm-block-device.c
+++ b/thunar-volman/tvm-block-device.c
@@ -73,23 +73,46 @@ tvm_file_test (GMount *mount,
const gchar *filename,
GFileTest test)
{
- gboolean result = FALSE;
- GFile *mount_point;
- gchar *mount_path;
- gchar *absolute_path;
+ const gchar *name;
+ gboolean result = FALSE;
+ GFile *mount_point;
+ gchar *directory;
+ gchar *path;
+ GDir *dp;
g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
g_return_val_if_fail (filename != NULL && *filename != '\0', FALSE);
mount_point = g_mount_get_root (mount);
- mount_path = g_file_get_path (mount_point);
+ directory = g_file_get_path (mount_point);
g_object_unref (mount_point);
- absolute_path = g_build_filename (mount_path, filename, NULL);
- g_free (mount_path);
+ /* 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);
+ }
- result = g_file_test (absolute_path, test);
- g_free (absolute_path);
+ g_free (directory);
return result;
}