Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MSG_file_rename function
[simgrid.git] / src / simix / smx_io.c
index 519ce6d..aa0d016 100644 (file)
@@ -33,6 +33,22 @@ smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data)
   return xbt_lib_get_or_null(storage_lib, name, SIMIX_STORAGE_LEVEL);
 }
 
+/**
+ * \brief Internal function to destroy a SIMIX storage.
+ *
+ * \param s the host to destroy (a smx_storage_t)
+ */
+void SIMIX_storage_destroy(void *s)
+{
+  smx_storage_priv_t storage = (smx_storage_priv_t) s;
+
+  xbt_assert((storage != NULL), "Invalid parameters");
+  if (storage->data)
+    free(storage->data);
+
+  /* Clean storage structure */
+  free(storage);
+}
 
 void* SIMIX_pre_file_get_data(smx_simcall_t simcall,smx_file_t fd){
   return SIMIX_file_get_data(fd);
@@ -221,7 +237,7 @@ int SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
   }
 
   if (surf_workstation_model->extension.workstation.unlink(host, fd->surf_file)){
-    fd->surf_file = NULL;
+    xbt_free(fd);
     return 1;
   } else
     return 0;
@@ -284,6 +300,19 @@ xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd)
       fd->surf_file);
 }
 
+void SIMIX_pre_file_rename(smx_simcall_t simcall, smx_file_t fd, const char* new_name)
+{
+  return SIMIX_file_rename(simcall->issuer, fd, new_name);
+}
+
+void SIMIX_file_rename(smx_process_t process, smx_file_t fd, const char* new_name)
+{
+  smx_host_t host = process->smx_host;
+  return  surf_workstation_model->extension.workstation.rename(host,
+      fd->surf_file, new_name);
+}
+
+
 sg_storage_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name)
 {
   return SIMIX_storage_get_free_size(simcall->issuer, name);