コード例 #1
0
int main(){
JSONNode n = read_formatted("input.json");
JSONNode n1 = read_formatted("input1.json");
test *tst = new test();
int status;
//n.set_name(abi::__cxa_demangle(typeid(*tst).name(), 0,0,&status ));
n.push_back(JSONNode("FF::Node_Subclass", abi::__cxa_demangle(typeid(*tst).name(), 0,0,&status )));
if(n1.type()==JSON_NULL){
   std::cout<<"null"<<std::endl; 
}
JSONNode n2 (JSON_NODE);
n2.set_name("Child1");
n2.push_back(JSONNode("id",1));
n.set_name("Parrent");
n.push_back(n2);
JSONNode::iterator it =n.find_nocase("String Node");
if(it->as_string()=="-1"){std::cout<<it->as_int()<<std::endl;}
it->as_int()!=-1 ? (std::cout<< "it is"<<std::endl) : (std::cout<<"Mapper Warning: processor id is -1"<<std::endl);
if (n.at("String Node")==""){
std::cout<<"ha ha ha"<<std::endl;
}
std::cout<< "This is the name: "<<n.name()<<std::endl;
n.at("String Node")="";
bool x =true;
n.push_back(JSONNode("MyBOOLNODE", x));
n["String Node"]=x;
//n.erase(n.find_nocase("String Node"));
write_formatted(n1, "out1.json");
write_formatted(n, "out.json");
JSONNode::const_iterator i =n.find_nocase("ArrayOfNumbers");
std::string strLowerCase= "ARRAYOfNUMbers"; 
std::string myTest= "ff::ff_farm<adaptive_loadbalancer, ff::ff_gatherer>";
std::transform(myTest.begin(), myTest.end(), myTest.begin(), ::tolower);
std::size_t found = myTest.find("adaptive_loadbalancer");
if (found!=std::string::npos)
  std::cout << "first 'needle' found at: " << found << '\n';

std::cout<< "here it is: " << myTest<< std::endl;
JSONNode n_ar = n.at("ArrayOfNumbers");
std::cout<<"here :"<<n_ar[0].as_int()<< std::endl;
// if (0 == strcasecmp("hello", "HELLO"))

if(strcasecmp((i->name()).c_str(), strLowerCase.c_str()) == 0)
//if(!(n2.empty()))
  std::cout<<"haha"<<i->size()<<std::endl;
std::cout<<i->name()<<std::endl;
std::cout<<((i->as_array()).begin()+1)->as_int()<<std::endl;
std::cout<<((i->as_array()).at(1)).as_int()<<std::endl;
std::cout<<((i->as_array())[1]).as_int()<<std::endl;
//std::cout<<i->as_string()<<std::endl;
//JSONNode c(JSON_ARRAY);
//c=i->as_array();
//JSONNode nk= c.at(0);
//JSONNode::const_iterator it = c.begin();
//std::cout <<nk.as_int()<<std::endl;
return 0;
}
コード例 #2
0
JSONNode LumiverseFloat::toJSON(string name) {
  JSONNode node;
  node.set_name(name);

  node.push_back(JSONNode("type", getTypeName()));
  node.push_back(JSONNode("val", m_val));
  node.push_back(JSONNode("default", m_default));
  node.push_back(JSONNode("max", m_max));
  node.push_back(JSONNode("min", m_min));

  return node;
}
コード例 #3
0
ファイル: Keyframe.cpp プロジェクト: ebshimizu/Lumiverse
JSONNode Keyframe::toJSON() {
  JSONNode keyframe;
  keyframe.push_back(JSONNode("t", (unsigned long) t));
  if (val != nullptr) {
    keyframe.push_back(val->toJSON("val"));
  }
  keyframe.push_back(JSONNode("useCurrentState", useCurrentState));

  if (timelineID != "") {
    keyframe.push_back(JSONNode("timelineID", timelineID));
    keyframe.push_back(JSONNode("timelineOffset", (unsigned long)timelineOffset));
  }

  return keyframe;
}
コード例 #4
0
ファイル: Programmer.cpp プロジェクト: ebshimizu/Lumiverse
JSONNode Programmer::toJSON() {
  JSONNode root;
  root.set_name("programmer");

  JSONNode devices;
  devices.set_name("devices");

  for (const auto& kvp : m_devices) {
    devices.push_back(kvp.second->toJSON());
  }

  root.push_back(devices);

  root.push_back(captured.toJSON("captured"));

  return root;
}
コード例 #5
0
ファイル: sframe_io.cpp プロジェクト: hoytak/SFrame
/**
 * Write column_names and column_values (as a row in the sframe) to JSONNode.
 */
void sframe_row_to_json(const std::vector<std::string>& column_names,
                        const std::vector<flexible_type>& column_values,
                        JSONNode& node) {
    DASSERT_EQ(column_names.size(), column_values.size());
    for (size_t i = 0; i < column_names.size(); ++i) {
        node.push_back(flexible_type_to_json(column_values[i], column_names[i]));
    }
}
コード例 #6
0
ファイル: Keyframe.cpp プロジェクト: ebshimizu/Lumiverse
JSONNode Event::toJSON() {
  // this is equivalent to saying "something happened here but I have no idea what it is"
  JSONNode e;
  e.set_name(_id);
  e.push_back(JSONNode("type", getType()));

  return e;
}
コード例 #7
0
ptree currencyHandler::getAllCurrenciesInJsonFormat() {
	JSONNode n(JSON_NODE);

	n.push_back(JSONNode("String Node", "String Value"));
	n.push_back(JSONNode("Integer Node", 42));
	n.push_back(JSONNode("Floating Point Node", 3.14));
	n.push_back(JSONNode("Boolean Node", true));
	std::string jc = n.write_formatted();
	std::cout << jc << std::endl;


	JSONNode n(JSON_NODE);
	n.push_back(JSONNode("RootA", "Hello World"));
	JSONNode c(JSON_ARRAY);
	c.set_name("ArrayOfNumbers");
	c.push_back(JSONNode("", 16));
	c.push_back(JSONNode("", 42));
	c.push_back(JSONNode("", 128));
	n.push_back(c);
	std::string jc = n.write_formatted();
	std::cout << jc << std::endl;


	std::string json = "{\"RootA\":\"Value in parent node\",\"ChildNode\":{\"ChildA\":\"String Value\",\"ChildB\":42}}";
	JSONNode n = libjson::parse(json);
	ParseJSON(n);


	JSONNode n(JSON_NODE);
	n.push_back(JSONNode("RootA", "Value in parent node"));
	JSONNode c(JSON_NODE);
	c.set_name("ChildNode");
	c.push_back(JSONNode("ChildA", "String Value"));
	c.push_back(JSONNode("ChildB", 42));
	n.push_back(c);
	std::string jc = n.write_formatted();
	std::cout << jc << std::endl;


	return allCurrenciesJsonArray;
}
コード例 #8
0
JSONNode *Database::CreateTable(const string &name, const vector<string> &columnNames)
{
	if (this->FindTable(name))
		return NULL;
	JSONNode table;
	table.set_name(name);
	JSONNode columns(JSON_ARRAY);
	columns.set_name("columns");
	for (auto i = columnNames.begin(); i != columnNames.end(); i++)
		columns.push_back(JSONNode("", *i));
	table.push_back(columns);
	JSONNode rows(JSON_ARRAY);
	rows.set_name("rows");
	table.push_back(rows);
	auto tables = data.find("tables");
	tables->push_back(table);
	//cout << tables->write_formatted() << endl;
	//cout << data.write_formatted() << endl;
	auto t = tables->find(name);
	return t == tables->end() ? NULL : &*t;
}
コード例 #9
0
JSONNode Rig::toJSON() {
  JSONNode root;

  stringstream ss;
  ss << LumiverseCore_VERSION_MAJOR << "." << LumiverseCore_VERSION_MINOR;

  root.push_back(JSONNode("version", ss.str()));
  root.push_back(JSONNode("refreshRate", m_refreshRate));

  JSONNode devices;
  devices.set_name("devices");
  for (auto d : m_devices) {
    devices.push_back(d->toJSON());
  }
  root.push_back(devices);

  JSONNode patches;
  patches.set_name("patches");
  for (auto& p : m_patches) {
    JSONNode patch = p.second->toJSON();
    patch.set_name(p.first);
    patches.push_back(patch);
  }
  root.push_back(patches);

  return root;
}
コード例 #10
0
bool Rig::load(string filename) {
  stop();

  // Check to see if we can load the file.
  ifstream data;
  data.open(filename, ios::in | ios::binary | ios::ate);

  if (data.is_open()) {
    reset();

    // "+ 1" for the ending
    streamoff size = data.tellg();
    char* memblock = new char[(unsigned int)size + 1];

    data.seekg(0, ios::beg);

    stringstream ss;
    ss << "Loading " << size << " bytes from " << filename;
    Logger::log(INFO, ss.str());

    data.read(memblock, size);
    data.close();

    // It's not guaranteed that the following memory after memblock is blank.
    // C-style string needs an end.
    memblock[size] = '\0';
      
    JSONNode n = libjson::parse(memblock);

	// Pass in json path with the original json nodes.
	n.push_back(JSONNode("jsonPath", filename));

    // This could get to be a large function, so let's break off into a helper.
    loadJSON(n);

    delete memblock;
    return true;
  }
  else {
    stringstream ss;
    ss << "Error opening " << filename;
    Logger::log(ERR, ss.str());

    return false;
  }
}
コード例 #11
0
ファイル: server.cpp プロジェクト: nonolith/connect
void data_server_handler::on_client_connect(websocketpp::session_ptr client){
	static const boost::regex nonolith_domain("^https?://[[:w:]\\.-]*?nonolithlabs.com$");
	static const boost::regex localhost_domain("^https?://localhost(:[[:d:]]+)?$");
	const string origin = client->get_client_header("Origin");

	if (!allowAnyOrigin 
			&& origin!=""
			&& origin!="null"
			&& !regex_match(origin, localhost_domain) 
			&& !regex_match(origin, nonolith_domain)
			){
		client->start_http(403, "Origin not allowed");
		std::cerr << "Rejected client with unknown origin " << origin << std::endl;
		return;
	}
	
	const std::string resource = client->get_resource();
	Url url(resource);
	UrlPath path(url, 1);

	try{
		if (path.leaf()){ // "/"
			client->set_header("Location", redir_url);
			client->start_http(301);
		}else if (path.matches("rest")){
			handleJSONRequest(path.sub(), client);
		}else if (path.matches("ws")){
			client->start_websocket();
		}else{
			client->start_http(404, "Not found");
		}
	}catch(std::exception& e){
		JSONNode j;
		j.push_back(JSONNode("error", e.what()));
		std::cerr << "Exception while processing request: " << e.what() <<std::endl;
		respondJSON(client, j, 500);
	}
}
コード例 #12
0
void TestSuite::TestInspectors(void){
    UnitTest::SetPrefix("TestInspectors.cpp - Inspectors");
    JSONNode test = JSONNode(JSON_NULL);
    #ifdef JSON_CASTABLE
	   assertEquals(test.as_string(), JSON_TEXT(""));
	   assertEquals(test.as_int(), 0);
	   assertEquals(test.as_float(), 0.0f);
	   assertEquals(test.as_bool(), false);
    #endif

    test = 15.5f;
    assertEquals(test.type(), JSON_NUMBER);
  #ifdef JSON_CASTABLE
    assertEquals(test.as_string(), JSON_TEXT("15.5"));
  #endif
    assertEquals(test.as_int(), 15);
    assertEquals(test.as_float(), 15.5f);
    #ifdef JSON_CASTABLE
	   assertEquals(test.as_bool(), true);
    #endif

    test = 0.0f;
    assertEquals(test.type(), JSON_NUMBER);
  #ifdef JSON_CASTABLE
    assertEquals(test.as_string(), JSON_TEXT("0"));
  #endif
    assertEquals(test.as_int(), 0);
    assertEquals(test.as_float(), 0.0f);
    #ifdef JSON_CASTABLE
	   assertEquals(test.as_bool(), false);
    #endif

    test = true;
    assertEquals(test.type(), JSON_BOOL);
    #ifdef JSON_CASTABLE
	   assertEquals(test.as_string(), JSON_TEXT("true"));
	   assertEquals(test.as_int(), 1);
	   assertEquals(test.as_float(), 1.0f);
    #endif
    assertEquals(test.as_bool(), true);

    test = false;
    assertEquals(test.type(), JSON_BOOL);
    #ifdef JSON_CASTABLE
	   assertEquals(test.as_string(), JSON_TEXT("false"));
	   assertEquals(test.as_int(), 0);
	   assertEquals(test.as_float(), 0.0f);
    #endif
    assertEquals(test.as_bool(), false);

    #ifdef JSON_CASTABLE
	   test.cast(JSON_NODE);
    #else
	   test = JSONNode(JSON_NODE);
    #endif
    assertEquals(test.type(), JSON_NODE);
    assertEquals(test.size(), 0);
    test.push_back(JSONNode(JSON_TEXT("hi"), JSON_TEXT("world")));
    test.push_back(JSONNode(JSON_TEXT("hello"), JSON_TEXT("mars")));
    test.push_back(JSONNode(JSON_TEXT("salut"), JSON_TEXT("france")));
    assertEquals(test.size(), 3);
    TestSuite::testParsingItself(test);

    #ifdef JSON_CASTABLE
	   JSONNode casted = test.as_array();
	   #ifdef JSON_UNIT_TEST
		  assertNotEquals(casted.internal, test.internal);
	   #endif
	   assertEquals(casted.type(), JSON_ARRAY);
	   assertEquals(test.type(), JSON_NODE);
	   assertEquals(test.size(), 3);
	   assertEquals(casted.size(), 3);
	   TestSuite::testParsingItself(casted);
    #endif

    UnitTest::SetPrefix("TestInspectors.cpp - Location");

    try {
	   #ifdef JSON_CASTABLE
		  assertEquals(casted.at(0), JSON_TEXT("world"));
		  assertEquals(casted.at(1), JSON_TEXT("mars"));
		  assertEquals(casted.at(2), JSON_TEXT("france"));
		  assertEquals(casted.at(0).name(), JSON_TEXT(""));
		  assertEquals(casted.at(1).name(), JSON_TEXT(""));
		  assertEquals(casted.at(2).name(), JSON_TEXT(""));
	   #endif
	   assertEquals(test.at(0), JSON_TEXT("world"));
	   assertEquals(test.at(1), JSON_TEXT("mars"));
	   assertEquals(test.at(2), JSON_TEXT("france"));
	   assertEquals(test.at(0).name(), JSON_TEXT("hi"));
	   assertEquals(test.at(1).name(), JSON_TEXT("hello"));
	   assertEquals(test.at(2).name(), JSON_TEXT("salut"));
    } catch (std::out_of_range){
	   FAIL("exception caught");
    }

    try {
	   assertEquals(test.at(JSON_TEXT("hi")), JSON_TEXT("world"));
	   assertEquals(test.at(JSON_TEXT("hello")), JSON_TEXT("mars"));
	   assertEquals(test.at(JSON_TEXT("salut")), JSON_TEXT("france"));
	   #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
		  assertEquals(test.at_nocase(JSON_TEXT("SALUT")), JSON_TEXT("france"));
		  assertEquals(test.at_nocase(JSON_TEXT("HELLO")), JSON_TEXT("mars"));
		  assertEquals(test.at_nocase(JSON_TEXT("HI")), JSON_TEXT("world"));
	   #endif
    } catch (std::out_of_range){
	   FAIL("exception caught");
    }

    assertException(test.at(JSON_TEXT("meh")), std::out_of_range);
    #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
	   assertException(test.at_nocase(JSON_TEXT("meh")), std::out_of_range);
    #endif

    assertEquals(test[JSON_TEXT("hi")], json_string(JSON_TEXT("world")));
    assertEquals(test[JSON_TEXT("hello")], json_string(JSON_TEXT("mars")));
    assertEquals(test[JSON_TEXT("salut")], json_string(JSON_TEXT("france")));
    assertEquals(test[0], JSON_TEXT("world"));
    assertEquals(test[1], JSON_TEXT("mars"));
    assertEquals(test[2], JSON_TEXT("france"));

    #ifdef JSON_ITERATORS
	  #ifdef JSON_CASTABLE
	   UnitTest::SetPrefix("TestInspectors.cpp - Iterators");
	   for(JSONNode::iterator it = casted.begin(), end = casted.end(); it != end; ++it){
		  assertEquals((*it).name(), JSON_TEXT(""));
	   }
	  #endif
    #endif

    #ifdef JSON_BINARY
	   UnitTest::SetPrefix("TestInspectors.cpp - Binary");
	   test.set_binary((const unsigned char *)"Hello World", 11);
	   assertEquals(test.type(), JSON_STRING);
	   assertEquals(test.as_string(), JSON_TEXT("SGVsbG8gV29ybGQ="));
	   assertEquals(test.as_binary(), "Hello World");
	   assertEquals(test.as_binary().size(), 11);

	   test = JSON_TEXT("Hello World");
	   assertEquals(test.type(), JSON_STRING);
	   assertEquals(test.as_string(), JSON_TEXT("Hello World"));
	   #ifdef JSON_SAFE
		  assertEquals(test.as_binary(), "");
	   #endif
    #endif

   #ifdef JSON_READ_PRIORITY
	  //This is a regression test for a bug in at()
	  json_string buffer(JSON_TEXT("{ \"myValue1\" : \"foo\", \"myValue2\" : \"bar\"}"));
	  JSONNode current = libjson::parse(buffer);
	  try {
		  JSONNode & value1 = current[JSON_TEXT("myValue1")];
		  assertEquals(value1.as_string(), JSON_TEXT("foo"));
		  JSONNode & value2 = current[JSON_TEXT("myValue2")];
		  assertEquals(value2.as_string(), JSON_TEXT("bar"));
	  } catch (...){
		  assertTrue(false);
	  }
  #endif
}
コード例 #13
0
ファイル: modulemanager.cpp プロジェクト: S1M0NE/IrcBot
std::string ModuleManager::callMethod(const std::string& sender, const std::string& reciver, const std::string& action, const std::string& jsonString, IrcConnection* connection) {
	if(reciver=="IRCCONNECTION") {
		JSONNode n;
		if(!jsonString.empty()) {
			n = libjson::parse(jsonString);
		}

		if(action == "joinChan") {
			connection->joinChan(n["channel"].as_string());
		}
		else if(action == "partChan") {
			connection->partChan(n["channel"].as_string());
		}
		else if(action == "sendQuit") {
			connection->sendQuit(n["msg"].as_string());
		}
		else if(action == "sendMessage") {
			connection->sendMessage(n["target"].as_string(), n["message"].as_string());
		}
		else if(action == "sendNotice") {
			connection->sendNotice(n["target"].as_string(), n["message"].as_string());
		}
		else if(action == "sendAction") {
			connection->sendNotice(n["target"].as_string(), n["message"].as_string());
		}
		else if(action == "sendCTCP") {
			connection->sendNotice(n["target"].as_string(), n["message"].as_string());
		}
		else if(action == "changeNick") {
			connection->changeNick(n["nick"].as_string());
		}
		else if(action == "setUserMode") {
			connection->setUserMode(n["mode"].as_string());
		}
		else if(action == "setMode") {
			connection->setMode(n["nick"].as_string(), n["mode"].as_string());
		}
		else if(action == "getChannels") {
			JSONNode n(JSON_NODE);

			std::map<std::string, IrcChannel>& channelList = connection->getChannels();
			std::map<std::string, IrcChannel>::iterator iter;
			for(iter=channelList.begin(); iter!=channelList.end(); ++iter) {
				JSONNode n2(JSON_ARRAY);
				n2.set_name(iter->first);
				n2.push_back(convertIrcChannelToJSONString(iter->second));
				n.push_back(n2);
			}
			return n.write();
		}
		else if(action == "getServer") {
			return connection->getServer();
		}
		else if(action == "getPort") {
			return Base::StringUtils::toString(connection->getPort());
		}
		else if(action == "getNick") {
			return connection->getNick();
		}
		else if(action == "getID") {
			return connection->getID();
		}
	}
	else if(reciver=="IRC") {
		JSONNode n;
		if(!jsonString.empty()) {
			n = libjson::parse(jsonString);
		}

		if(action == "disconect") {
			mIRC->disconect(n["id"].as_string());
		}
		else if(action == "disconectAll") {
			mIRC->disconectAll();
		}
	}
	else if(reciver=="MODULEMANAGER") {
		JSONNode n;
		if(!jsonString.empty()) {
			n = libjson::parse(jsonString);
		}

		if(action == "reloadModule") {
			return Base::StringUtils::toString(reloadModule(n["id"].as_string()));
		}
		else if(action == "loadModuleBinary" || action == "loadModuleScript") {
			std::map<std::string, std::string> tmpParams;

			JSONNode n2 = n["params"];
			JSONNode::iterator i = n2.begin();
			for(; i!=n2.end(); ++i) {
				tmpParams[(*i).name()] = (*i).as_string();
			}

			if(action == "loadModuleBinary") {
				return Base::StringUtils::toString(loadModuleBinary(n["id"].as_string(), n["file"].as_string(), tmpParams));
			}
			else {
				return Base::StringUtils::toString(loadModuleScript(n["id"].as_string(), n["file"].as_string(), tmpParams));
			}
		}
		else if(action == "unloadModule") {
			unloadModule(n["id"].as_string());
		}
	}
	else {
		Module* module = getModule(reciver);
		if(!module) {
			return "";
		}

		if(module->type == Module::BINARY) {
			if(!module->binaryModule.onInternalMessage) {
				return "";
			}

			return module->binaryModule.onInternalMessage(sender.c_str(), action.c_str(), jsonString.c_str(), connection);
		}
	}

	return "";
}
コード例 #14
0
ファイル: TarUtil.cpp プロジェクト: pyotr777/kportal
ResponseCode UpdateRepoTagOfTarball(std::string pathTarball, std::string repo, std::string tag, std::string &idImage) {
  TAR *tar = NULL;
  int ret = 0;
  int th_found = 0;
  int exitcode = 0;
//  char tmp_filepath[] = P_tmpdir "/libtar-tmpfile-XXXXXX";
  //gen path to upload image
  char* tmp_imagepath = tempnam (FileUtils::GetPathDir(pathTarball).c_str(), "imageDirTmp_");
  std::string pathTmpDir = tmp_imagepath;
  free(tmp_imagepath);
  std::cout << "path tmp dir: " << pathTmpDir << std::endl;

  int tmp_fd = -1;

  ret = tar_open(&tar, (char*)pathTarball.c_str(), NULL, O_RDONLY, 0, 0);
  if (ret != 0) {
	fprintf(stdout, "Fail to open file: %s\n", pathTarball.c_str());
//	return FILE_ACTION_ERROR;
	exitcode = 2;
  }
	if (exitcode == 0) {
		if (tar_extract_all(tar, (char*)pathTmpDir.c_str()) != 0) {
            fprintf(stderr, "Fail to extract file: %s\n", pathTarball.c_str());
			exitcode = 2;
		}
	}

	if (exitcode == 0) {
		ret = tar_close(tar);
		if (ret != 0) {
			perror("Failed to close tar file.");
			exitcode = 2;
		}
		tar = NULL;
	}

  //Modify repository file
  if (exitcode == 0) {
	char buf[BUFSIZ];
	ssize_t n_buf = 0;
	FILE *tmpfile = NULL;

	std::ifstream in((pathTmpDir + "/" + REPOSITORIES_FILE).c_str(), std::ios::binary);
	std::string info((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());

	JSONNode n;
	try
	{
		n = libjson::parse(info);
	} catch(const std::invalid_argument& e) {
		std::cerr << "Invalid argument: " << e.what() << '\n';
//		return FILE_ACTION_ERROR;
		exitcode = 1;
	}
	if(exitcode == 0){
		JSONNode::const_iterator i = n.begin();
		//if (i != n.end() && i -> name() == TAG_SERVICE_STR && i -> type() != JSON_ARRAY && i -> type() != JSON_NODE)
		if (i != n.end() && i -> type() == JSON_NODE){
			JSONNode tag_id_node = i->as_node();
			i = tag_id_node.begin();
			if (i != n.end() && i -> type() != JSON_ARRAY && i -> type() != JSON_NODE){
				idImage = i->as_string();
			}else{
				std::cout << "Tarball format error.\n";
		//		return FILE_ACTION_ERROR;
				exitcode = 1;
			}
		}
	}else{
		std::cout << "Tarball format error.\n";
//			return FILE_ACTION_ERROR;
		exitcode = 1;
		}
	}

	if(exitcode == 0){
		JSONNode newRepoNode(JSON_NODE);
		newRepoNode.set_name(repo);
		newRepoNode.push_back(JSONNode(tag, idImage));

		JSONNode newNode;
		newNode.push_back(newRepoNode);
		std::string content = newNode.write();

		FILE * pFile;

		if (exitcode == 0) {
			pFile = fopen ((pathTmpDir + "/" + REPOSITORIES_FILE).c_str() , "w");
			if (pFile == NULL) {
			   printf("Error opening file %s\n", (pathTmpDir + "/" + REPOSITORIES_FILE).c_str());
		//	   return FILE_ACTION_ERROR;
			   exitcode = 1;
			}
		}

		if (exitcode == 0) {
			fwrite (content.c_str() , sizeof(char), content.size(), pFile);
			fclose (pFile);
			printf("content tmp file: %s\n", content.c_str());
		}
	}

	if (exitcode == 0) {
		remove (pathTarball.c_str());
		ret = tar_open(&tar, (char*)pathTarball.c_str(), NULL, O_WRONLY | O_CREAT, 0600, 0);
		if (ret != 0) {
		  fprintf(stderr, "Fail to open file: %s\n", pathTarball.c_str());
		//	  return FILE_ACTION_ERROR;
		  exitcode = 2;
		}

		if (exitcode == 0) {
			if (tar_append_tree(tar, (char*)pathTmpDir.c_str(), "") != 0) {
			  fprintf(stderr, "Fail to compress file: %s\n", pathTarball.c_str());
		//		  return FILE_ACTION_ERROR;
			  exitcode = 2;
			}
		}

		if (exitcode == 0) {
			ret = tar_close(tar);
			if (ret != 0) {
				perror("Failed to close tar file.");
				exitcode = 2;
			} else {
				tar = NULL;
			}
		}
	}
	std::cout << "delete_folder_tree: " << pathTmpDir.c_str() << std::endl;
	if (FileUtils::delete_folder_tree(pathTmpDir.c_str())) {
		fprintf(stderr, "Fail to delete temp dir: %s\n", pathTmpDir.c_str());
	}

	if (exitcode == 0) {
		return FILE_ACTION_SUCCESS;
	} else if (exitcode == 1) {
		return FILE_ACTION_ERROR;
	} else {
		return DATA_ERROR;
	}
}