Help making a shell
Nov 9, 2014 at 12:08am UTC
Hello so I am a bit rusty, and by that I mean like SUPER rusty.
I have this program that creates a file system and then I need to make the shell to interact with it. I need help with my default constructor as odd as that may sound.
Here is my Shell class please help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
#include<vector>
#include"Sdrive.h"
#include"Filesys.h"
using namespace std;
class Shell: public Filesys
{
Public :
Shell(string filename, int blocksize, int numberofblocks);
int dir();// lists all files
int add(string file);// add a new file using input from the keyboard
int del(string file);// deletes the file
int type(string file);//lists the contents of file
int copy(string file1, string file2);//copies file1 to file2
};
Shell:: Shell(string filename, int blocksize, int numberofblocks)
{
}
int Shell:: del(string file)
{
if (remove(file) != 1)
{
cout << "Error deleting file" << endl;
}
else
cout << "File removed successfully" << endl;
return 1;
}
int Shell::dir()
{
vector<string> flist=ls();
for (i=0; i<flist.size(); i++)
{
cout << flist[i] << endl;
}
}
int Shell:: add (string filename)
{
int ecode = newfile(filename);
if (ecode < 1)
{
return 0;
}
cout << "Enter data followed by a ^" << endl;
string buffer;
char x;
cin.get(x);
while (x != 'n' )
{
buffer += x;
cin.get(x);
}
vector <string> blocks =block(buffer, getblocksize);
for (int i = 0; i < blocks.size(); i++)
{
int blockid = addblock(filename, blocks[i]);
}
return 1;
}
Topic archived. No new replies allowed.