Wat
[potpourri.git] / include / core / cURLDirectory.h
blobf5cf8d318a5cc35e7c1d1c363595aeba40a9c3ea
1 // Copyright 2008 Brian Caine
3 // This file is part of Potpourri.
5 // Potpourri is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Potpourri is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTIBILITY of FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Potpourri. If not, see <http://www.gnu.org/licenses/>.
19 // NOTES:
20 // A Directory that gets shit via curl
21 // curl is a bitchin' library
22 // and curlpp is a bitchin' binding for a bitchin' library
24 #ifndef __CURLDIRECTORY_H
25 #define __CURLDIRECTORY_H
27 #include "../../include/core/Directory.h"
28 #include "../../include/plugins/media/Archive.h"
30 #include <map>
31 #include <vector>
32 #include <string>
34 #include <curlpp/cURLpp.hpp>
35 #include <curlpp/Easy.hpp>
37 namespace fragrant
39 const std::string protocol_host_separator = "://";
41 struct URL
43 std::string protocol;
44 std::string host;
45 std::string path;
47 std::vector<std::string> split_path;
48 std::string raw_url;
50 std::string getURL();
51 URL(std::string);
52 URL(const fragrant::URL& right);
55 class cURLDirectory : public Directory
57 public:
58 cURLDirectory(std::string durl,
59 std::map<std::string, archive_function>);
60 ~cURLDirectory();
62 std::string getFile(std::string filename);
63 std::vector<std::string> getListing(std::string folder);
65 Directory* getDirectory(std::vector<std::string> paths);
67 private:
69 int callback(cURLpp::Easy* ptr, char* data, int size, int nmemb);
71 std::string fetchData(std::string url);
73 std::string data_received;
74 URL url;
75 std::map<std::string, archive_function> archive_funcs;
77 static cURLpp::Cleanup cleanup_class;
81 #endif