MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / get_file_offsets

Method get_file_offsets

src/board_controller/playback_file_board.cpp:417–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417int PlaybackFileBoard::get_file_offsets (std::string filename, std::vector<long int> &offsets)
418{
419 offsets.clear ();
420
421 FILE *fp = fopen (filename.c_str (), "rb");
422 if (fp == NULL)
423 {
424 safe_logger (spdlog::level::err, "failed to open file: {}", filename.c_str ());
425 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
426 }
427
428 char buf[MAX_LINE_LENGTH];
429 long int bytes_read = 0;
430 while (true)
431 {
432 offsets.push_back (bytes_read);
433 char *res = fgets (buf, sizeof (buf), fp);
434 bytes_read += (long int)strlen (buf);
435 if (res == NULL)
436 {
437 break;
438 }
439 }
440
441 fclose (fp);
442 if (offsets.size () < 2)
443 {
444 safe_logger (spdlog::level::err, "empty file: {}", filename);
445 return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
446 }
447
448 return (int)BrainFlowExitCodes::STATUS_OK;
449}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected