- XBT_DEBUG("\tOpen file '%s'",path);
-
- sg_size_t size, *psize;
- psize = (sg_size_t*) xbt_dict_get_or_null(p_content, path);
- // if file does not exist create an empty file
- if(psize)
- size = *psize;
- else {
- psize = xbt_new(sg_size_t,1);
- size = 0;
- *psize = size;
- xbt_dict_set(p_content, path, psize, 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->size = size;
- file->mount = xbt_strdup(mount);
- file->current_position = 0;
-
- StorageAction *action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN);
- action->p_file = file;
-
- return action;
-}
-
-StorageAction *StorageN11::close(surf_file_t fd)
-{
- char *filename = fd->name;
- XBT_DEBUG("\tClose file '%s' size '%llu'", filename, fd->size);
- // unref write actions from storage
- void *_write_action;
- StorageAction *write_action;
- unsigned int i;
- xbt_dynar_foreach(p_writeActions, i, _write_action) {
- write_action = static_cast<StorageAction*>(_write_action);
- if ((write_action->p_file) == fd) {
- xbt_dynar_cursor_rm(p_writeActions, &i);
- write_action->unref();
- }
- }
- free(fd->name);
- free(fd->mount);
- xbt_free(fd);
- StorageAction *action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, CLOSE);
- return action;