16#include <Sortie_Fichier_base.h>
40Sortie_Fichier_base::~Sortie_Fichier_base()
45void Sortie_Fichier_base::set_toFlush()
52 char* theValue = getenv(
"TRUST_FLUSHFILES");
53 if (theValue !=
nullptr)
55 toFlush_=atoi(theValue);
59void Sortie_Fichier_base::set_buffer()
63 char* theValue = getenv(
"TRUST_BUFFSIZE");
66 int buffSize = 3000000;
67 if (theValue !=
nullptr)
69 buffSize = atoi(theValue);
73 size_t internalBuffSize = buffSize;
74 internalBuff_ =
new char[internalBuffSize];
75 ofstream_->rdbuf()->pubsetbuf(internalBuff_,internalBuffSize);
94 delete[] internalBuff_;
95 internalBuff_ =
nullptr;
123 std::string cmd=
"mkdir -p ";
125 int err = system(cmd.c_str());
128 Cerr <<
"Sortie_Fichier_base::ouvrir: Error while creating " <<
root <<
" folder!" << finl;
132 std::string pathname =
root;
133 if (!pathname.empty()) pathname+=
"/";
138 Cerr <<
"Warning, file " << pathname <<
" has been opened/closed " << counter_ <<
" times..." << finl;
140 IOS_OPEN_MODE ios_mod=mode;
145 if (ios_mod==ios::out)
148 assert((ios_mod==ios::app)||(ios_mod==(ios::app|ios::out)));
149 ios_mod=ios_mod|ios::binary;
151 ostream_ = std::make_unique<ofstream>(pathname,ios_mod);
157 Cerr <<
"Error when opening the file " << pathname <<
". File was opened " << counter_ <<
" time(s) ..." << finl;
158 Cerr <<
"Either:\n you don't have write rights,\n or your filesystem is very slow and multiple file open/close." << finl;
159 Cerr <<
"Contact TRUST support team." << finl;
194 Cerr <<
"[IO] Setting output directory to: " <<
root << finl;
bool bin_
Is this a binary flux?
bool is_64b_
Will we be reading/writing in 64b? (Init in ctor to avoid including arch.h probably).
Class defining operators and methods for all reading operation in an input flow (file,...
class Nom Une chaine de caractere pour nommer les objets de TRUST
virtual int finit_par(const char *const n) const
classe Objet_U Cette classe est la classe de base des Objets de TRUST
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static int exception_sur_exit
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
virtual int get_precision()
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
Sortie & flush() override
Force l'ecriture sur disque des donnees dans le tampon Utilise l'implementation de la classe ofstream...
void precision(int pre) override
void setf(IOS_FORMAT code) override
static void set_root(const std::string dirname)
ofstream & get_ofstream()
Classe de base des flux de sortie.
std::unique_ptr< ostream > ostream_