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 <kenlm@kheafield.com>2012-03-11 21:47:38 +0400
committerKenneth Heafield <kenlm@kheafield.com>2012-03-11 21:47:38 +0400
commit175b7aaf495963a8dd08525094073db06686adf8 (patch)
treec279eee1e5a3d3d7d417ec747091e184c418b7bf /util/file.cc
parent0fc56ef7b602134b387b264c4b1ffe13e7ac40f8 (diff)
KenLM c1dba12
- Reject NaNs - Fix ChartState hashing (unused in Moses) - Expose CreateOrThrow - Minor portability improvement in getopt
Diffstat (limited to 'util/file.cc')
-rw-r--r--util/file.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/util/file.cc b/util/file.cc
index aee7c77ac..176737fa7 100644
--- a/util/file.cc
+++ b/util/file.cc
@@ -42,6 +42,16 @@ int OpenReadOrThrow(const char *name) {
return ret;
}
+int CreateOrThrow(const char *name) {
+ int ret;
+#if defined(_WIN32) || defined(_WIN64)
+ UTIL_THROW_IF(-1 == (ret = _open(name, _O_CREAT | _O_TRUNC | _O_RDWR, _S_IREAD | _S_IWRITE)), ErrnoException, "while creating " << name);
+#else
+ UTIL_THROW_IF(-1 == (ret = open(name, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)), ErrnoException, "while creating " << name);
+#endif
+ return ret;
+}
+
uint64_t SizeFile(int fd) {
#if defined(_WIN32) || defined(_WIN64)
__int64 ret = _filelengthi64(fd);