summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libtracker-common/tracker-file-utils.c76
-rw-r--r--src/libtracker-common/tracker-file-utils.h53
-rw-r--r--src/libtracker-common/tracker-utils.c75
-rw-r--r--src/libtracker-common/tracker-utils.h3
-rw-r--r--src/tracker-extract/tracker-cue-sheet.c5
-rw-r--r--tests/libtracker-common/tracker-utils-test.c8
6 files changed, 110 insertions, 110 deletions
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index e2891ab43..64dc27284 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -835,3 +835,79 @@ tracker_file_cmp (GFile *file_a,
* Useful to be used in g_list_find_custom() or g_queue_find_custom() */
return !g_file_equal (file_a, file_b);
}
+
+/**
+ * tracker_filename_casecmp_without_extension:
+ * @a: a string containing a file name
+ * @b: filename to be compared with @a
+ *
+ * This function performs a case-insensitive comparison of @a and @b.
+ * Additionally, text beyond the last '.' in a string is not considered
+ * part of the match, so for example given the inputs "file.mp3" and
+ * "file.wav" this function will return %TRUE.
+ *
+ * Internally, the g_ascii_tolower() function is used - this means that
+ * @a and @b must be in an encoding in which ASCII characters always
+ * represent themselves, such as UTF-8 or the ISO-8859-* charsets.
+ *
+ * Returns: %TRUE if the two file names match.
+ **/
+gboolean
+tracker_filename_casecmp_without_extension (const gchar *a,
+ const gchar *b)
+{
+ const gchar *ca = a;
+ const gchar *cb = b;
+ gboolean period_a = FALSE;
+ gboolean period_b = FALSE;
+ gboolean match = TRUE;
+
+ g_return_val_if_fail (a != NULL, FALSE);
+ g_return_val_if_fail (b != NULL, FALSE);
+
+ while (1) {
+ if (*ca == '\0' && *cb == '\0')
+ break;
+
+ if (*ca != '\0' && *cb != '\0') {
+ if (g_ascii_tolower (*ca) != g_ascii_tolower (*cb)) {
+ match = FALSE;
+ break;
+ }
+ }
+
+ if (*ca == '.')
+ period_a = TRUE;
+
+ if (*cb == '.')
+ period_b = TRUE;
+
+ if (*ca == '\0' || *cb == '\0') {
+ match = FALSE;
+ break;
+ }
+
+ ca ++; cb ++;
+ }
+
+ if (!match) {
+ /* If the mismatch was past the last '.' then forgive it. */
+ if (*ca != '\0' && period_a) {
+ match = TRUE;
+
+ while (*(ca ++) != '\0')
+ if (*ca == '.')
+ match = FALSE;
+ }
+
+ if (*cb != '\0' && period_b) {
+ match = TRUE;
+
+ while (*(cb ++) != '\0')
+ if (*cb == '.')
+ match = FALSE;
+ }
+ }
+
+ return match;
+}
diff --git a/src/libtracker-common/tracker-file-utils.h b/src/libtracker-common/tracker-file-utils.h
index d3a8bc8b0..fee22d004 100644
--- a/src/libtracker-common/tracker-file-utils.h
+++ b/src/libtracker-common/tracker-file-utils.h
@@ -32,36 +32,37 @@ G_BEGIN_DECLS
#endif
/* File utils */
-FILE* tracker_file_open (const gchar *path);
-void tracker_file_close (FILE *file,
- gboolean need_again_soon);
-goffset tracker_file_get_size (const gchar *path);
-guint64 tracker_file_get_mtime (const gchar *path);
-guint64 tracker_file_get_mtime_uri (const gchar *uri);
-
-gchar * tracker_file_get_mime_type (GFile *file);
-gboolean tracker_file_lock (GFile *file);
-gboolean tracker_file_unlock (GFile *file);
-gboolean tracker_file_is_locked (GFile *file);
-gboolean tracker_file_is_hidden (GFile *file);
-gint tracker_file_cmp (GFile *file_a,
- GFile *file_b);
+FILE* tracker_file_open (const gchar *path);
+void tracker_file_close (FILE *file,
+ gboolean need_again_soon);
+goffset tracker_file_get_size (const gchar *path);
+guint64 tracker_file_get_mtime (const gchar *path);
+guint64 tracker_file_get_mtime_uri (const gchar *uri);
+gchar * tracker_file_get_mime_type (GFile *file);
+gboolean tracker_file_lock (GFile *file);
+gboolean tracker_file_unlock (GFile *file);
+gboolean tracker_file_is_locked (GFile *file);
+gboolean tracker_file_is_hidden (GFile *file);
+gint tracker_file_cmp (GFile *file_a,
+ GFile *file_b);
/* Path utils */
-gboolean tracker_path_is_in_path (const gchar *path,
- const gchar *in_path);
-GSList * tracker_path_list_filter_duplicates (GSList *roots,
- const gchar *basename_exception_prefix,
- gboolean is_recursive);
-gchar * tracker_path_evaluate_name (const gchar *uri);
-gboolean tracker_path_has_write_access_or_was_created (const gchar *path);
+gboolean tracker_path_is_in_path (const gchar *path,
+ const gchar *in_path);
+GSList * tracker_path_list_filter_duplicates (GSList *roots,
+ const gchar *basename_exception_prefix,
+ gboolean is_recursive);
+gchar * tracker_path_evaluate_name (const gchar *uri);
+gboolean tracker_path_has_write_access_or_was_created (const gchar *path);
+gboolean tracker_filename_casecmp_without_extension (const gchar *a,
+ const gchar *b);
/* File system utils */
-gboolean tracker_file_system_has_enough_space (const gchar *path,
- gulong required_bytes,
- gboolean creating_db);
-guint64 tracker_file_system_get_remaining_space (const gchar *path);
-gdouble tracker_file_system_get_remaining_space_percentage (const gchar *path);
+gboolean tracker_file_system_has_enough_space (const gchar *path,
+ gulong required_bytes,
+ gboolean creating_db);
+guint64 tracker_file_system_get_remaining_space (const gchar *path);
+gdouble tracker_file_system_get_remaining_space_percentage (const gchar *path);
G_END_DECLS
diff --git a/src/libtracker-common/tracker-utils.c b/src/libtracker-common/tracker-utils.c
index b58d5a151..fe1b5cbba 100644
--- a/src/libtracker-common/tracker-utils.c
+++ b/src/libtracker-common/tracker-utils.c
@@ -210,78 +210,3 @@ tracker_strhex (const guint8 *data,
return new_str;
}
-/**
- * tracker_case_match_filename_without_extension:
- * @a: a string containing a file name
- * @b: filename to be compared with @a
- *
- * This function performs a case-insensitive comparison of @a and @b.
- * Additionally, text beyond the last '.' in a string is not considered
- * part of the match, so for example given the inputs "file.mp3" and
- * "file.wav" this function will return %TRUE.
- *
- * Internally, the g_ascii_tolower() function is used - this means that
- * @a and @b must be in an encoding in which ASCII characters always
- * represent themselves, such as UTF-8 or the ISO-8859-* charsets.
- *
- * Returns: %TRUE if the two file names match.
- **/
-gboolean
-tracker_case_match_filename_without_extension (const gchar *a,
- const gchar *b)
-{
- const gchar *ca = a;
- const gchar *cb = b;
- gboolean period_a = FALSE;
- gboolean period_b = FALSE;
- gboolean match = TRUE;
-
- g_return_val_if_fail (a != NULL, FALSE);
- g_return_val_if_fail (b != NULL, FALSE);
-
- while (1) {
- if (*ca == '\0' && *cb == '\0')
- break;
-
- if (*ca != '\0' && *cb != '\0') {
- if (g_ascii_tolower (*ca) != g_ascii_tolower (*cb)) {
- match = FALSE;
- break;
- }
- }
-
- if (*ca == '.')
- period_a = TRUE;
-
- if (*cb == '.')
- period_b = TRUE;
-
- if (*ca == '\0' || *cb == '\0') {
- match = FALSE;
- break;
- }
-
- ca ++; cb ++;
- }
-
- if (!match) {
- /* If the mismatch was past the last '.' then forgive it. */
- if (*ca != '\0' && period_a) {
- match = TRUE;
-
- while (*(ca ++) != '\0')
- if (*ca == '.')
- match = FALSE;
- }
-
- if (*cb != '\0' && period_b) {
- match = TRUE;
-
- while (*(cb ++) != '\0')
- if (*cb == '.')
- match = FALSE;
- }
- }
-
- return match;
-}
diff --git a/src/libtracker-common/tracker-utils.h b/src/libtracker-common/tracker-utils.h
index a89161136..035be9694 100644
--- a/src/libtracker-common/tracker-utils.h
+++ b/src/libtracker-common/tracker-utils.h
@@ -44,9 +44,6 @@ gchar * tracker_strhex (const guint8 *data,
gsize size,
gchar delimiter);
-gboolean tracker_case_match_filename_without_extension (const gchar *a,
- const gchar *b);
-
G_END_DECLS
#endif /* __LIBTRACKER_COMMON_UTILS_H__ */
diff --git a/src/tracker-extract/tracker-cue-sheet.c b/src/tracker-extract/tracker-cue-sheet.c
index 7411bea3d..7f05ccc23 100644
--- a/src/tracker-extract/tracker-cue-sheet.c
+++ b/src/tracker-extract/tracker-cue-sheet.c
@@ -241,9 +241,10 @@ parse_cue_sheet_for_file (const gchar *cue_sheet,
* extension in the FILE field, so this is what we test for.
*/
if (file_name != NULL) {
- if (!tracker_case_match_filename_without_extension
- (file_name, track_get_filename (track)))
+ if (!tracker_filename_casecmp_without_extension (file_name,
+ track_get_filename (track))) {
continue;
+ }
}
if (track_get_mode (track) != MODE_AUDIO)
diff --git a/tests/libtracker-common/tracker-utils-test.c b/tests/libtracker-common/tracker-utils-test.c
index 07364ca78..91359592a 100644
--- a/tests/libtracker-common/tracker-utils-test.c
+++ b/tests/libtracker-common/tracker-utils-test.c
@@ -75,12 +75,12 @@ test_seconds_estimate_to_string ()
}
#define assert_filename_match(a, b) { \
- g_assert (tracker_case_match_filename_without_extension (a, b) == TRUE); \
- g_assert (tracker_case_match_filename_without_extension (b, a) == TRUE); }
+ g_assert (tracker_filename_casecmp_without_extension (a, b) == TRUE); \
+ g_assert (tracker_filename_casecmp_without_extension (b, a) == TRUE); }
#define assert_no_filename_match(a, b) { \
- g_assert (tracker_case_match_filename_without_extension (a, b) == FALSE); \
- g_assert (tracker_case_match_filename_without_extension (b, a) == FALSE); }
+ g_assert (tracker_filename_casecmp_without_extension (a, b) == FALSE); \
+ g_assert (tracker_filename_casecmp_without_extension (b, a) == FALSE); }
static void
test_case_match_filename_without_extension ()