Hello, I created a custom app that needs to load some keys and certificates for encryption and I am trying to load these files from my cpp code with no luck so far. My setup is as following: I am using the dump plugin to simply transfer my files into the snap as follows: parts:
keys:
plugin: dump
source: ./keys
organize:
test.txt: ./keys/test.txt
server_cert.der: ./keys/server_cert.der
server_key.der: ./keys/server_key.der
client_cert.der: ./keys/client_cert.der
client_key.der: ./keys/client_key.der Please note that I am using test.txt for testing reading the file from the cpp code. In my cpp code I tried many different paths to read this file (test.txt) with no luck. I installed the app on my linux machine and it worked without any problem, but the issue occurs only on CtrlX core (I am currently using virtual core). Here is the relevant part of my cpp code: std::string path = "keys/test.txt";
std::cout << "write " << path << std::endl;
std::ofstream outfile (path);
if (outfile.is_open()){
std::cout << "opened: "<< path << std::endl;
outfile << "Test txt with some words\nand two lines\n" << path;
outfile.close();
}
else{
std::cout << "error: " << path << std::endl;
}
std::string sum;
char x;
std::ifstream inFile;
inFile.open("keys/test.txt");
if (!inFile) {
std::cout << "Unable to open file" << std::endl;
exit(1); // terminate with error
}
while (inFile >> x) {
sum = sum + x;
}
inFile.close();
std::cout << "Sum = " << sum << std::endl; I also tried many different plugins such as: personal-files, system-files but I can't get it to work, I also saw some posts using rexroth-solutions, but I didn't know how to exactly use it for my use case. My questions: 1) Where should I store my files (.der & .txt) files and how to organize them correctly 2) What is the correct path that I should use within my cpp code to be able to access these files Your help is highly appreciated. Many thanks, Osama Ayoub
... View more