1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032565: Foundation Classes, OSD_FileSystem - expose interface for registering global protocols

Added methods OSD_FileSystem::AddDefaultProtocol()/::RemoveDefaultProtocol()
and fixed misleading description of OSD_FileSystemSelector::AddProtocol().
This commit is contained in:
kgv 2021-09-09 21:04:21 +03:00 committed by smoskvin
parent 8a17a8bb45
commit 36d21f1a1a
3 changed files with 32 additions and 3 deletions

View File

@ -54,6 +54,26 @@ const Handle(OSD_FileSystem)& OSD_FileSystem::DefaultFileSystem()
return aDefSystem;
}
//=======================================================================
// function : AddDefaultProtocol
// purpose :
//=======================================================================
void OSD_FileSystem::AddDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred)
{
Handle(OSD_FileSystemSelector) aFileSelector = Handle(OSD_FileSystemSelector)::DownCast (DefaultFileSystem());
aFileSelector->AddProtocol (theFileSystem, theIsPreferred);
}
//=======================================================================
// function : RemoveDefaultProtocol
// purpose :
//=======================================================================
void OSD_FileSystem::RemoveDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem)
{
Handle(OSD_FileSystemSelector) aFileSelector = Handle(OSD_FileSystemSelector)::DownCast (DefaultFileSystem());
aFileSelector->RemoveProtocol (theFileSystem);
}
//=======================================================================
// function : openIStream
// purpose :

View File

@ -24,9 +24,18 @@ class OSD_FileSystem : public Standard_Transient
DEFINE_STANDARD_RTTIEXT(OSD_FileSystem, Standard_Transient)
public:
//! Returns a global file system, which a selector between registered file systems.
//! Returns a global file system, which a selector between registered file systems (OSD_FileSystemSelector).
Standard_EXPORT static const Handle(OSD_FileSystem)& DefaultFileSystem();
//! Registers file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem().
//! Note that registering protocols is not thread-safe operation and expected to be done once at application startup.
//! @param[in] theFileSystem file system to register
//! @param[in] theIsPreferred add to the beginning of the list when TRUE, or add to the end otherwise
Standard_EXPORT static void AddDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred = false);
//! Unregisters file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem().
Standard_EXPORT static void RemoveDefaultProtocol (const Handle(OSD_FileSystem)& theFileSystem);
public:
//! Returns TRUE if URL defines a supported protocol.

View File

@ -27,12 +27,12 @@ public:
//! Constructor.
OSD_FileSystemSelector() {}
//! Registers file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem().
//! Registers file system within this selector.
//! @param theFileSystem [in] file system to register
//! @param theIsPreferred [in] add to the beginning of the list when TRUE, or add to the end otherwise
Standard_EXPORT void AddProtocol (const Handle(OSD_FileSystem)& theFileSystem, bool theIsPreferred = false);
//! Unregisters file system within the global file system selector returned by OSD_FileSystem::DefaultFileSystem().
//! Unregisters file system within this selector.
Standard_EXPORT void RemoveProtocol (const Handle(OSD_FileSystem)& theFileSystem);
public: