MeteoIODoc 20241005.2ccf54a9
FStream.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/* Copyright 2014 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3/***********************************************************************************/
4/* This file is part of MeteoIO.
5 MeteoIO is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 MeteoIO is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef FSTREAM_H
20#define FSTREAM_H
21
22#include <sstream>
23#include <fstream>
24#include <meteoio/IOManager.h>
25
26namespace mio {
27
36class ofilestream : public std::ofstream
37{
38 public:
40 ofilestream(const char* filename, std::ios_base::openmode mode = std::ios_base::out);
41 ofilestream(const char* filename, const Config& cfgreader, std::ios_base::openmode mode = std::ios_base::out);
42 ofilestream(const std::string filename, std::ios_base::openmode mode = std::ios_base::out);
43 ofilestream(const std::string filename, const Config& cfgreader, std::ios_base::openmode mode = std::ios_base::out);
44
45
46 void open(const char* filename, std::ios_base::openmode mode = std::ios_base::out);
47 static void createDirectoriesOfFile(const char* filename);
48
49 static bool getDefault();
50 static std::string getLimitBaseDir();
51
52 private:
53 static std::string initializeFilesystem(const char* filename, const Config& cfgreader);
54 static std::string initializeFilesystem(const char* filename, bool write_directories);
55 static bool write_directories_default;
56 static bool keep_old_files;
57 friend void IOManager::setOfstreamDefault(const Config& i_cfg);
58
59 static std::string cutPathToLimitDir(const std::string &path);
60 static std::string limitAccess(std::string path, const bool& write_directories);
61
62 static bool warn_abs_path;
63};
64}
65
66#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
void setOfstreamDefault(const Config &i_cfg)
Definition: IOManager.cc:315
A class that extends std::ofstream, adding some output functionality. Limiting the write access of th...
Definition: FStream.h:37
static bool getDefault()
Definition: FStream.cc:211
ofilestream()
Definition: FStream.h:39
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::out)
The actual writing function.
Definition: FStream.cc:178
static void createDirectoriesOfFile(const char *filename)
Definition: FStream.cc:225
static std::string getLimitBaseDir()
Definition: FStream.cc:216
Definition: Config.cc:31