1 /* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_S4U_FILE_HPP
7 #define SIMGRID_S4U_FILE_HPP
11 #include <simgrid/simix.h>
17 /** @brief A simulated file
19 * Used to simulate the time it takes to access to a file, but does not really store any information.
21 * They are located on @ref simgrid::s4u::Storage that are accessed from a given @ref simgrid::s4u::Host through
23 * For now, you cannot change the mountpoints programatically, and must declare them from your platform file.
28 File(std::string fullpath, void* userdata);
29 File(std::string fullpath, sg_host_t host, void* userdata);
32 /** Retrieves the path to the file */
33 const char* getPath() { return path_.c_str(); }
35 /** Simulates a local read action. Returns the size of data actually read */
36 sg_size_t read(sg_size_t size);
38 /** Simulates a write action. Returns the size of data actually written. */
39 sg_size_t write(sg_size_t size);
41 /** Allows to store user data on that host */
42 void setUserdata(void* data) { userdata_ = data; }
43 /** Retrieves the previously stored data */
44 void* getUserdata() { return userdata_; }
46 /** Retrieve the datasize */
49 /** Sets the file head to the given position. */
50 void seek(sg_offset_t pos);
51 void seek(sg_offset_t pos, int origin);
53 /** Retrieves the current file position */
56 /** Rename a file. WARNING: It is forbidden to move the file to another mount point */
57 void move(std::string fullpath);
59 /** Remove a file from disk */
62 std::string storage_type;
63 std::string storageId;
64 std::string mount_point;
68 surf_file_t pimpl_ = nullptr;
70 void* userdata_ = nullptr;
73 } // namespace simgrid::s4u
75 #endif /* SIMGRID_S4U_HOST_HPP */