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/>.
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"
34 #include <curlpp/cURLpp.hpp>
35 #include <curlpp/Easy.hpp>
39 const std::string protocol_host_separator
= "://";
47 std::vector
<std::string
> split_path
;
52 URL(const fragrant::URL
& right
);
55 class cURLDirectory
: public Directory
58 cURLDirectory(std::string durl
,
59 std::map
<std::string
, archive_function
>);
62 std::string
getFile(std::string filename
);
63 std::vector
<std::string
> getListing(std::string folder
);
65 Directory
* getDirectory(std::vector
<std::string
> paths
);
69 int callback(cURLpp::Easy
* ptr
, char* data
, int size
, int nmemb
);
71 std::string
fetchData(std::string url
);
73 std::string data_received
;
75 std::map
<std::string
, archive_function
> archive_funcs
;
77 static cURLpp::Cleanup cleanup_class
;