Revision: 1243
http://geeqie.svn.sourceforge.net/geeqie/?rev=1243&view=rev
Author: zas_
Date: 2008-11-15 20:01:25 +0000 (Sat, 15 Nov 2008)
Log Message:
-----------
Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
Modified Paths:
--------------
trunk/src/bar_info.c
trunk/src/cache-loader.c
trunk/src/cache.c
trunk/src/cache.h
trunk/src/cache_maint.c
trunk/src/dupe.c
trunk/src/main.c
trunk/src/pan-view.c
trunk/src/search.c
trunk/src/thumb.c
trunk/src/thumb_standard.c
trunk/src/ui_fileops.c
trunk/src/ui_fileops.h
Modified: trunk/src/bar_info.c
===================================================================
--- trunk/src/bar_info.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/bar_info.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -98,7 +98,7 @@
mode_t mode = 0755;
comment_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path,
FALSE, &mode);
- if (cache_ensure_dir_exists(comment_dir, mode))
+ if (recursive_mkdir_if_not_exists(comment_dir, mode))
{
gchar *filename = g_strconcat(fd->name,
GQ_CACHE_EXT_METADATA, NULL);
Modified: trunk/src/cache-loader.c
===================================================================
--- trunk/src/cache-loader.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/cache-loader.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -168,7 +168,7 @@
mode_t mode = 0755;
base = cache_get_location(CACHE_TYPE_SIM, cl->fd->path,
FALSE, &mode);
- if (cache_ensure_dir_exists(base, mode))
+ if (recursive_mkdir_if_not_exists(base, mode))
{
g_free(cl->cd->path);
cl->cd->path =
cache_get_location(CACHE_TYPE_SIM, cl->fd->path, TRUE, NULL);
Modified: trunk/src/cache.c
===================================================================
--- trunk/src/cache.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/cache.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -582,41 +582,7 @@
*-------------------------------------------------------------------
*/
-/* warning: this func modifies path string contents!, on fail it is set to
fail point */
-gint cache_ensure_dir_exists(gchar *path, mode_t mode)
-{
- if (!path) return FALSE;
- if (!isdir(path))
- {
- gchar *p = path;
- while (p[0] != '\0')
- {
- p++;
- if (p[0] == G_DIR_SEPARATOR || p[0] == '\0')
- {
- gint end = TRUE;
- if (p[0] != '\0')
- {
- p[0] = '\0';
- end = FALSE;
- }
- if (!isdir(path))
- {
- DEBUG_1("creating sub dir:%s", path);
- if (!mkdir_utf8(path, mode))
- {
- log_printf("create dir failed:
%s\n", path);
- return FALSE;
- }
- }
- if (!end) p[0] = G_DIR_SEPARATOR;
- }
- }
- }
- return TRUE;
-}
-
static void cache_path_parts(CacheType type,
const gchar **cache_rc, const gchar **cache_local,
const gchar **cache_ext)
{
Modified: trunk/src/cache.h
===================================================================
--- trunk/src/cache.h 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/cache.h 2008-11-15 20:01:25 UTC (rev 1243)
@@ -69,8 +69,6 @@
void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd);
gint cache_sim_data_filled(ImageSimilarityData *sd);
-
-gint cache_ensure_dir_exists(gchar *path, mode_t mode);
gchar *cache_get_location(CacheType type, const gchar *source, gint
include_name, mode_t *mode);
gchar *cache_find_location(CacheType type, const gchar *source);
Modified: trunk/src/cache_maint.c
===================================================================
--- trunk/src/cache_maint.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/cache_maint.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -524,7 +524,7 @@
if (!src || !dest) return;
base = cache_get_location(CACHE_TYPE_THUMB, dest, FALSE, &mode);
- if (cache_ensure_dir_exists(base, mode))
+ if (recursive_mkdir_if_not_exists(base, mode))
{
gchar *buf;
gchar *d;
@@ -548,7 +548,7 @@
g_free(base);
base = cache_get_location(CACHE_TYPE_METADATA, dest, FALSE, &mode);
- if (cache_ensure_dir_exists(base, mode))
+ if (recursive_mkdir_if_not_exists(base, mode))
{
gchar *buf;
gchar *d;
@@ -603,7 +603,7 @@
if (!src_cache) return;
dest_base = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest,
FALSE, &mode);
- if (cache_ensure_dir_exists(dest_base, mode))
+ if (recursive_mkdir_if_not_exists(dest_base, mode))
{
gchar *path;
Modified: trunk/src/dupe.c
===================================================================
--- trunk/src/dupe.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/dupe.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -435,7 +435,7 @@
if (!di) return;
base = cache_get_location(CACHE_TYPE_SIM, di->fd->path, FALSE, &mode);
- if (cache_ensure_dir_exists(base, mode))
+ if (recursive_mkdir_if_not_exists(base, mode))
{
CacheData *cd;
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/main.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -450,7 +450,7 @@
log_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, path);
- if (!mkdir_utf8(path, 0755))
+ if (!recursive_mkdir_if_not_exists(path, 0755))
{
log_printf(_("Could not create dir:%s\n"), path);
}
Modified: trunk/src/pan-view.c
===================================================================
--- trunk/src/pan-view.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/pan-view.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -638,7 +638,7 @@
mode_t mode = 0755;
base = cache_get_location(CACHE_TYPE_SIM, fd->path,
FALSE, &mode);
- if (cache_ensure_dir_exists(base, mode))
+ if (recursive_mkdir_if_not_exists(base, mode))
{
g_free(cd->path);
cd->path = cache_get_location(CACHE_TYPE_SIM,
fd->path, TRUE, NULL);
Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/search.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -1540,7 +1540,7 @@
path = image_loader_get_fd(sd->img_loader)->path;
base = cache_get_location(CACHE_TYPE_SIM, path, FALSE,
&mode);
- if (cache_ensure_dir_exists(base, mode))
+ if (recursive_mkdir_if_not_exists(base, mode))
{
g_free(cd->path);
cd->path = cache_get_location(CACHE_TYPE_SIM,
path, TRUE, NULL);
Modified: trunk/src/thumb.c
===================================================================
--- trunk/src/thumb.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/thumb.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -50,7 +50,7 @@
cache_dir = cache_get_location(CACHE_TYPE_THUMB, tl->fd->path, FALSE,
&mode);
- if (cache_ensure_dir_exists(cache_dir, mode))
+ if (recursive_mkdir_if_not_exists(cache_dir, mode))
{
gchar *cache_path;
gchar *pathl;
Modified: trunk/src/thumb_standard.c
===================================================================
--- trunk/src/thumb_standard.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/thumb_standard.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -14,7 +14,6 @@
#include "main.h"
#include "thumb_standard.h"
-#include "cache.h" /* for cache_ensure_dir_exists */
#include "image-load.h"
#include "md5-util.h"
#include "pixbuf_util.h"
@@ -319,14 +318,14 @@
source_base = remove_level_from_path(tl->fd->path);
if (stat_utf8(source_base, &st))
{
- cache_ensure_dir_exists(base_path, st.st_mode);
+ recursive_mkdir_if_not_exists(base_path,
st.st_mode);
}
g_free(source_base);
}
}
else
{
- cache_ensure_dir_exists(base_path, THUMB_PERMS_FOLDER);
+ recursive_mkdir_if_not_exists(base_path, THUMB_PERMS_FOLDER);
}
g_free(base_path);
Modified: trunk/src/ui_fileops.c
===================================================================
--- trunk/src/ui_fileops.c 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/ui_fileops.c 2008-11-15 20:01:25 UTC (rev 1243)
@@ -762,4 +762,49 @@
return ret;
}
+
+gboolean recursive_mkdir_if_not_exists(gchar *path, mode_t mode)
+{
+ if (!path) return FALSE;
+
+ if (!isdir(path))
+ {
+ gchar *npath = g_strdup(path);
+ gchar *p = npath;
+
+ while (p[0] != '\0')
+ {
+ p++;
+ if (p[0] == G_DIR_SEPARATOR || p[0] == '\0')
+ {
+ gint end = TRUE;
+
+ if (p[0] != '\0')
+ {
+ p[0] = '\0';
+ end = FALSE;
+ }
+
+ if (!isdir(npath))
+ {
+ DEBUG_1("creating sub dir:%s", npath);
+ if (!mkdir_utf8(npath, mode))
+ {
+ log_printf("create dir failed:
%s\n", npath);
+ g_free(npath);
+ return FALSE;
+ }
+ }
+
+ if (!end) p[0] = G_DIR_SEPARATOR;
+ }
+ }
+ g_free(npath);
+ }
+
+ return TRUE;
+}
+
+
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
Modified: trunk/src/ui_fileops.h
===================================================================
--- trunk/src/ui_fileops.h 2008-11-15 19:13:43 UTC (rev 1242)
+++ trunk/src/ui_fileops.h 2008-11-15 20:01:25 UTC (rev 1243)
@@ -81,5 +81,7 @@
gint file_in_path(const gchar *name);
+gboolean recursive_mkdir_if_not_exists(gchar *path, mode_t mode);
+
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn