summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-05-30 00:19:20 +0100
committerVincent Sanders <vince@kyllikki.org>2014-05-30 00:19:20 +0100
commite9d53022a46b94c45eba7b0f7f99cd07a885e5a0 (patch)
tree6065a894fae4f7d8e8885f1f1d9fb5ec9e04a4d7
parent95baa1113b1cd3c7d533f3cd0e9efb6819c21e71 (diff)
downloadnetsurf-e9d53022a46b94c45eba7b0f7f99cd07a885e5a0.tar.gz
netsurf-e9d53022a46b94c45eba7b0f7f99cd07a885e5a0.tar.bz2
write a cache tag file as an aid to backup software
-rw-r--r--content/fs_backing_store.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c
index b08a8e7f9..af93d6066 100644
--- a/content/fs_backing_store.c
+++ b/content/fs_backing_store.c
@@ -777,6 +777,42 @@ read_entries(struct store_state *state)
return NSERROR_OK;
}
+/**
+ * Write the cache tag file.
+ *
+ * @param state The cache state.
+ * @return NSERROR_OK on sucess or error code on faliure.
+ */
+static nserror
+write_cache_tag(struct store_state *state)
+{
+ FILE *fcachetag;
+ nserror ret;
+ char *fname = NULL;
+
+ ret = netsurf_mkpath(&fname, NULL, 2, state->path, "CACHEDIR.TAG");
+ if (ret != NSERROR_OK) {
+ return ret;
+ }
+
+ fcachetag = fopen(fname, "wb");
+
+ free(fname);
+
+ if (fcachetag == NULL) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ fprintf(fcachetag,
+ "Signature: 8a477f597d28d172789f06886806bc55\n"
+ "# This file is a cache directory tag created by NetSurf.\n"
+ "# For information about cache directory tags, see:\n"
+ "# http://www.brynosaurus.com/cachedir/\n");
+
+ fclose(fcachetag);
+
+ return NSERROR_OK;
+}
/**
* Write the control file for the current state.
@@ -960,6 +996,9 @@ initialise(const struct llcache_store_parameters *parameters)
if (ret != NSERROR_OK) {
LOG(("read control failed %s", messages_get_errorcode(ret)));
ret = write_control(newstate);
+ if (ret == NSERROR_OK) {
+ write_cache_tag(newstate);
+ }
}
if (ret != NSERROR_OK) {
/* that went well obviously */