From: navarro Date: Tue, 31 Jul 2012 15:37:23 +0000 (+0200) Subject: During the storage open, create the file if not exist. X-Git-Tag: v3_8~246 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b19b4ec8e7ea6fbccc30d4e18ef5a5c16e44e251?ds=sidebyside During the storage open, create the file if not exist. --- 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;