Exemplo n.º 1
0
void Layout::start_element(const string& local_name,
   const AttributeSet &attrs)
{
   Widget* w = NULL;

   if (local_name == "layout") {
      root = new RootWidget(attrs);
      parse_path.push(root);
      return;
   }
   else if (local_name == "font") {
      const string name = attrs.get<string>("name");
      const string file = attrs.get<string>("file");     
      const bool drop_shadow = attrs.get<bool>("drop-shadow", false);
      const int size = attrs.get<int>("size", 14);

      theme.add_font(name,
         gui::load_font(file, size, FONT_NORMAL, drop_shadow));

      return;
   }
   else if (local_name == "window")
      w = new Window(attrs);
   else if (local_name == "button")
      w = new Button(attrs);
   else if (local_name == "label")
      w = new Label(attrs);
   else if (local_name == "throttle-meter")
      w = new ThrottleMeter(attrs);
   else if (local_name == "toggle-bar")
      w = new ToggleBar(attrs);
   else if (local_name == "toggle-button")
      w = new ToggleButton(attrs);
   else if (local_name == "canvas3d")
      w = new Canvas3D(attrs);
   else if (local_name == "image-button")
      w = new ImageButton(attrs);
   else if (local_name == "from-bottom")
      w = new FromBottom(attrs);
   else
      throw runtime_error("Unexpected " + local_name);

   Widget* parent = parse_path.top();
   if (ContainerWidget* c = dynamic_cast<ContainerWidget*>(parent)) {
      c->add_child(w);
   }
   else {
      throw runtime_error("Widget " + parse_path.str()
         + " cannot contain children");
   }      

   parse_path.push(w);

   widgets[parse_path.str()] = w;
}
Exemplo n.º 2
0
void Layout::end_element(const string& local_name)
{
   if (local_name != "font")
      parse_path.pop();
}
Exemplo n.º 3
0
void DirectoryManager::Dir_Create(char* direc)
{
	try {
		//Bitmap 갱신 함수를 통해 비트맵 갱신
		string path = direc;

		Inode inode;
		
		// inode 설정
		//비트맵들 1로 설정 ..
		
		inode.mode = "d777";

		// int EmptyDataNum = dBlockBitmap.getEmpty();
		// int EmptyInodeNum = inodeBitmap.getEmpty();

		ppp.push("DC");
		// 절대 경로 분석
		PathManager& pm = *PathManager::getInstance();
		vector<string> arr;

		pm.doAnalyzeFolder(direc, arr);
		

		int n = arr.size(); // n: 경로상의 폴더 개수?

		string currDir = arr[n - 1]; // 현재디렉토리 이름(내가 만들 디렉토리)
		string topDir = ""; // 상위디렉토리 이름

		if (strcmp(direc, "/") == 0)
			topDir = arr[n - 1]; // 현재디렉토리 이름(내가 만들 디렉토리)
		else
			topDir = arr[n - 2];
		//addDirectory 

		int currDirInode = -1;
		int topDirInode = -1;
		
		if(path == "/")
			topDirInode = returnInodeNum((char*)topDir.c_str());
		else
			topDirInode = returnInodeNum(stringToCharArr((*pm.getAllAbsPath(direc))[n - 2]));


		FileSystem& fs = *FileSystem::getInstance();

		//memcpy(dB.data, (void *)content.c_str, sizeof(content)); 


		Directory curDr;
		Directory topDr;

		char time[13];
		getCurrentTime(time);

		char linkCount[2] = "0";

		//Inode 정보 설정
		inode.blocks = "1";
		inode.linksCount = linkCount;
		inode.mtime = time;
		inode.size = "0";
		inode.time = time;
		inode.ctime = time;

		if (strcmp(direc, "/") != 0 && topDr.isExist((char*)currDir.c_str()) == true)
		{
			cout << "dir exist" << endl;
			return;
		}//디렉토리 중복 검사
		ppp.push("2");
		currDirInode = fs.writeFS_Dir(inode);
		
		ppp.push("3");
		


		if (strcmp(direc, "/") != 0)
		{
			topDr = *returnDir(topDirInode);
			Entry e;
			ppp.push("4");
			e.inodeNum = currDirInode;
			strcpy(e.name, currDir.c_str());
			topDr.addDirectory(e, topDirInode);
			ppp.push("5");
		}
		curDr.setInodeNum(currDirInode, topDirInode);
		Entry *enList = curDr.entryList;

		string content = ".,";

		//cout << enList[0].inodeNum << endl;
		content.append(to_string(enList[0].inodeNum));
		content.append(";..," + to_string(enList[1].inodeNum));
		content.append(";");
		//데이터블록에 데이터 추가(idx는 datablock Index)
		
		//할당받은 블록 받아오기
		char* tmpBlockList = fs.inodeBlock->getDataBlockList(currDirInode);
		int idx = atoi(tmpBlockList);

		//할당받은 블록 리셋
		fs.resetDataBlock(&idx, 1);
		
		//다시 쓴다
		int assignedIdx = fs.writeFS((char*)content.c_str());
		char dataBlockList[] = "   \0";
		itoa(assignedIdx, dataBlockList);

		char size[4];
		memcpy(size, stringToCharArr(to_string(content.length())), strlen(stringToCharArr(to_string(content.length())))+1);

		//링크 정보 다시 읽어와야 함
		inode = fs.readFS(currDirInode);

		//Inode 정보 설정
		getCurrentTime(time);

		inode.blocks = "1";
		inode.mtime = time;
		inode.size = size;
		inode.dataBlockList = dataBlockList;

		ppp.push("6");
		//데이터 블록 추가 후 업데이트
		fs.updateInode_writeFile(currDirInode, inode);
		ppp.push("7");
	}
	catch (char* msg)
	{
		cerr << "error : " << msg << endl;
	}
}