ARTS 2.5.11 (git: 6827797f)
file.h
Go to the documentation of this file.
1
2// File description
4
13#ifndef file_h
14#define file_h
15
16#include <fstream>
17
18#include "double_imanip.h"
19#include "messages.h"
20#include "mystring.h"
21
23// Default file names
25
26void filename_ascii(String& filename, const String& varname);
27
28void filename_bin(String& filename, const std::string_view varname);
29
31// Functions to open and read ASCII files
33
34void open_output_file(std::ofstream& file, const std::string_view name);
35
36void cleanup_output_file(std::ofstream& file, const std::string_view name);
37
38void open_input_file(std::ifstream& file, const std::string_view name);
39
40[[nodiscard]] ArrayOfString read_text_from_stream(std::istream& is);
41
42[[nodiscard]] ArrayOfString read_text_from_file(const std::string_view name);
43
44void replace_all(String& s, const std::string_view what, const std::string_view with);
45
46[[nodiscard]] int check_newline(const std::string_view s);
47
48[[nodiscard]] bool file_exists(const std::string_view filename);
49
50bool find_file(ArrayOfString& matches,
51 const std::string_view filename,
52 const ArrayOfString& paths,
53 const ArrayOfString& extensions = {""});
54
55void find_xml_file(String& filename, const Verbosity& verbosity);
56
57[[nodiscard]] bool find_xml_file_existence(String& filename);
58
59[[nodiscard]] String expand_path(String path);
60
61[[nodiscard]] String add_basedir(const std::string_view path);
62
63[[nodiscard]] String get_dirname(const std::string_view path);
64
65[[nodiscard]] ArrayOfString list_directory(const std::string_view dirname);
66
67[[nodiscard]] String make_filename_unique(const std::string_view filename, const String& extension = "");
68
69#endif
Fast double input stream with support for parsing nan and inf.
ArrayOfString list_directory(const std::string_view dirname)
Return list of files in directory.
Definition: file.cc:470
ArrayOfString read_text_from_file(const std::string_view name)
Reads an ASCII file and appends the contents to the String vector text.
Definition: file.cc:186
void open_output_file(std::ofstream &file, const std::string_view name)
String make_filename_unique(const std::string_view filename, const String &extension="")
Make filename unique.
Definition: file.cc:496
String add_basedir(const std::string_view path)
Definition: file.cc:424
void find_xml_file(String &filename, const Verbosity &verbosity)
Find an xml file.
Definition: file.cc:338
ArrayOfString read_text_from_stream(std::istream &is)
bool find_xml_file_existence(String &filename)
As find_xml_file but does not throw in the main body.
Definition: file.cc:377
String expand_path(String path)
Definition: file.cc:405
void replace_all(String &s, const std::string_view what, const std::string_view with)
Replace all occurances of ‘what’ in ‘s’ with ‘with’.
Definition: file.cc:215
void filename_ascii(String &filename, const String &varname)
Gives the default file name for the ASCII formats.
Definition: file.cc:43
void cleanup_output_file(std::ofstream &file, const std::string_view name)
void filename_bin(String &filename, const std::string_view varname)
bool find_file(ArrayOfString &matches, const std::string_view filename, const ArrayOfString &paths, const ArrayOfString &extensions={""})
Searches through paths for a file with a matching name.
Definition: file.cc:284
void open_input_file(std::ifstream &file, const std::string_view name)
int check_newline(const std::string_view s)
Checks if there is exactly one newline character at the end of the string.
Definition: file.cc:233
bool file_exists(const std::string_view filename)
Checks if the given file exists.
Definition: file.cc:265
String get_dirname(const std::string_view path)
Return the parent directory of a path.
Definition: file.cc:444
Declarations having to do with the four output streams.
This file contains the definition of String, the ARTS string class.