MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / binaryToText

Function binaryToText

SRC/runtime/commands/utilities/BinaryFileStream.cpp:601–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599
600
601int
602binaryToText(const char* inputFilename, const char* outputFilename)
603{
604 //
605 // open the files
606 //
607
608 ifstream input(inputFilename, ios::in | ios::binary);
609 ofstream output(outputFilename, ios::out);
610 if (input.bad()) {
611 std::cerr << "WARNING - BinaryFileStream - binaryToText()";
612 std::cerr << " - could not open file " << inputFilename << std::endl;
613 output.close();
614 return -1;
615 }
616 if (output.bad()) {
617 std::cerr << "WARNING - BinaryFileStream - binaryToText()";
618 std::cerr << " - could not open file " << outputFilename << std::endl;
619 output.close();
620 return -1;
621 }
622
623 //
624 // until done
625 // read input consisting doubles till \n and write to output file
626 //
627
628 double data;
629 char* c = (char*)&data;
630 int numNumbers = 0;
631 /* ORIGINAL
632 while ( !input.eof()) {
633 input.read(c, 1);
634 if (*c != '\n') {
635 input.read(&c[1],7);
636 output << data << " ";
637 numNumbers++;
638 } else {
639 if (numNumbers != 0)
640 output << "\n";
641 numNumbers = 0;
642 }
643 }
644 REPLACED WITH: */
645
646 int nLF = 0;
647 int intervalLF = 0;
648 double aveIntervalLF = 0;
649 int numCol;
650
651 int dataLen = 0;
652 int numRow;
653
654 while (!input.eof()) {
655 input.read(c, 1);
656 dataLen++;
657
658 if ((*c == '\n') && (intervalLF % 8 == 0)) {

Callers

nothing calls this directly

Calls 2

closeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected