Commit 22d260e316fa422f3ef14e1c146cb04da38f6f60
- Diff rendering mode:
- inline
- side by side
champlain/champlain-file-cache.c
(28 / 9)
|   | |||
| 70 | 70 | static gboolean tile_is_expired (ChamplainFileCache *file_cache, ChamplainTile *tile); | |
| 71 | 71 | static void delete_tile (ChamplainFileCache *file_cache, const gchar *filename); | |
| 72 | 72 | static void delete_dir_recursive (GFile *parent); | |
| 73 | static gboolean create_cache_dir (const gchar *dir_name); | ||
| 73 | 74 | ||
| 74 | 75 | static void fill_tile (ChamplainMapSource *map_source, | |
| 75 | 76 | ChamplainTile *tile); | |
| … | … | ||
| 199 | 199 | G_OBJECT_CLASS (champlain_file_cache_parent_class)->finalize (object); | |
| 200 | 200 | } | |
| 201 | 201 | ||
| 202 | static gboolean | ||
| 203 | create_cache_dir (const gchar *dir_name) | ||
| 204 | { | ||
| 205 | /* If needed, create the cache's dirs */ | ||
| 206 | if (dir_name) | ||
| 207 | { | ||
| 208 | if (g_mkdir_with_parents (dir_name, 0700) == -1 && errno != EEXIST) | ||
| 209 | { | ||
| 210 | g_warning ("Unable to create the image cache path '%s': %s", | ||
| 211 | dir_name, g_strerror (errno)); | ||
| 212 | return FALSE; | ||
| 213 | } | ||
| 214 | } | ||
| 215 | return TRUE; | ||
| 216 | } | ||
| 217 | |||
| 202 | 218 | static void | |
| 203 | 219 | init_cache (ChamplainFileCache *file_cache) | |
| 204 | 220 | { | |
| … | … | ||
| 225 | 225 | gint error; | |
| 226 | 226 | ||
| 227 | 227 | g_print ("init! '%d'\n", champlain_tile_cache_get_persistent (tile_cache)); | |
| 228 | /* If needed, create the cache's dirs */ | ||
| 229 | if (priv->cache_dir) | ||
| 228 | |||
| 229 | g_return_if_fail (create_cache_dir (priv->cache_dir)); | ||
| 230 | |||
| 231 | if (champlain_tile_cache_get_persistent (tile_cache)) | ||
| 230 | 232 | { | |
| 231 | if (g_mkdir_with_parents (priv->cache_dir, 0700) == -1 && errno != EEXIST) | ||
| 233 | if (priv->cache_dir) | ||
| 234 | priv->real_cache_dir = g_strdup (priv->cache_dir); | ||
| 235 | else | ||
| 232 | 236 | { | |
| 233 | g_warning ("Unable to create the image cache path '%s': %s", | ||
| 234 | priv->cache_dir, g_strerror (errno)); | ||
| 235 | return; | ||
| 237 | priv->real_cache_dir = g_build_path (G_DIR_SEPARATOR_S, | ||
| 238 | g_get_user_cache_dir (), | ||
| 239 | "champlain", NULL); | ||
| 240 | g_return_if_fail (create_cache_dir (priv->real_cache_dir)); | ||
| 236 | 241 | } | |
| 237 | 242 | } | |
| 238 | |||
| 239 | if (champlain_tile_cache_get_persistent (tile_cache)) | ||
| 240 | priv->real_cache_dir = g_strdup (priv->cache_dir); | ||
| 241 | 243 | else | |
| 242 | 244 | { | |
| 243 | 245 | /* Create temporary directory for non-persistent caches */ |
Comments
Add your comment
Please log in to comment



Add a new comment:
Login or create an account to post a comment