eog r4852 - in trunk: . src
- From: csaavedra svn gnome org
- To: svn-commits-list gnome org
- Subject: eog r4852 - in trunk: . src
- Date: Sun, 26 Oct 2008 17:25:23 +0000 (UTC)
Author: csaavedra
Date: Sun Oct 26 17:25:23 2008
New Revision: 4852
URL: http://svn.gnome.org/viewvc/eog?rev=4852&view=rev
Log:
2008-10-07 Claudio Saavedra <csaavedra igalia com>
* src/eog-util.c: (+eog_util_filename_get_extension):
* src/eog-util.h: Add method to obtain extension from a filename.
Modified:
trunk/ChangeLog
trunk/src/eog-util.c
trunk/src/eog-util.h
Modified: trunk/src/eog-util.c
==============================================================================
--- trunk/src/eog-util.c (original)
+++ trunk/src/eog-util.c Sun Oct 26 17:25:23 2008
@@ -279,3 +279,46 @@
return dot_dir;
}
+
+/* Based on eel_filename_strip_extension() */
+
+/**
+ * eog_util_filename_get_extension:
+ * @filename: a filename
+ *
+ * Returns a reasonably good guess of the file extension of @filename.
+ *
+ * Returns: a newly allocated string with the file extension of @filename.
+ **/
+char *
+eog_util_filename_get_extension (const char * filename)
+{
+ char *begin, *begin2;
+
+ if (filename == NULL) {
+ return NULL;
+ }
+
+ begin = strrchr (filename, '.');
+
+ if (begin && begin != filename) {
+ if (strcmp (begin, ".gz") == 0 ||
+ strcmp (begin, ".bz2") == 0 ||
+ strcmp (begin, ".sit") == 0 ||
+ strcmp (begin, ".Z") == 0) {
+ begin2 = begin - 1;
+ while (begin2 > filename &&
+ *begin2 != '.') {
+ begin2--;
+ }
+ if (begin2 != filename) {
+ begin = begin2;
+ }
+ }
+ begin ++;
+ } else {
+ return NULL;
+ }
+
+ return g_strdup (begin);
+}
Modified: trunk/src/eog-util.h
==============================================================================
--- trunk/src/eog-util.h (original)
+++ trunk/src/eog-util.h Sun Oct 26 17:25:23 2008
@@ -52,6 +52,8 @@
const gchar *eog_util_dot_dir (void);
+char * eog_util_filename_get_extension (const char * filename_with_extension);
+
G_END_DECLS
#endif /* __EOG_UTIL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]