Matthias Volk
8 years ago
29 changed files with 188 additions and 182 deletions
-
23src/storm-dft/modelchecker/dft/DFTASFChecker.cpp
-
17src/storm-dft/parser/DFTGalileoParser.cpp
-
14src/storm-dft/parser/DFTJsonParser.cpp
-
8src/storm-gspn-cli/storm-gspn.cpp
-
20src/storm-gspn/storm-gspn.h
-
11src/storm-pgcl-cli/storm-pgcl.cpp
-
9src/storm-pgcl/parser/PgclParser.cpp
-
5src/storm/abstraction/MenuGameAbstractor.cpp
-
8src/storm/cli/entrypoints.h
-
5src/storm/modelchecker/region/ParameterRegion.cpp
-
5src/storm/parser/AtomicPropositionLabelingParser.cpp
-
5src/storm/parser/DeterministicSparseTransitionParser.cpp
-
9src/storm/parser/FormulaParser.cpp
-
14src/storm/parser/JaniParser.cpp
-
18src/storm/parser/MappedFile.cpp
-
8src/storm/parser/MappedFile.h
-
5src/storm/parser/MarkovAutomatonSparseTransitionParser.cpp
-
5src/storm/parser/NondeterministicSparseTransitionParser.cpp
-
10src/storm/parser/PrismParser.cpp
-
5src/storm/parser/SparseChoiceLabelingParser.cpp
-
5src/storm/parser/SparseStateRewardParser.cpp
-
8src/storm/settings/SettingsManager.cpp
-
13src/storm/solver/SmtlibSmtSolver.cpp
-
6src/storm/storage/dd/Odd.cpp
-
18src/storm/storage/jani/JSONExporter.cpp
-
15src/storm/utility/export.h
-
81src/storm/utility/file.h
-
13src/storm/utility/storm.h
-
7src/test/parser/MappedFileTest.cpp
@ -0,0 +1,81 @@ |
|||
/** |
|||
* @file: file.h |
|||
* @author: Sebastian Junges |
|||
* |
|||
* @since October 7, 2014 |
|||
*/ |
|||
|
|||
#ifndef STORM_UTILITY_FILE_H_ |
|||
#define STORM_UTILITY_FILE_H_ |
|||
|
|||
#include <iostream> |
|||
|
|||
#include "storm/utility/macros.h" |
|||
#include "storm/exceptions/FileIoException.h" |
|||
|
|||
namespace storm { |
|||
namespace utility { |
|||
|
|||
/*! |
|||
* Open the given file for writing. |
|||
* |
|||
* @param filename Path and name of the file to be tested. |
|||
* @param filestream Contains the file handler afterwards. |
|||
* @param append If true, the new content is appended instead of clearing the existing content. |
|||
*/ |
|||
inline void openFile(std::string const& filepath, std::ofstream& filestream, bool append = false) { |
|||
if (append) { |
|||
filestream.open(filepath, std::ios::app); |
|||
} else { |
|||
filestream.open(filepath); |
|||
} |
|||
STORM_LOG_THROW(filestream, storm::exceptions::FileIoException , "Could not open file " << filepath << "."); |
|||
STORM_PRINT_AND_LOG("Write to file " << filepath << "." << std::endl); |
|||
} |
|||
|
|||
/*! |
|||
* Open the given file for reading. |
|||
* |
|||
* @param filename Path and name of the file to be tested. |
|||
* @param filestream Contains the file handler afterwards. |
|||
*/ |
|||
inline void openFile(std::string const& filepath, std::ifstream& filestream) { |
|||
filestream.open(filepath); |
|||
STORM_LOG_THROW(filestream, storm::exceptions::FileIoException , "Could not open file " << filepath << "."); |
|||
} |
|||
|
|||
/*! |
|||
* Close the given file after writing. |
|||
* |
|||
* @param filestream Contains the file handler to close. |
|||
*/ |
|||
inline void closeFile(std::ofstream& stream) { |
|||
stream.close(); |
|||
} |
|||
|
|||
/*! |
|||
* Close the given file after reading. |
|||
* |
|||
* @param filestream Contains the file handler to close. |
|||
*/ |
|||
inline void closeFile(std::ifstream& stream) { |
|||
stream.close(); |
|||
} |
|||
|
|||
/*! |
|||
* Tests whether the given file exists and is readable. |
|||
* |
|||
* @param filename Path and name of the file to be tested. |
|||
* @return True iff the file exists and is readable. |
|||
*/ |
|||
inline bool fileExistsAndIsReadable(std::string const& filename) { |
|||
// Test by opening an input file stream and testing the stream flags. |
|||
std::ifstream filestream; |
|||
filestream.open(filename); |
|||
return filestream.good(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue