ClientHandler/ClientHandler.cpp
HttpMessage ClientHandler::closePackage(HttpMessage msg) {
	HttpMessage message;
	if (!FileSystem::Directory::exists("../TestFileServer/" + msg.findValue("dir"))) {
		message.addAttribute(HttpMessage::attribute("type", "error"));
		message.addAttribute(HttpMessage::attribute("fromAddr", msg.findValue("toAddr")));
		message.addAttribute(HttpMessage::attribute("toAddr", msg.findValue("fromAddr")));
		std::string str = "\n  no package with the name " + msg.findValue("dir");
		message.addBody(str);
		return message;
	}
	std::string name = "../TestFileServer/" + msg.findValue("dir") + "/" + msg.findValue("dir") + "." + getCurrentDate() + ".xml";
	XmlDocument doc(name, XmlDocument::file);
	sPtr close = makeTaggedElement("close");
	close->addChild(makeTextElement("true"));
	doc.xmlRoot()->addChild(close);
	FileSystem::File::remove(name);
	FileSystem::File xml(name);
	xml.open(FileSystem::File::out, FileSystem::File::text);
	if (xml.isGood()) xml.putLine(doc.toString());
	xml.close();
	return message;
}
// ----------------< close a package to prevent addditional updating >-------------
< close a package to prevent addditional updating >
< close a package to prevent addditional updating >
HttpMessage ClientHandler::closePackage(HttpMessage msg) {
	HttpMessage message;
	if (!FileSystem::Directory::exists("../TestFileServer/" + msg.findValue("dir"))) {
		message.addAttribute(HttpMessage::attribute("type", "error"));
		message.addAttribute(HttpMessage::attribute("fromAddr", msg.findValue("toAddr")));
		message.addAttribute(HttpMessage::attribute("toAddr", msg.findValue("fromAddr")));
		std::string str = "\n  no package with the name " + msg.findValue("dir");
		message.addBody(str);
		return message;
	}
	std::string name = "../TestFileServer/" + msg.findValue("dir") + "/" + msg.findValue("dir") + "." + getCurrentDate() + ".xml";
	XmlDocument doc(name, XmlDocument::file);
	sPtr close = makeTaggedElement("close");
	close->addChild(makeTextElement("true"));
	doc.xmlRoot()->addChild(close);
	FileSystem::File::remove(name);
	FileSystem::File xml(name);
	xml.open(FileSystem::File::out, FileSystem::File::text);
	if (xml.isGood()) xml.putLine(doc.toString());
	xml.close();
	return message;
}
HttpMessage ClientHandler :: closePackage ( HttpMessage msg ) { HttpMessage message ; if ( ! FileSystem :: Directory :: exists ( " " + msg . findValue ( " " ) ) ) { message . addAttribute ( HttpMessage :: attribute ( " " , " " ) ) ; message . addAttribute ( HttpMessage :: attribute ( " " , msg . findValue ( " " ) ) ) ; message . addAttribute ( HttpMessage :: attribute ( " " , msg . findValue ( " " ) ) ) ; std :: string str = " \n " + msg . findValue ( " " ) ; message . addBody ( str ) ; return message ; } std :: string name = " " + msg . findValue ( " " ) + " " + msg . findValue ( " " ) + " " + getCurrentDate ( ) + " " ; XmlDocument doc ( name , XmlDocument :: file ) ; sPtr close = makeTaggedElement ( " " ) ; close -> addChild ( makeTextElement ( " " ) ) ; doc . xmlRoot ( ) -> addChild ( close ) ; FileSystem :: File :: remove ( name ) ; FileSystem :: File xml ( name ) ; xml . open ( FileSystem :: File :: out , FileSystem :: File :: text ) ; if ( xml . isGood ( ) ) xml . putLine ( doc . toString ( ) ) ; xml . close ( ) ; return message ; }
< close a package to prevent addditional updating >
< close a package to prevent addditional updating >