[Xfce4-commits] <thunar-volman:jannis/port-to-udev> Make tvm_file_test() case insensitive so that video_ts equals VIDEO_TS.

Jannis Pohlmann noreply at xfce.org
Mon Jul 19 19:34:01 CEST 2010


Updating branch refs/heads/jannis/port-to-udev
         to 9bd67464b81364ee9da5e86f5bc349c67a6f6b2c (commit)
       from fc5d5240526507bb57e7db19830842189def4922 (commit)

commit 9bd67464b81364ee9da5e86f5bc349c67a6f6b2c
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Jul 19 19:33:22 2010 +0200

    Make tvm_file_test() case insensitive so that video_ts equals VIDEO_TS.
    
    This fixes a few problems with video CD/DVD autoplay.

 thunar-volman/tvm-block-device.c |   43 +++++++++++++++++++++++++++++--------
 1 files changed, 33 insertions(+), 10 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;
 }



More information about the Xfce4-commits mailing list