Browse Source

downloader: Add url property to VirtualFileHTTP

rdb 9 months ago
parent
commit
c960874d4e
2 changed files with 15 additions and 2 deletions
  1. 11 2
      panda/src/downloader/virtualFileHTTP.cxx
  2. 4 0
      panda/src/downloader/virtualFileHTTP.h

+ 11 - 2
panda/src/downloader/virtualFileHTTP.cxx

@@ -39,8 +39,7 @@ VirtualFileHTTP(VirtualFileMountHTTP *mount, const Filename &local_filename,
   _implicit_pz_file(implicit_pz_file),
   _status_only(open_flags != 0)
 {
-  URLSpec url(_mount->get_root());
-  url.set_path(_mount->get_root().get_path() + _local_filename.c_str());
+  URLSpec url = get_url();
   _channel = _mount->get_channel();
   if (_status_only) {
     _channel->get_header(url);
@@ -89,6 +88,16 @@ get_filename() const {
   }
 }
 
+/**
+ * Returns the full URL of this file.
+ */
+URLSpec VirtualFileHTTP::
+get_url() const {
+  URLSpec url(_mount->get_root());
+  url.set_path(_mount->get_root().get_path() + _local_filename.c_str());
+  return url;
+}
+
 /**
  * Returns true if this file exists, false otherwise.
  */

+ 4 - 0
panda/src/downloader/virtualFileHTTP.h

@@ -39,6 +39,7 @@ public:
 
   virtual VirtualFileSystem *get_file_system() const;
   virtual Filename get_filename() const;
+  URLSpec get_url() const;
 
   virtual bool has_file() const;
   virtual bool is_directory() const;
@@ -54,6 +55,9 @@ public:
   virtual bool read_file(std::string &result, bool auto_unwrap) const;
   virtual bool read_file(vector_uchar &result, bool auto_unwrap) const;
 
+PUBLISHED:
+  MAKE_PROPERTY(url, get_url);
+
 private:
   bool fetch_file(std::ostream *buffer_stream) const;
   std::istream *return_file(std::istream *buffer_stream, bool auto_unwrap) const;