0

So I'm trying to copy the text contents of an LDB file, my problem is that only 1 line gets copied with the following:


#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
    string line;
    //For writing text file
    //Creating ofstream & ifstream class object
    ifstream ini_file{ "file.ldb" };
    ofstream out_file{ "copy.txt" };

    if (ini_file && out_file) {

        while (getline(ini_file, line)) {
            out_file << line << "\n";
        }

        cout << "Copy Finished \n";

    }
    else {
        //Something went wrong
        printf("Cannot read File");
    }

    //Closing file
    ini_file.close();
    out_file.close();

    return 0;
}

The script only copies the following line:


ʨ, ±¨datak T{"Controller":{"a(Status˜valuer":true,"ComasABA  },J0 i(SnabW }:? 

Which is like the first 300 characters from the file.

The whole ldb file has about 700kb, while the output is 129 bytes.

I'm not interested in decrypting, I just want the data which is semi-encrypted and will later process it myself.

johnnasx
  • 158
  • 10
  • See https://stackoverflow.com/questions/15138353/how-to-read-a-binary-file-into-a-vector-of-unsigned-chars – 1201ProgramAlarm Jun 24 '21 at 18:54
  • Opening the file in default "text" mode reads chars until it gets to a special char (LF/CR combo). In a encrypted file this LF/CR is rare or ypu may meet it by chance. Better open the file in "binary" mode, read the chars (one by one) and dismiss those that fall outside of common characters range. – Ripi2 Jun 24 '21 at 18:56

0 Answers0