فهرست منبع

check that output file can be created before training

Summary: This checks that the output file can be created before training.

Reviewed By: piotr-bojanowski

Differential Revision: D7010529

fbshipit-source-id: 504813de5ded70a6201560625d254cfc61972b3d
Edouard Grave 8 سال پیش
والد
کامیت
e8ea6ce588
1فایلهای تغییر یافته به همراه5 افزوده شده و 0 حذف شده
  1. 5 0
      src/main.cc

+ 5 - 0
src/main.cc

@@ -292,6 +292,11 @@ void train(const std::vector<std::string> args) {
   Args a = Args();
   a.parseArgs(args);
   FastText fasttext;
+  std::ofstream ofs(a.output+".bin");
+  if (!ofs.is_open()) {
+    throw std::invalid_argument(a.output + ".bin cannot be opened for saving.");
+  }
+  ofs.close();
   fasttext.train(a);
   fasttext.saveModel();
   fasttext.saveVectors();