From b19b4ec8e7ea6fbccc30d4e18ef5a5c16e44e251 Mon Sep 17 00:00:00 2001 From: navarro Date: Tue, 31 Jul 2012 17:37:23 +0200 Subject: [PATCH] During the storage open, create the file if not exist. --- src/surf/storage.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/surf/storage.c b/src/surf/storage.c index 7aed75ee22..ace5d0af45 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -51,8 +51,20 @@ static surf_action_t storage_action_open(void *storage, const char* mount, const { XBT_DEBUG("\tOpen file '%s'",path); xbt_dict_t content_dict = ((storage_t)storage)->content; - surf_stat_t content = xbt_dict_get(content_dict,path); + surf_stat_t content = xbt_dict_get_or_null(content_dict,path); + // if file does not exist create an empty file + if(!content){ + content = xbt_new0(s_surf_stat_t,1); + content->stat.date = xbt_strdup(""); + content->stat.group = xbt_strdup(""); + content->stat.size = 0; + content->stat.time = xbt_strdup(""); + content->stat.user = xbt_strdup(""); + content->stat.user_rights = xbt_strdup(""); + xbt_dict_set(content_dict,path,content,NULL); + XBT_DEBUG("File '%s' was not found, file created.",path); + } surf_file_t file = xbt_new0(s_surf_file_t,1); file->name = xbt_strdup(path); file->content = content; -- 2.20.1