From: vsr Date: Mon, 30 Dec 2019 09:01:33 +0000 (+0300) Subject: bos #16517 Implement method CanOpen() to check that study file is accessible and... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9bd30afc90b5669de3beae66832b7b335deb7b2c;p=modules%2Fyacs.git bos #16517 Implement method CanOpen() to check that study file is accessible and readable --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 5ddf9b081..9488ca344 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -574,6 +574,13 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin */ boolean Open (in URLPath aStudyUrl) raises (SALOME::SALOME_Exception); +/*! \brief Check if study can be opened + + Tries to open and read given url. + \param aStudyUrl The path to the study +*/ + boolean CanOpen (in URLPath aStudyUrl); + /*! \brief Saving the study in a file (or files). Saves a study. diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 2a14971d7..8f12cf461 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -132,10 +132,16 @@ bool SALOMEDS_Study::Open(const std::string& theStudyUrl) return false; std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl ); - if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) ) - return false; + return _corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ); +} - return true; +bool SALOMEDS_Study::CanOpen(const std::string& theStudyUrl) +{ + if(CORBA::is_nil(_corba_impl)) + return false; + std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl ); + + return _corba_impl->CanOpen( (wchar_t*)wtheStudyUrl.c_str() ); } bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII) diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index c6dc58486..3f8de21eb 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -56,6 +56,7 @@ public: virtual void Init(); virtual bool Open(const std::string& theStudyUrl); + virtual bool CanOpen(const std::string& theStudyUrl); virtual bool Save(bool theMultiFile, bool theASCII); virtual bool SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index e5a26a9fb..b7f8654d3 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -413,6 +413,21 @@ bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl) return res; } +//============================================================================ +/*! Function : CanOpen + * Purpose : Check that a Study can be opened + */ +//============================================================================ +bool SALOMEDS_Study_i::CanOpen(const wchar_t* aWUrl) +{ + SALOMEDS::Locker lock; + + Unexpect aCatch(SalomeException); + std::string aUrl = Kernel_Utils::encode_s(aWUrl); + + return SALOMEDSImpl_Study().Open( aUrl ); +} + PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA() { return _poa; diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index f16e029a7..ad39fde89 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -74,13 +74,20 @@ public: virtual void Init(); virtual void Clear(); - //! method to Open a Study + //! method to open a Study /*! \param char* arguments, the study URL - \return Study_ptr arguments + \return bool arguments */ virtual bool Open(const wchar_t* aStudyUrl) throw (SALOME::SALOME_Exception); + //! method to check that a Study can be opened + /*! + \param char* arguments, the study URL + \return bool arguments + */ + virtual bool CanOpen(const wchar_t* aStudyUrl); + //! method to save a Study virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII); diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 7a9c7ba4c..e696d66eb 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -53,6 +53,7 @@ public: virtual void Clear() = 0; virtual bool Open(const std::string& theStudyUrl) = 0; + virtual bool CanOpen(const std::string& theStudyUrl) = 0; virtual std::string GetPersistentReference() = 0; virtual bool IsEmpty() = 0;