From cc7ee26bbc7ed2158c82b8f6e579077e220d111f Mon Sep 17 00:00:00 2001
From: jsiegle <jsiegle@mit.edu>
Date: Tue, 6 Nov 2012 15:04:47 -0500
Subject: [PATCH] Rudimentary code for writing headers to data files

---
 Source/Processors/RecordNode.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Source/Processors/RecordNode.cpp b/Source/Processors/RecordNode.cpp
index 09580899e..0a3bf8619 100755
--- a/Source/Processors/RecordNode.cpp
+++ b/Source/Processors/RecordNode.cpp
@@ -141,6 +141,8 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
 
 		std::pair<int, Channel> newPair (getNextChannel(false), newChannel);
 
+		//std::cout << "adding channel " << getNextChannel(false) << std::endl;
+
 		continuousChannels.insert(newPair);
 
 		
@@ -230,7 +232,25 @@ void RecordNode::setParameter (int parameterIndex, float newValue)
 			if (continuousChannels[i].isRecording)
 			{
 				std::cout << "OPENING FILE: " << continuousChannels[i].filename << std::endl;
+
+				File f = File(continuousChannels.filename);
+				bool fileExists = false;
+
+				if (f.exists())
+				{
+					fileExists = true;
+				}
+
+
 				continuousChannels[i].file = fopen(continuousChannels[i].filename.toUTF8(), "a");
+
+				if (!fileExists)
+				{
+					// create header (needs more details, obviously)
+					String header = "THIS IS A HEADER.";
+					fwrite(header.toUTF8(), 1, header.getNumBytesAsUTF8(), continuousChannels[i].file);
+				}
+
 			}
 		}
  		
-- 
GitLab