Skip to content

Commit ef83d54

Browse files
committed
Add error logging for missing files in BinaryFileSource
1 parent 279705d commit ef83d54

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Source/Processors/FileReader/BinaryFileSource/BinaryFileSource.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void BinaryFileSource::fillRecordInfo()
7777
String sampleNumbersFilename;
7878
String channelStatesFilename;
7979

80-
int majorVersion = guiVersion.substring(0, 1).getIntValue();
80+
int majorVersion = guiVersion.substring (0, 1).getIntValue();
8181
int minorVersion = guiVersion.substring (2, 3).getIntValue();
8282

8383
if (minorVersion < 6 && majorVersion == 0)
@@ -125,7 +125,10 @@ void BinaryFileSource::fillRecordInfo()
125125

126126
File dataFile = m_rootPath.getChildFile ("continuous").getChildFile (streamName).getChildFile ("continuous.dat");
127127
if (! dataFile.existsAsFile())
128+
{
129+
LOGE ("Continuous data file not found: ", dataFile.getFullPathName());
128130
continue;
131+
}
129132

130133
int numChannels = record[idNumChannels];
131134
int64 numSamples = (dataFile.getSize() / numChannels) / sizeof (int16);
@@ -157,7 +160,7 @@ void BinaryFileSource::fillRecordInfo()
157160

158161
cInfo.name = chan[idChannelName];
159162
cInfo.bitVolts = chan[idBitVolts];
160-
cInfo.type = static_cast<uint8>(int(chan[idType]));
163+
cInfo.type = static_cast<uint8> (int (chan[idType]));
161164

162165
info.channels.add (cInfo);
163166
}
@@ -210,6 +213,12 @@ void BinaryFileSource::fillRecordInfo()
210213
LOGD ("TTL found");
211214

212215
File channelStatesFile = m_rootPath.getChildFile ("events").getChildFile (streamName).getChildFile (channelStatesFilename);
216+
217+
if (! channelStatesFile.existsAsFile())
218+
{
219+
LOGE ("Channel states file not found: ", channelStatesFile.getFullPathName());
220+
continue;
221+
}
213222
LOGD ("Channel States File: ", channelStatesFile.getFullPathName());
214223
std::unique_ptr<MemoryMappedFile> channelStatesFileMap (new MemoryMappedFile (channelStatesFile, MemoryMappedFile::readOnly));
215224
jassert (channelStatesFileMap.get() != nullptr);
@@ -233,6 +242,11 @@ void BinaryFileSource::fillRecordInfo()
233242
LOGD ("Message found");
234243

235244
File textFile = m_rootPath.getChildFile ("events").getChildFile (streamName).getChildFile ("text.npy");
245+
if (! textFile.existsAsFile())
246+
{
247+
LOGE ("MessageCenter text file not found: ", textFile.getFullPathName());
248+
continue;
249+
}
236250

237251
juce::FileInputStream inputStream (textFile);
238252
inputStream.skipNextBytes (10); // \x93NUMPY \x01 \x00
@@ -338,7 +352,7 @@ int BinaryFileSource::readData (float* buffer, int nSamples)
338352
}
339353

340354
m_samplePos += samplesToRead;
341-
return int(samplesToRead);
355+
return int (samplesToRead);
342356
}
343357

344358
/* void BinaryFileSource::processChannelData (int16* inBuffer, float* outBuffer, int channel, int64 numSamples)

0 commit comments

Comments
 (0)