ARTS 2.5.0 (git: 9ee3ac6c)
file.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2012 Stefan Buehler <sbuehler@ltu.se>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
19// File description
21
30#ifndef file_h
31#define file_h
32
33#include <fstream>
34#include "double_imanip.h"
35#include "messages.h"
36#include "mystring.h"
37
39// Default file names
41
42void filename_ascii(String& filename, const String& varname);
43
44void filename_bin(String& filename, const String& varname);
45
47// Functions to open and read ASCII files
49
50void open_output_file(std::ofstream& file, const String& name);
51
52void cleanup_output_file(std::ofstream& file, const String& name);
53
54void open_input_file(std::ifstream& file, const String& name);
55
56void read_text_from_stream(ArrayOfString& text, std::istream& is);
57
58void read_text_from_file(ArrayOfString& text, const String& name);
59
60void replace_all(String& s, const String& what, const String& with);
61
62int check_newline(const String& s);
63
64bool file_exists(const String& filename);
65
66bool find_file(ArrayOfString& matches,
67 const String& filename,
68 const ArrayOfString& paths,
69 const ArrayOfString& extensions = {""});
70
71void find_xml_file(String& filename, const Verbosity& verbosity);
72
73bool find_xml_file_existence(String& filename);
74
75String expand_path(const String& path);
76
77String add_basedir(const String& path);
78
79void get_dirname(String& dirname, const String& path);
80
81void list_directory(ArrayOfString& files, String dirname);
82
83void make_filename_unique(String& filename, const String& extension = "");
84
85#endif
IO manipulation classes for parsing nan and inf.
void replace_all(String &s, const String &what, const String &with)
Replace all occurances of ‘what’ in ‘s’ with ‘with’.
Definition: file.cc:253
bool find_file(ArrayOfString &matches, const String &filename, const ArrayOfString &paths, const ArrayOfString &extensions={""})
Searches through paths for a file with a matching name.
Definition: file.cc:353
void cleanup_output_file(std::ofstream &file, const String &name)
void find_xml_file(String &filename, const Verbosity &verbosity)
Find an xml file.
Definition: file.cc:414
bool file_exists(const String &filename)
Checks if the given file exists.
Definition: file.cc:303
String add_basedir(const String &path)
Definition: file.cc:499
bool find_xml_file_existence(String &filename)
As find_xml_file but does not throw in the main body.
Definition: file.cc:452
void open_output_file(std::ofstream &file, const String &name)
int check_newline(const String &s)
Checks if there is exactly one newline character at the end of the string.
Definition: file.cc:271
void filename_bin(String &filename, const String &varname)
void get_dirname(String &dirname, const String &path)
Return the parent directory of a path.
Definition: file.cc:519
void read_text_from_stream(ArrayOfString &text, std::istream &is)
void filename_ascii(String &filename, const String &varname)
Gives the default file name for the ASCII formats.
Definition: file.cc:73
void make_filename_unique(String &filename, const String &extension="")
Make filename unique.
Definition: file.cc:571
void list_directory(ArrayOfString &files, String dirname)
Return list of files in directory.
Definition: file.cc:543
void open_input_file(std::ifstream &file, const String &name)
String expand_path(const String &path)
Definition: file.cc:480
void read_text_from_file(ArrayOfString &text, const String &name)
Reads an ASCII file and appends the contents to the String vector text.
Definition: file.cc:225
Declarations having to do with the four output streams.
This file contains the definition of String, the ARTS string class.