Streams and stores

There a various ways to store the state of a group of related objects. A working solution would be to use a conventional file system directory in which each of the objects is a file, or, if it contains objects itself, a subdirectory. Unfortunately, this is an inconvenient solution, for example when copying the document. Experience has shown that dividing one logical file into multiple physical files leads to problems.

The solution used by the OLE2-developers was to use compound files. Simply put, a compound file is filesystem in a file. Just like a file system consists of directories and files, a compound file consists of streams and storages.

Bonobo follows this OLE2-approach, and defines interfaces for stores and streams:

Next to these interfaces, Bonobo also provides an implementation for compound files. This implementation is called libefs. In the next sections GNOME::Stream, GNOME::Storage and libefs will be discussed.

Stores

The GNOME::Storage interface specifies the 'directory-part' of the filesystem-in-a-file. The following methods are exported (bonobo-storage.idl):
		interface Storage : Unknown {

			typedef long OpenMode;
			const OpenMode READ  = 1;
			const OpenMode WRITE = 2;
			const OpenMode DENY_READ = 4;
			const OpenMode DENY_WRITE = 8;

			exception NameExists {};
			exception NotFound {};
			exception NoPermission {};

			typedef sequence<string> directory_list;

			Stream create_stream (in string path) raises (NameExists);
			Stream open_stream   (in string path, in OpenMode mode) raises (NotFound, NoPermission);
			Storage create_storage (in string path) raises (NameExists);
			Storage open_storage   (in string path, in OpenMode mode) raises (NotFound, NoPermission);
			void copy_to (in Storage target);
			void rename (in string path_name, in string new_path_name) raises (NameExists, NotFound);
			void commit ();
			directory_list list_contents (in string path) raises (NotFound);
			void erase (in string path) raises (NotFound);
		};
	

Stream

	module GNOME {
		interface Stream : Unknown {
			typedef sequence<octet> iobuf;

			enum SeekType {
				SEEK_SET,
				SEEK_CUR,
				SEEK_END
			};

			long read     (in long count, out iobuf buffer);
			long write    (in iobuf buffer);
			long seek     (in long offset, in SeekType whence);
			void truncate (in long length);
			void copy_to  (in string dest, in long bytes,
					inout long read, inout long written);
			void commit ();
			void close ();
			boolean eos ();
			long length ();
		};
	};