Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2014-10-08 16:42:53 +0400
committerKenneth Heafield <github@kheafield.com>2014-10-08 16:42:53 +0400
commit36da8d1e0c17cbdecb7613398464bb9cabb56d20 (patch)
tree640641c55ac102f2fb5178fc816e260c1c0965b7 /util/file.hh
parente9f0ae951e59b5853ef677b1c627b4e7bc5b48b7 (diff)
KenLM 370f97fa549f02e162a3a0f17bf3ad6cce2c3813
Diffstat (limited to 'util/file.hh')
-rw-r--r--util/file.hh26
1 files changed, 4 insertions, 22 deletions
diff --git a/util/file.hh b/util/file.hh
index f2bb319d5..7204b6a04 100644
--- a/util/file.hh
+++ b/util/file.hh
@@ -2,6 +2,7 @@
#define UTIL_FILE_H
#include "util/exception.hh"
+#include "util/scoped.hh"
#include "util/string_piece.hh"
#include <cstddef>
@@ -42,29 +43,10 @@ class scoped_fd {
scoped_fd &operator=(const scoped_fd &);
};
-class scoped_FILE {
- public:
- explicit scoped_FILE(std::FILE *file = NULL) : file_(file) {}
-
- ~scoped_FILE();
-
- std::FILE *get() { return file_; }
- const std::FILE *get() const { return file_; }
-
- void reset(std::FILE *to = NULL) {
- scoped_FILE other(file_);
- file_ = to;
- }
-
- std::FILE *release() {
- std::FILE *ret = file_;
- file_ = NULL;
- return ret;
- }
-
- private:
- std::FILE *file_;
+struct scoped_FILE_closer {
+ static void Close(std::FILE *file);
};
+typedef scoped<std::FILE, scoped_FILE_closer> scoped_FILE;
/* Thrown for any operation where the fd is known. */
class FDException : public ErrnoException {