1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/dev5-libmisc-ipfs-http-c

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
Внести вклад в разработку кода
Синхронизировать код
Отмена
Подсказка: Поскольку Git не поддерживает пустые директории, создание директории приведёт к созданию пустого файла .keep.
Loading...
README.md

Это клиентская библиотека C++ для работы с HTTP API, основанная на IPFS (межпланетной файловой системе). В библиотеке реализованы следующие функции:

  • files.ls;
  • files.read;
  • files.rm;
  • files.stat;
  • files.write;
  • add;
  • get;
  • универсальный интерфейс для http-get.

Демо:

#include <libmisc-ipfs-http-c.h>

int main(int argc, char **argv)
{
	Log::setTrace();
	shared_ptr<IpfsHttpClient> ipfs(new IpfsHttpClient("http://127.0.0.1:5001/api/v0/"));
	int err;
	string desc;
	//
	ipfs->filesWrite("/home/dev5/ipfs-hello-world0.txt", "/ipfs-hello-world0.txt", err, desc); /* ipfs files write. */
	ipfs->filesWrite("/home/dev5/ipfs-hello-world1.txt", "/ipfs-hello-world1.txt", err, desc);
	shared_ptr<list<shared_ptr<IpfsFileLsRspEntry>>> lis = ipfs->filesLs("/", err, desc);
	for (auto& it : *lis)
	{
		LOG_DEBUG("%s", it->toString().c_str())
	}
	LOG_DEBUG("content: %s", ipfs->filesRead("/ipfs-hello-world0.txt", err, desc).c_str()) /* ipfs files read. */
	ipfs->filesRm("/ipfs-hello-world0.txt", err, desc); /* ipfs files rm */
	LOG_DEBUG("stat: %s", ipfs->filesStat("/ipfs-hello-world1.txt", err, desc)->toString().c_str()) /* ipfs files stat. */
	shared_ptr<IpfsAddRsp> add = ipfs->add("/home/dev5/ipfs-hello-world0.txt", err, desc);
	LOG_DEBUG("add: %s", add->toString().c_str()) /* ipfs add. */
	LOG_DEBUG("get: %s", ipfs->get(add->hash, err, desc).c_str()) /* ipfs get. */
	//
	LOG_DEBUG("%s", ipfs->httpGet("swarm/peers", err, desc).c_str()) /* ipfs xxx. */
	return EXIT_SUCCESS;
}

Зависимости:

  • libmisc;
  • libcurl;
  • libarchive.

Компиляция:

export PLAT=LINUX
export LIB_CURL=/home/dev5/tools/curl-7.66.0
export LIB_ARCHIVE=/home/dev5/tools/libarchive-3.4.0
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
export CXX_FLAG="-g3 -O3"
export MAKE_J="-j3"
ls ./
libmisc-cpp libmisc-ipfs-http-c
chmod 775 */*.sh
cd libmisc-ipfs-http-c;./build.sh

Комментарии ( 0 )

Вы можете оставить комментарий после Вход в систему

Введение

Создание клиентской библиотеки на C++ для работы с HTTP API IPFS (межпланетной файловой системы). Развернуть Свернуть
AGPL-3.0
Отмена

Обновления

Пока нет обновлений

Участники

все

Недавние действия

Загрузить больше
Больше нет результатов для загрузки
1
https://api.gitlife.ru/oschina-mirror/dev5-libmisc-ipfs-http-c.git
git@api.gitlife.ru:oschina-mirror/dev5-libmisc-ipfs-http-c.git
oschina-mirror
dev5-libmisc-ipfs-http-c
dev5-libmisc-ipfs-http-c
master