|
|||||||||||||||||||||||||
|
|||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionStructured storage is something which, when done using the plain Windows API, seems overly complicated; much more so than is needed. The aim of this article is to briefly introduce you to the concepts behind structured storage, and then provide a helper class to simplify its usage. The idea behind structured storage is that a single file can itself contain a basic filing system. Its main reason for existence was to help with OLE documents: embedded objects are simply save as separate 'streams' within the single file. Here is a diagram which illustrates this concept:
Although this technology is primarily for use in OLE, it can be put to other uses. In order to help you access the functionality of this powerful tool easily, I have created a helper class, namely CSSFile, to aid in the creation, and modification of structured storage files. UpdatesIf you have used this class previously, you will most likely wish to update your code to use the latest version. Here are the main differences (note that the interface remains the same):
Usage of the classWhilst the class is fairly straightforward, I have listed the functions and their interfaces below to aid your usage of the class: Function: CreateSSFile(...)Parametersfilename - the name of the file to be created mode - the mode of access for the file Return value'true' if the file was successfully created Function: OpenSSFile(...)Parametersfilename - the name of the file to open mode - the mode of access for the file Return value'true' if the file was successfully opened Function: Attach(...)ParameterspNews - the storage this object should hook Return valueThe previous storage being managed by the object Function: Detach(...)No ParametersReturn valueThe previous storage being managed by the object Function: Close()No ParametersNo Return valueFunction: CreateStorage(...)Parametersname - the name of the storage to create (will be created within the current path inside the root storage) enter - enter the storage after creation? mode - the mode of access for the storage Return value'true' if the storage was successfully created Function: EnterStorage(...)Parametersname - the name of the storage to open mode - the mode of access for the storage Return value'true' if the storage was successfully opened Function: ExitStorage(...)No ParametersReturn value'true' if the storage path was moved up a level Function: CreateStream(...)Parametersname - the name of the stream to create sf - a COleStreamFile into which the stream is opened mode - the mode of access for the stream Return value'true' if the stream was successfully created Function: OpenStream(...)Parametersname - the name of the stream to open sf - a COleStreamFile into which the stream is opened mode - the mode of access for the stream Return value'true' if the stream was successfully opened Function: DestroyElement(...)Parametersname - the name of the element to destroy Return value'true' if the element was successfully destroyed Function: GetRootStorage()No ParametersReturn valueThe root of the currently open storage Function: GetCurrentStorage()No ParametersReturn valueThe currently open storage Function: IsOpen()No ParametersReturn valueWhether a file is currently being managed by the object Function: GetFilename()No ParametersReturn valueThe filename of the root storage Function: GetPath(...)ParametersSepChar - the character to be used to separate the paths in the storages (i.e. Windows uses '\' for standard file system paths). Return valueThe current path within the storage (including the filename of the root storage).
|
||||||||||||||||||||||||