user.h

来自「本科作业虚拟linux操作系统下的文教系统」· C头文件 代码 · 共 87 行

H
87
字号


#ifndef User_tag
#define User_tag

class User
{
	int uid;
	std::string name;
	std::string passwd;
	std::vector<Nfile*> flist;

public:
	User(std::string nm,std::string pass,int ud)
	{
		name=nm;
		passwd=pass;
		uid=ud;
	}
	int getUid()
	{
		return uid;
	}
	std::string getName()
	{
		return name;
	}
	std::string getPass()
	{
		return passwd;
	}
	void addFile(Nfile*file)
	{
		flist.push_back(file);
	}

	int Isexist(std::string name)
	{
		for(std::vector<Nfile*>::iterator it=flist.begin();it!=flist.end();it++)
		{
			if((*it)->getName()==name)
				return 1;
		}
		return 0;
	}
	Nfile* getFileByName(std::string nm)
	{
		for(std::vector<Nfile*>::iterator it=flist.begin();it!=flist.end();it++)
		{
			if((*it)->getName()==nm)
			{
				
				return *it;
			}
		}

		return NULL;

	}

	int closeFileByName(std::string nm)
	{
		for(std::vector<Nfile*>::iterator it=flist.begin();it!=flist.end();it++)
		{
			if((*it)->getName()==nm)
			{
				flist.erase(it);

				
				return 1;
			}
		}
		return 0;
	}

	void closeAllFiles()
	{
		for(std::vector<Nfile*>::iterator it=flist.begin();it!=flist.end();it++)
		{
				flist.erase(it);
		}

	}

};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?