File: error-if-cant-open

package info (click to toggle)
devtodo 0.1.20-6.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,116 kB
  • sloc: sh: 9,134; cpp: 3,943; perl: 112; makefile: 73; ansic: 3; csh: 2
file content (18 lines) | stat: -rw-r--r-- 536 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if the database can't be created error so that the user knows.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511342

--- a/src/Loaders.cc
+++ b/src/Loaders.cc
@@ -215,7 +215,11 @@
 	{
 	ofstream of(file.c_str());
 
-		if (of.bad()) return false;
+        if(of.fail( ) || of.bad( )) {
+            cout << "ERROR: Failed to create/open file: " << file << "\n";
+            exit(1);
+        }
+
 		if (options.verbose > 1)
 			cout << "todo: saving to database '" << file << "'" << endl;
 		of << "<?xml version=\"1.0\"?>" << endl;