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

Function binaryToText

SRC/handler/BinaryFileStream.cpp:589–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

OPS_convertBinaryToTextFunction · 0.50
convertBinaryToTextFunction · 0.50

Calls 2

closeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected