Skip to content

Commit

Permalink
adding method to class entrepot to get the current user_interaction o…
Browse files Browse the repository at this point in the history
…bject if any
  • Loading branch information
Edrusb committed Mar 29, 2024
1 parent 6d811bd commit 551c7d8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libdar/entrepot.hpp
Expand Up @@ -130,6 +130,9 @@ namespace libdar
/// \note method open() just above uses the specified user_interaction provided as its first argument
virtual void change_user_interaction(const std::shared_ptr<user_interaction> & new_dialog) {};

/// get the current user_interaction if the implementation reocrded it at construction time (may be nullptr if not)
virtual std::shared_ptr<user_interaction> get_current_user_interaction() const { return std::shared_ptr<user_interaction>(); };

/// routines to read existing files in the current directory (see set_location() / set_root() methods)

/// \param[in] dir_details, if set to true, use read_dir_next() with the isdir argument, else
Expand Down
22 changes: 22 additions & 0 deletions src/libdar/entrepot_libcurl.cpp
Expand Up @@ -170,6 +170,28 @@ namespace libdar
#endif
}

shared_ptr<user_interaction> entrepot_libcurl::get_current_user_interaction() const
{
#if defined ( LIBCURL_AVAILABLE ) && defined ( LIBTHREADAR_AVAILABLE )
shared_ptr<user_interaction> ret;

NLS_SWAP_IN;
try
{
ret = pimpl->get_current_user_interaction();
}
catch(...)
{
NLS_SWAP_OUT;
throw;
}
NLS_SWAP_OUT;

return ret;
#else
throw Efeature("libcurl library");
#endif
}

void entrepot_libcurl::read_dir_reset() const
{
Expand Down
1 change: 1 addition & 0 deletions src/libdar/entrepot_libcurl.hpp
Expand Up @@ -81,6 +81,7 @@ namespace libdar
virtual const path & get_location() const override;
virtual const path & get_root() const override;
virtual void change_user_interaction(const std::shared_ptr<user_interaction> & new_dialog) override;
virtual std::shared_ptr<user_interaction> get_current_user_interaction() const override;
virtual void read_dir_reset() const override;
virtual bool read_dir_next(std::string & filename) const override;
virtual void read_dir_reset_dirinfo() const override;
Expand Down
1 change: 1 addition & 0 deletions src/libdar/i_entrepot_libcurl.hpp
Expand Up @@ -84,6 +84,7 @@ namespace libdar
/// like ftp://www.some.where:8021//tmp/sub/dir
virtual std::string get_url() const override { return base_URL + get_full_path().display_without_root(); };
virtual void change_user_interaction(const std::shared_ptr<user_interaction> & new_dialog) override { change_ui(new_dialog); };
virtual std::shared_ptr<user_interaction> get_current_user_interaction() const { return get_pointer(); };
virtual void read_dir_reset() const override { set_current_dir(false); };
virtual bool read_dir_next(std::string & filename) const override;
virtual void read_dir_reset_dirinfo() const override { set_current_dir(true); };
Expand Down

0 comments on commit 551c7d8

Please sign in to comment.