....It is quite portable inside the unix land....but I'm looking for a way to make it more standard.
The two following functions are 1.constructor for a disk class (for a virtual machine) and a way to execute shell directory commands of the host system.
Code:
disk::disk(string name,vm* owner)
{
/// Check if name is already in the global list
ofstream new_disk("disks/"+name+"_prop");
new_disk<<"Name: "<<name<<endl;
system(("mkdir disks/"+name).c_str());
pwd="disks/"+name+"/";
disk_of = owner;
//(*disk_of).shell(); //Works
}
Code:
void disk::command(std::string com)
{
istringstream in(com);
string test;
in>>test;
if(test=="cd")
{
in>>test;
pwd+=test; //pwd is a string containing the present working dir to carry over from calls to system();
system(("cd "+test).c_str());
}
else
{
system(("cd "+pwd+" && "+com).c_str());
}
}