summaryrefslogtreecommitdiff
path: root/riscos/filename.c
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2006-01-04 22:59:49 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2006-01-04 22:59:49 +0000
commit5ae56e68507d0ba8f06b8e4eb6606d8ccc645266 (patch)
treec613113b46c897cc17d05efec9c34348ec8abc06 /riscos/filename.c
parenta1c3e05e0a4df489f43d4a8b1708199c08824d06 (diff)
downloadnetsurf-5ae56e68507d0ba8f06b8e4eb6606d8ccc645266.tar.gz
netsurf-5ae56e68507d0ba8f06b8e4eb6606d8ccc645266.tar.bz2
[project @ 2006-01-04 22:59:49 by rjw]
Reduce directory creation overhead slightly. Ensure directories are actually created. svn path=/import/netsurf/; revision=1982
Diffstat (limited to 'riscos/filename.c')
-rw-r--r--riscos/filename.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/riscos/filename.c b/riscos/filename.c
index 41433488a..7fb0031b7 100644
--- a/riscos/filename.c
+++ b/riscos/filename.c
@@ -174,6 +174,7 @@ static struct directory *ro_filename_create_directory(const char *prefix) {
int index;
struct directory *old_dir, *new_dir, *prev_dir = NULL;
char dir_prefix[16];
+ os_error *error;
/* get the lowest unique prefix, or use the provided one */
if (!prefix) {
@@ -219,6 +220,23 @@ static struct directory *ro_filename_create_directory(const char *prefix) {
prev_dir->next = new_dir;
}
+ /* if the previous directory has the same parent then we can simply
+ * create the child. */
+ if ((prev_dir) && (!strncmp(prev_dir->prefix, new_dir->prefix, 6))) {
+ new_dir->prefix[8] = '\0';
+ sprintf(ro_filename_directory, "%s.%s",
+ CACHE_FILENAME_PREFIX, new_dir->prefix);
+ new_dir->prefix[8] = '.';
+ error = xosfile_create_dir(ro_filename_directory, 0);
+ /* the user has probably deleted the parent directory whilst
+ * we are running if there is an error, so we don't report this
+ * yet and try to create the structure normally. */
+ if (!error)
+ return new_dir;
+ LOG(("xosfile_create_dir: 0x%x: %s",
+ error->errnum, error->errmess));
+ }
+
/* create the directory structure */
sprintf(ro_filename_directory, "%s.", CACHE_FILENAME_PREFIX);
last_1 = ro_filename_directory + strlen(CACHE_FILENAME_PREFIX) + 1;
@@ -227,9 +245,14 @@ static struct directory *ro_filename_create_directory(const char *prefix) {
*last_1++ = *last_2++;
while (*last_2 && *last_2 != '.')
*last_1++ = *last_2++;
- if (*last_2) {
+ if (*last_2) {
last_1[0] = '\0';
- xosfile_create_dir(ro_filename_directory, 0);
+ error = xosfile_create_dir(ro_filename_directory, 0);
+ if (error) {
+ LOG(("xosfile_create_dir: 0x%x: %s",
+ error->errnum, error->errmess));
+ return NULL;
+ }
}
}
return new_dir;