Additional debug features
[geeqie.git] / src / ui_fileops.c
index 3ab6bcb..c4466fc 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * (SLIK) SimpLIstic sKin functions
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -32,6 +41,9 @@
 #include "ui_utildlg.h"        /* for locale warning dialog */
 #include "md5-util.h"
 
+#include "filefilter.h"
+#include "secure_save.h"
+
 /*
  *-----------------------------------------------------------------------------
  * generic file information and manipulation routines (public)
@@ -46,6 +58,8 @@ void print_term(const gchar *text_utf8)
 
        text_l = g_locale_from_utf8(text_utf8, -1, NULL, NULL, NULL);
        fputs((text_l) ? text_l : text_utf8, stderr);
+       if(command_line && command_line->ssi)
+               secure_fputs(command_line->ssi, (text_l) ? text_l : text_utf8);
        g_free(text_l);
 }
 
@@ -688,7 +702,7 @@ gchar *unique_filename_simple(const gchar *path)
        name = filename_from_path(path);
        if (!name) return NULL;
 
-       ext = extension_from_path(name);
+       ext = registered_extension_from_path(name);
 
        if (!ext)
                {
@@ -720,24 +734,14 @@ const gchar *filename_from_path(const gchar *path)
 
 gchar *remove_level_from_path(const gchar *path)
 {
-       gint p = 0, n = -1;
+       const gchar *base;
 
        if (!path) return NULL;
 
-       while (path[p])
-               {
-               if (path[p] == G_DIR_SEPARATOR) n = p;
-               p++;
-               }
-       if (n <= 0) n++;
-
-       return g_strndup(path, (gsize) n);
-}
+       base = strrchr(path, G_DIR_SEPARATOR);
+       if (base) return g_strndup(path, strlen(path)-strlen(base));
 
-const gchar *extension_from_path(const gchar *path)
-{
-       if (!path) return NULL;
-       return strrchr(path, '.');
+       return NULL;
 }
 
 gboolean file_extension_match(const gchar *path, const gchar *ext)
@@ -757,18 +761,13 @@ gboolean file_extension_match(const gchar *path, const gchar *ext)
 
 gchar *remove_extension_from_path(const gchar *path)
 {
-       gint p = 0, n = -1;
+       const gchar *reg_ext;
 
        if (!path) return NULL;
 
-       while (path[p])
-               {
-               if (path[p] == '.') n = p;
-               p++;
-               }
-       if (n < 0) n = p;
+       reg_ext = registered_extension_from_path(path);
 
-       return g_strndup(path, (gsize) n);
+       return g_strndup(path, strlen(path) - (reg_ext == NULL ? 0 : strlen(reg_ext)));
 }
 
 void parse_out_relatives(gchar *path)