aboutsummaryrefslogtreecommitdiff
path: root/GithubAPI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'GithubAPI.cpp')
-rw-r--r--GithubAPI.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/GithubAPI.cpp b/GithubAPI.cpp
index a60a5c2..9f52e86 100644
--- a/GithubAPI.cpp
+++ b/GithubAPI.cpp
@@ -1,6 +1,8 @@
#include "GithubAPI.hpp"
#include "json.hpp"
+#include <curl/curl.h>
+#include <fstream>
#include <iostream>
GithubAPI::GithubAPI(std::string username)
@@ -44,6 +46,22 @@ size_t GithubAPI::GetAvatarBuffer(std::vector<unsigned char> &avatar_buffer) {
return avatar_buffer.size();
}
+bool GithubAPI::AvatarToFile(std::string filename) {
+ std::vector<unsigned char> avatar_buffer;
+
+ if (GetAvatarBuffer(avatar_buffer) == 0) {
+ return false;
+ }
+
+ {
+ std::ofstream avout(filename, std::ios::out | std::ios::binary);
+ avout.write((char const *)avatar_buffer.data(), avatar_buffer.size());
+ avout.close();
+ }
+
+ return true;
+}
+
bool GithubAPI::ResetCURL() {
if (curl == nullptr) {
return false;