- XBT_DEBUG("\tClose file '%s' size '%llu'", fd->name, fd->size);
- // unref write actions from storage
- for (std::vector<StorageAction*>::iterator it = writeActions_.begin(); it != writeActions_.end();) {
- StorageAction *write_action = *it;
- if ((write_action->file_) == fd) {
- write_action->unref();
- it = writeActions_.erase(it);
- } else {
- ++it;
- }
- }
- free(fd->name);
- free(fd->mount);
- xbt_free(fd);
- StorageAction* action = new StorageN11Action(model(), 0, isOff(), this, CLOSE);
- return action;
-}
-
-StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size)
-{
- if(fd->current_position + size > fd->size){
- if (fd->current_position > fd->size){
- size = 0;
- } else {
- size = fd->size - fd->current_position;
- }
- fd->current_position = fd->size;
- }
- else
- fd->current_position += size;
-
- StorageAction* action = new StorageN11Action(model(), size, isOff(), this, READ);
- return action;
-}
-
-StorageAction *StorageN11::write(surf_file_t fd, sg_size_t size)
-{
- char *filename = fd->name;
- XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
-
- StorageAction* action = new StorageN11Action(model(), size, isOff(), this, WRITE);
- action->file_ = fd;
- /* Substract the part of the file that might disappear from the used sized on the storage element */
- usedSize_ -= (fd->size - fd->current_position);
- // If the storage is full before even starting to write
- if(usedSize_==size_) {
- action->setState(Action::State::failed);
- }
- return action;