Adding a bit more checking on file operations.
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_circular_file.cc
index 6f605419e122cb1241822525b8f3319242b71f78..c9222597a873da93ca5f2081bc7f314d73a9a9d1 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2002 Free Software Foundation, Inc.
+ * Copyright 2002,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -39,6 +39,8 @@
 #include <stdlib.h>
 
 #include <algorithm>
+#include <stdio.h>
+#include <string.h>
 
 static const int HEADER_SIZE = 4096;
 static const int HEADER_MAGIC = 0xEB021026;
@@ -64,7 +66,10 @@ gr_circular_file::gr_circular_file (const char *filename,
       exit (1);
     }
 #ifdef HAVE_MMAP       /* FIXME */
-    ftruncate (d_fd, size + HEADER_SIZE);
+    if(ftruncate (d_fd, size + HEADER_SIZE) != 0) {
+      perror (filename);
+      exit (1);
+    }
 #endif
   }
   else {