#include <bits/stdc++.h>
using namespace std;
int main(int count, char* argv[])
{
if(count!=2)
{
// print_syntax(argv[0]);
}
else if(count==2)
{
string file_name=argv[1];
// cout<<file_name<<endl;
string file_directory="~/.local/share/Trash/info/"+file_name+".trashinfo";
cout<<file_directory<<endl;
ifstream myReadFile;
myReadFile.open(file_directory);
char output[100];
if (myReadFile.is_open())
{
cout<<"here";
while (!myReadFile.eof())
{
myReadFile >> output;
cout<<output;
}
}
else
{
cout<<"Not working";
}
myReadFile.close();
}
}
I am trying to read a file from trash which further has two subfolders, the info one containing meta data for deleted file with an extension of .trashinfo
But due to some reason, I am not able to open that file in this program.
root@kali:~/projects/Linux-Commands/Restore# ./a.out hero
~/.local/share/Trash/info/hero.trashinfo
Not working
root@kali:~/projects/Linux-Commands/Restore# vi ~/.local/share/Trash/info/hero.trashinfo
By using this vi command, I can easily open it in the terminal and even edit it.