i'm currently using chdir() in my program, and I got it to work...however... I don't know how to cd to the root directory, or how to cd up one directory for that matter....here's the code...
Code:#include <iostream>
#include <stdlib.h>
#include <string>
#include <unistd.h>
void main()
{
char cmd[100] = " ";
char dir[100] = " ";
char * pch;
int cmdLength, cmdCounter;
int dirCounter = 0;
cout << "Please enter command: ";
cin.getline(cmd, 100);
while (strcmp (cmd, "exit") !=0)
{
if((cmd[0] == 'c') && (cmd[1] == 'd') && (cmd[2] == ' '))
{
cout << "I'm here corey..." << endl;
cmdLength = strlen(cmd);
cout << cmdLength << endl;
for(cmdCounter=3; cmdCounter < cmdLength; cmdCounter++)
{
cout << dir[dirCounter];
dir[dirCounter] = cmd[cmdCounter];
dirCounter++;
}
chdir(dir);
cout << "Please enter command: ";
cin.getline(cmd,100);
}
else
{
system (cmd);
cout << "Please enter command: ";
cin.getline(cmd,100);
}
}
exit(1);
}