I'm really trying to catch it.. but it won't do it...
parent
d624a2c0aa
commit
2f4b319e39
|
@ -1,6 +1,8 @@
|
|||
#include "file.h"
|
||||
|
||||
#include <cmark-gfm.h>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
File::File() {}
|
||||
|
||||
|
@ -14,6 +16,7 @@ cmark_node * File::fetch(const std::string& path)
|
|||
std::stringstream contents;
|
||||
network.fetchFile(path, &contents);
|
||||
return parser.parseStream(contents);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void File::free(cmark_node *node)
|
||||
|
|
|
@ -19,11 +19,9 @@ cmark_node * Parser::parseFile(const std::string &filePath)
|
|||
if( ( file = fopen(filePath.c_str(), "r" ) ) != NULL )
|
||||
{
|
||||
cmark_node *doc;
|
||||
|
||||
// TODO: Copy/paste cmark_parse_file() content to here, allowing me to add extensions to the parser.
|
||||
doc = cmark_parse_file(file, options);
|
||||
fclose(file);
|
||||
|
||||
return doc;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -4,10 +4,21 @@
|
|||
|
||||
// Connect to IPFS daemon
|
||||
Network::Network()
|
||||
: client("localhost", 5001)
|
||||
: client(NULL)
|
||||
{
|
||||
try {
|
||||
client = new ipfs::Client("localhost", 5001);
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
// Something else
|
||||
client = NULL;
|
||||
} catch (...) {
|
||||
std::cerr << "Something else!?" << std::endl;
|
||||
client = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Network::fetchFile(const std::string& path, std::iostream* response) {
|
||||
client.FilesGet(path, response);
|
||||
if (client != NULL)
|
||||
client->FilesGet(path, response);
|
||||
}
|
|
@ -13,9 +13,9 @@ class Network
|
|||
{
|
||||
public:
|
||||
Network();
|
||||
|
||||
|
||||
void fetchFile(const std::string& path, std::iostream* response);
|
||||
private:
|
||||
ipfs::Client client;
|
||||
ipfs::Client *client;
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue