summaryrefslogtreecommitdiff
path: root/klm/util/file.hh
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-08-16 17:02:56 -0400
committerKenneth Heafield <github@kheafield.com>2012-08-16 17:07:51 -0400
commitf82833385b7cf3c01dc2f92830119dfe3ebc573e (patch)
tree6a8c04bb723d2504c461a398135d9645135a730a /klm/util/file.hh
parenta68aaea190197f17f308b91f66ceff222a784460 (diff)
KenLM update. Remove a couple of segfaults for weird input. Other oddball stuff.
Diffstat (limited to 'klm/util/file.hh')
-rw-r--r--klm/util/file.hh8
1 files changed, 7 insertions, 1 deletions
diff --git a/klm/util/file.hh b/klm/util/file.hh
index 5c57e2a9..8af1ff4f 100644
--- a/klm/util/file.hh
+++ b/klm/util/file.hh
@@ -65,7 +65,10 @@ class scoped_FILE {
std::FILE *file_;
};
+// Open for read only.
int OpenReadOrThrow(const char *name);
+// Create file if it doesn't exist, truncate if it does. Opened for write.
+int CreateOrThrow(const char *name);
// Return value for SizeFile when it can't size properly.
const uint64_t kBadSize = (uint64_t)-1;
@@ -91,10 +94,13 @@ class TempMaker {
public:
explicit TempMaker(const std::string &prefix);
+ // These will already be unlinked for you.
int Make() const;
-
std::FILE *MakeFile() const;
+ // This will force you to close the fd instead of leaving it open.
+ std::string Name(scoped_fd &opened) const;
+
private:
std::string base_;
};