Adding a bit more checking on file operations.
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_circular_file.cc
index 8aa8af08e479117509d941b038247fe0c86273d7..c9222597a873da93ca5f2081bc7f314d73a9a9d1 100644 (file)
@@ -1,12 +1,12 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2002 Free Software Foundation, Inc.
+ * Copyright 2002,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
  * GNU Radio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
+ * the Free Software Foundation; either version 3, or (at your option)
  * any later version.
  * 
  * GNU Radio is distributed in the hope that it will be useful,
@@ -16,8 +16,8 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with GNU Radio; see the file COPYING.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -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 {