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
9 #include <boost/unordered_map.hpp>
13 #include <simgrid/simix.h>
21 /** @brief A simulated file
23 * Used to simulate the time it takes to access to a file, but does not really store any information.
25 * They are located on @link{simgrid::s4u::Storage}, that are accessed from a given @link{simgrid::s4u::Host} through mountpoints.
26 * For now, you cannot change the mountpoints programatically, and must declare them from your platform file.
28 XBT_PUBLIC_CLASS File {
30 File(const char *fullpath, void* userdata);
33 smx_file_t p_inferior;
37 /** Retrieves the path to the file */
38 const char *path() { return p_path;}
40 /** Simulates a read action. Returns the size of data actually read
42 * FIXME: reading from a remotely mounted disk is not implemented yet. Any storage is considered as local, and no network communication ever occur.
44 sg_size_t read(sg_size_t size);
45 /** Simulates a write action. Returns the size of data actually written.
47 * FIXME: reading from a remotely mounted disk is not implemented yet. Any storage is considered as local, and no network communication ever occur.
49 sg_size_t write(sg_size_t size);
51 /** Allows to store user data on that host */
52 void set_userdata(void *data) {p_userdata = data;}
53 /** Retrieves the previously stored data */
54 void* userdata() {return p_userdata;}
56 void *p_userdata=NULL;
59 /** Retrieve the datasize */
62 /** Sets the file head to the given position. */
63 void seek(sg_size_t pos);
64 /** Retrieves the current file position */
69 * WARNING: It is forbidden to move the file to another mount point */
70 void move(const char*fullpath);
72 /** Remove a file from disk */
75 /* FIXME: add these to the S4U API:
76 XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file);
77 XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const char* fullpath);
78 XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath);
83 }} // namespace simgrid::s4u
85 #endif /* SIMGRID_S4U_HOST_HPP */