示例#1
0
void FileCommands::remfile(FileSystemUser* fileSystem, string file) {
	FileObject* fo = fileSystem->getFileObject();
	if(!fo->containsObject(file)) {
		notFoundFile(file);
		return;
	}
	string sys = fileSystem->getSystem();
	int t = fo->getObject(file);
	sys.erase(t, fo->getPos() - t - 1);
	fileSystem->setNewSystem(sys);
	fo->remObj(file);	
}
示例#2
0
void FileCommands::remdir(FileSystemUser* fileSystem, string dir) {
	FileObject* fo = fileSystem->getFileObject();
	if(!fo->containsObject(dir)) {
		notFoundDir(dir);
		return;
	}
	string sys = fileSystem->getSystem();
	int t = fo->getObject(dir);
	cout<<"t: "<<t<<" pos:"<<fo->getPos()<<endl;
	if(fo->getPos() == fo->getBeginPos()) {
		fo->setEndPos();
	}
	sys.erase(t, fo->getPos() - t);
	fileSystem->setNewSystem(sys);	
	fo->remObj(dir);
}