- if(!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
- sg_size_t *psize, *new_psize;
- psize = (sg_size_t*)
- xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->p_content,
- fd->name);
- new_psize = xbt_new(sg_size_t, 1);
- *new_psize = *psize;
- if (psize){// src file exists
- xbt_dict_remove(findStorageOnMountList(fd->mount)->p_content, fd->name);
- char *path = (char *) xbt_malloc ((strlen(fullpath)-strlen(fd->mount)+1));
- strncpy(path, fullpath+strlen(fd->mount),
- strlen(fullpath)-strlen(fd->mount)+1);
- xbt_dict_set(findStorageOnMountList(fd->mount)->p_content, path,
- new_psize,NULL);
- XBT_DEBUG("Move file from %s to %s, size '%llu'",fd->name, fullpath, *psize);
- free(path);
+ if (!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
+ std::map<std::string, sg_size_t*>* content = findStorageOnMountList(fd->mount)->content_;
+ if (content->find(fd->name) != content->end()) { // src file exists
+ sg_size_t* psize = content->at(std::string(fd->name));
+ sg_size_t* new_psize = new sg_size_t;
+ *new_psize = *psize;
+ delete psize;
+ content->erase(fd->name);
+ std::string path = std::string(fullpath).substr(strlen(fd->mount), strlen(fullpath));
+ content->insert({path.c_str(), new_psize});
+ XBT_DEBUG("Move file from %s to %s, size '%llu'", fd->name, fullpath, *psize);