15 #include "virtualFileMountHTTP.h"
16 #include "virtualFileHTTP.h"
17 #include "virtualFileSystem.h"
29 VirtualFileMountHTTP::
30 VirtualFileMountHTTP(
const URLSpec &root, HTTPClient *http) :
36 string path = _root.get_path();
37 if (!path.empty() && path[path.length() - 1] !=
'/') {
48 VirtualFileMountHTTP::
49 ~VirtualFileMountHTTP() {
67 void VirtualFileMountHTTP::
68 reload_vfs_mount_url() {
73 while (n < vfs->get_num_mounts()) {
75 if (mount->is_of_type(VirtualFileMountHTTP::get_class_type())) {
86 PRC_DESC(
"vfs-mount-url http://site/path[:port] mount-point [options]"));
88 int num_unique_values = mounts.get_num_unique_values();
89 for (
int i = 0; i < num_unique_values; i++) {
90 string mount_desc = mounts.get_unique_value(i);
92 size_t space = mount_desc.rfind(
' ');
93 if (space == string::npos) {
94 downloader_cat.warning()
95 <<
"No space in vfs-mount-url descriptor: " << mount_desc <<
"\n";
98 string mount_point = mount_desc.substr(space + 1);
99 while (space > 0 && isspace(mount_desc[space - 1])) {
102 mount_desc = mount_desc.substr(0, space);
105 space = mount_desc.rfind(
' ');
106 if (space != string::npos) {
108 options = mount_point;
109 mount_point = mount_desc.substr(space + 1);
110 while (space > 0 && isspace(mount_desc[space - 1])) {
113 mount_desc = mount_desc.substr(0, space);
124 size_t q = options.find(
',', p);
125 while (q != string::npos) {
129 q = options.find(
',', p);
134 vfs->mount(mount, mount_point, flags);
145 bool VirtualFileMountHTTP::
156 bool VirtualFileMountHTTP::
157 is_directory(
const Filename &)
const {
167 bool VirtualFileMountHTTP::
168 is_regular_file(
const Filename &)
const {
183 make_virtual_file(const
Filename &local_filename,
184 const
Filename &original_filename,
bool implicit_pz_file,
186 PT(VirtualFileHTTP) vfile =
187 new VirtualFileHTTP(this, local_filename, implicit_pz_file, open_flags);
188 vfile->set_original_filename(original_filename);
201 istream *VirtualFileMountHTTP::
202 open_read_file(const
Filename &)
const {
215 streamsize VirtualFileMountHTTP::
216 get_file_size(
const Filename &, istream *)
const {
226 streamsize VirtualFileMountHTTP::
227 get_file_size(
const Filename &)
const {
245 time_t VirtualFileMountHTTP::
246 get_timestamp(
const Filename &)
const {
258 bool VirtualFileMountHTTP::
259 scan_directory(vector_string &,
const Filename &)
const {
268 void VirtualFileMountHTTP::
269 output(ostream &out)
const {
279 PT(HTTPChannel) VirtualFileMountHTTP::
281 PT(HTTPChannel) channel;
282 _channels_lock.acquire();
284 if (!_channels.empty()) {
288 channel = _channels.back();
289 _channels.pop_back();
292 channel = _http->make_channel(
true);
295 _channels_lock.release();
306 void VirtualFileMountHTTP::
307 recycle_channel(HTTPChannel *channel) {
308 _channels_lock.acquire();
309 _channels.push_back(channel);
310 _channels_lock.release();
313 #endif // HAVE_OPENSSL
A container for a URL, e.g.
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
static void parse_option(const string &option, int &flags, string &password)
Parses one of the option flags in the options list on the vfs-mount Config.prc line.
The abstract base class for a file or directory within the VirtualFileSystem.
This class is similar to ConfigVariable, but it reports its value as a list of strings.
The name of a file, such as a texture file or an Egg file.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
int unmount(Multifile *multifile)
Unmounts all appearances of the indicated Multifile from the file system.
The abstract base class for a mount definition used within a VirtualFileSystem.
static string expand_string(const string &str)
Reads the string, looking for environment variable names marked by a $.
TypeHandle is the identifier used to differentiate C++ class types.