1 /* Copyright (c) 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. */
7 #include "src/msg/msg_private.h"
8 #include "src/msg/msg_mailbox.h"
10 #include "simgrid/s4u/actor.hpp"
11 #include "simgrid/s4u/comm.hpp"
12 #include "simgrid/s4u/host.hpp"
13 #include "simgrid/s4u/mailbox.hpp"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
17 #include "simgrid/s4u/file.hpp"
18 #include "simgrid/s4u/host.hpp"
19 #include "simgrid/simix.h"
24 File::File(const char*fullpath, void *userdata) {
25 // this cannot fail because we get a xbt_die if the mountpoint does not exist
26 p_inferior = simcall_file_open(fullpath, Host::current()->inferior());
31 simcall_file_close(p_inferior, Host::current()->inferior());
34 sg_size_t File::read(sg_size_t size) {
35 return simcall_file_read(p_inferior, size, Host::current()->inferior());
37 sg_size_t File::write(sg_size_t size) {
38 return simcall_file_write(p_inferior,size, Host::current()->inferior());
40 sg_size_t File::size() {
41 return simcall_file_get_size(p_inferior);
44 void File::seek(sg_size_t pos) {
45 simcall_file_seek(p_inferior,pos,SEEK_SET);
47 sg_size_t File::tell() {
48 return simcall_file_tell(p_inferior);
50 void File::move(const char*fullpath) {
51 simcall_file_move(p_inferior,fullpath);
54 sg_host_t attached = Host::current()->inferior(); // FIXME: we should check where this file is attached
55 simcall_file_unlink(p_inferior,attached);
58 }} // namespace simgrid::s4u