/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
}
}
+// static
+FILE *File::openRawHandle(const char *filename, const char *mode)
+{
+ FILE *fp = fopen(filename, mode);
+ if (fp == NULL)
+ {
+ GMX_THROW_WITH_ERRNO(
+ FileIOError(formatString("Could not open file '%s'", filename)),
+ "fopen", errno);
+ }
+ return fp;
+}
+
+// static
+FILE *File::openRawHandle(const std::string &filename, const char *mode)
+{
+ return openRawHandle(filename.c_str(), mode);
+}
+
File::File(const char *filename, const char *mode)
: impl_(new Impl(NULL, true))
{
GMX_RELEASE_ASSERT(impl_->fp_ == NULL,
"Attempted to open the same file object twice");
// TODO: Port all necessary functionality from gmx_ffopen() here.
- impl_->fp_ = fopen(filename, mode);
- if (impl_->fp_ == NULL)
- {
- GMX_THROW_WITH_ERRNO(
- FileIOError(formatString("Could not open file '%s'", filename)),
- "fopen", errno);
- }
+ impl_->fp_ = openRawHandle(filename, mode);
}
void File::open(const std::string &filename, const char *mode)