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

Function binaryToText

DEVELOPER/core/BinaryFileStream.cpp:588–685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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