这是我正在制作的OS的代码,我停留在主程序上。 如何完成if语句? 这些类是sdisk,Filesys,Shell和Table
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <fstream>
#include <cmath>
using namespace std;
---- sdisk类----
class Sdisk{
public:
Sdisk(string diskname, int numberofblocks, int blocksize);
int getblock(int blocknumber, string& buffer);
int putblock(int blocknumber, string buffer);
int getnumberofblocks();
int getblocksize();
string getdiskname();
private:
string diskname;
int numberofblocks;
int blocksize;
};
---- filesys类----
class Filesys:public Sdisk
{
public :
Filesys(string filename, int numberofblocks, int blocksize);
int fsclose();
int fssynch();
int newfile(string file);
int rmfile(string file);
int getfirstblock(string file);
int addblock(string file, string buffer);
int delblock(string file, int blocknumber);
int readblock(string file, int blocknumber, string& buffer);
int writeblock(string file, int blocknumber, string buffer);
int nextblock(string file, int blocknumber);
vector<string> block(string buffer, int b);
vector<string> ls();
private :
int rootsize;
int fatsize;
vector<string> filename;
vector<int> firstblock;
vector<int> fat;
};
---- shell类-
class Shell:public Filesys{
public:
Shell(string diskname,int blocksize, int numberofblocks);
int dir();
int add(string file);
int del(string file);
int type(string file);
int copy(string file1,string file2);
};
----表类----
class Table:public Filesys{
public:
Table(string filename,int numberofblocks,int blocksize,string flatfile,string indexfile);
int Build_Table(string input_file);
int Search(string value);
private:
string flatfile;
string indexfile;
int numberofrecords;
int IndexSearch(string value);
};
---这是我遇到麻烦的地方--- -----我如何调用ls()函数----
int main()
{
Sdisk sdisk = Sdisk("sdisk.txt", 256, 128);
Filesys fsys = Filesys("sdisk.txt", 256, 128);
Shell shell = Shell("sdisk.txt", 256, 128);
Table table = Table("disk1", 256, 128, "flatfile", "indexfile");
table.Build_Table("data.txt");
string s;
string command = "go";
string op1, op2;
while (command != "quit")
{
command.clear();
op1.clear();
op2.clear();
cout << "$";
getline(cin, s);
int firstblank = s.find(' ');
if (firstblank < s.length()) s[firstblank] = '#';
int secondblank = s.find(' ');
command = s.substr(0, firstblank);
if (firstblank < s.length())
op1 = s.substr(firstblank + 1, secondblank - firstblank - 1);
if (secondblank < s.length())
op2 = s.substr(secondblank + 1);
if (command == "dir")
{
// use the ls function
}
if (command == "search")
{
// The variable op1 is the date
}
if (command == "add")
{
// The variable op1 is the new file
table.newfile(op1);
}
if (command == "del")
{
// The variable op1 is the file
}
if (command == "type")
{
// The variable op1 is the file
}
if (command == "copy")
{
// The variable op1 is the source file and the variable op2 is the destination file.
}
}
return 0;
}