示例#1
0
Swift::ByteArray FileDataStore::getContent(const Swift::URL& url) {
	auto path = urlToPath(url);
	if (!boost::filesystem::exists(path)) {
		return Swift::createByteArray("");
	}
	Swift::ByteArray content;
	Swift::readByteArrayFromFile(content, path);
	return content;
}
示例#2
0
void FileDataStore::setContent(const Swift::URL& url, const Swift::ByteArray& content) {
	boost::filesystem::path path = urlToPath(url);
	std::cerr << "Saving data to " << Swift::pathToString(path) << std::endl;
	try {
		boost::filesystem::ofstream file(path);
		file << Swift::byteArrayToString(content);
	}
	catch (const boost::filesystem::filesystem_error& e) {
		std::cerr << "ERROR: " << e.what() << std::endl;
	}
}
void CRapidDownloader::download(const std::string& name)
{
	std::string tmp;
	urlToPath(name,tmp);
	this->path = fileSystem->getSpringDir() + PATH_DELIMITER +"rapid" +PATH_DELIMITER+ tmp;
	fileSystem->createSubdirs(path);
	LOG_DEBUG("%s",name.c_str());
	//first try already downloaded file, as repo master file rarely changes
	if ((fileSystem->fileExists(path)) && (fileSystem->isOlder(path,REPO_MASTER_RECHECK_TIME)) && parse())
		return;
	IDownload dl(path);
	dl.addMirror(name);
	httpDownload->download(&dl);
	parse();
}
示例#4
0
bool CRepo::getDownload(IDownload& dl)
{
	std::string tmp;
	urlToPath(repourl,tmp);
	LOG_DEBUG("%s",tmp.c_str());
	this->tmpFile = fileSystem->getSpringDir() + PATH_DELIMITER + "rapid" + PATH_DELIMITER +tmp + PATH_DELIMITER +"versions.gz";
	fileSystem->createSubdirs(tmpFile);
	//first try already downloaded file, as repo master file rarely changes
	if ((fileSystem->fileExists(tmpFile)) && fileSystem->isOlder(tmpFile,REPO_RECHECK_TIME))
		return false;
	fileSystem->createSubdirs(tmpFile);
	dl = IDownload(tmpFile);
	dl.addMirror(repourl + "/versions.gz");
	return true;
}