Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix dist
[simgrid.git] / src / s4u / s4u_file.cpp
1 /* Copyright (c) 2015. The SimGrid Team. All rights reserved.               */
2
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. */
5
6 #include "xbt/log.h"
7 #include "src/msg/msg_private.h"
8
9 #include "simgrid/s4u/Actor.hpp"
10 #include "simgrid/s4u/comm.hpp"
11 #include "simgrid/s4u/host.hpp"
12 #include "simgrid/s4u/Mailbox.hpp"
13
14 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
15
16 #include "simgrid/s4u/file.hpp"
17 #include "simgrid/s4u/host.hpp"
18 #include "simgrid/simix.h"
19
20 namespace simgrid {
21 namespace s4u {
22
23 File::File(const char* fullpath, void* userdata) : path_(fullpath)
24 {
25   // this cannot fail because we get a xbt_die if the mountpoint does not exist
26   pimpl_ = simcall_file_open(fullpath, Host::current());
27 }
28
29 File::~File() {
30   simcall_file_close(pimpl_, Host::current());
31 }
32
33 sg_size_t File::read(sg_size_t size) {
34   return simcall_file_read(pimpl_, size, Host::current());
35 }
36 sg_size_t File::write(sg_size_t size) {
37   return simcall_file_write(pimpl_,size, Host::current());
38 }
39 sg_size_t File::size() {
40   return simcall_file_get_size(pimpl_);
41 }
42
43 void File::seek(sg_size_t pos) {
44   simcall_file_seek(pimpl_,pos,SEEK_SET);
45 }
46 sg_size_t File::tell() {
47   return simcall_file_tell(pimpl_);
48 }
49 void File::move(const char*fullpath) {
50   simcall_file_move(pimpl_,fullpath);
51 }
52 void File::unlink() {
53   sg_host_t attached = Host::current(); // FIXME: we should check where this file is attached
54   simcall_file_unlink(pimpl_,attached);
55 }
56
57 }} // namespace simgrid::s4u