From c960874d4ee06303ff7ea439d0f6abe44b70ca77 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 24 Feb 2025 20:07:31 +0100 Subject: [PATCH] downloader: Add url property to VirtualFileHTTP --- panda/src/downloader/virtualFileHTTP.cxx | 13 +++++++++++-- panda/src/downloader/virtualFileHTTP.h | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/panda/src/downloader/virtualFileHTTP.cxx b/panda/src/downloader/virtualFileHTTP.cxx index ee36ea95bd..d96a948ae4 100644 --- a/panda/src/downloader/virtualFileHTTP.cxx +++ b/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. */ diff --git a/panda/src/downloader/virtualFileHTTP.h b/panda/src/downloader/virtualFileHTTP.h index 49e5f4bd19..ed9bdfa04e 100644 --- a/panda/src/downloader/virtualFileHTTP.h +++ b/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;