mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
downloader: Implement VirtualFileHTTP::read_file()
This commit is contained in:
parent
20bdd32765
commit
84c2a18d00
@ -140,6 +140,26 @@ open_read_file(bool auto_unwrap) const {
|
|||||||
return return_file(strstream, auto_unwrap);
|
return return_file(strstream, auto_unwrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fills up the indicated pvector with the contents of the file, if it is a
|
||||||
|
* regular file. Returns true on success, false otherwise.
|
||||||
|
*/
|
||||||
|
bool VirtualFileHTTP::
|
||||||
|
read_file(vector_uchar &result, bool auto_unwrap) const {
|
||||||
|
if (_status_only) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ramfile ramfile;
|
||||||
|
if (!_channel->download_to_ram(&ramfile, false)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string &data = ramfile.get_data();
|
||||||
|
std::copy(data.begin(), data.end(), std::back_inserter(result));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads the entire file from the web server into the indicated iostream.
|
* Downloads the entire file from the web server into the indicated iostream.
|
||||||
* Returns true on success, false on failure.
|
* Returns true on success, false on failure.
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
virtual std::streamsize get_file_size() const;
|
virtual std::streamsize get_file_size() const;
|
||||||
virtual time_t get_timestamp() const;
|
virtual time_t get_timestamp() const;
|
||||||
|
|
||||||
|
virtual bool read_file(vector_uchar &result, bool auto_unwrap) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool fetch_file(std::ostream *buffer_stream) const;
|
bool fetch_file(std::ostream *buffer_stream) const;
|
||||||
std::istream *return_file(std::istream *buffer_stream, bool auto_unwrap) const;
|
std::istream *return_file(std::istream *buffer_stream, bool auto_unwrap) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user