xbt_dict_t Storage::getContent()
{
/* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
- /*surf_action_t action = storage_action_execute(storage,0, LS);*/
xbt_dict_t content_dict = xbt_dict_new_homogeneous(NULL);
xbt_dict_cursor_t cursor = NULL;
StorageAction::StorageAction(ModelPtr model, double cost, bool failed,
StoragePtr storage, e_surf_action_storage_type_t type)
: Action(model, cost, failed)
-, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL){
+, m_type(type), p_storage(storage), p_file(NULL){
progress = 0;
};
StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
StoragePtr storage, e_surf_action_storage_type_t type)
: Action(model, cost, failed, var)
- , m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL) {
+ , m_type(type), p_storage(storage), p_file(NULL){
progress = 0;
}
*/
virtual StorageActionPtr close(surf_file_t fd)=0;
- /**
- * @brief List directory contents of a path
- * @details [long description]
- *
- * @param path The path to the directory
- * @return The StorageAction corresponding to the ls action
- */
- virtual StorageActionPtr ls(const char *path)=0;
-
/**
* @brief Read a file
*
WRITE, /**< Write in a file */
STAT, /**< Stat a file */
OPEN, /**< Open a file */
- CLOSE, /**< Close a file */
- LS /**< List directory contents */
+ CLOSE /**< Close a file */
} e_surf_action_storage_type_t;
/** @ingroup SURF_storage_interface
e_surf_action_storage_type_t m_type;
StoragePtr p_storage;
surf_file_t p_file;
- xbt_dict_t p_lsDict;
double progress;
};
XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
}
-StorageActionPtr StorageN11::ls(const char* path)
-{
- StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, LS);
-
- action->p_lsDict = NULL;
- xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
-
- char* key;
- sg_size_t size = 0;
- xbt_dict_cursor_t cursor = NULL;
-
- xbt_dynar_t dyn = NULL;
- char* file = NULL;
-
- // for each file in the storage content
- xbt_dict_foreach(p_content,cursor,key,size){
- // Search if file start with the prefix 'path'
- if(xbt_str_start_with(key,path)){
- file = &key[strlen(path)];
-
- // Split file with '/'
- dyn = xbt_str_split(file,"/");
- file = xbt_dynar_get_as(dyn,0,char*);
-
- // file
- if(xbt_dynar_length(dyn) == 1){
- sg_size_t *psize = xbt_new(sg_size_t, 1);
- *psize=size;
- xbt_dict_set(ls_dict, file, psize, NULL);
- }
- // Directory
- else
- {
- // if directory does not exist yet in the dictionary
- if(!xbt_dict_get_or_null(ls_dict,file))
- xbt_dict_set(ls_dict,file,NULL,NULL);
- }
- xbt_dynar_free(&dyn);
- }
- }
-
- action->p_lsDict = ls_dict;
- return action;
-}
-
StorageActionPtr StorageN11::open(const char* mount, const char* path)
{
XBT_DEBUG("\tOpen file '%s'",path);
case OPEN:
case CLOSE:
case STAT:
- case LS:
break;
case READ:
lmm_expand(model->getMaxminSystem(), storage->p_constraintRead,
surf_file_t surf_storage_action_get_file(surf_action_t action){
return static_cast<StorageActionPtr>(action)->p_file;
}
-
-xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action){
- return static_cast<StorageActionPtr>(action)->p_lsDict;
-}