From cd2790c9d1a7b065e286e7fafb110a50fb7067d0 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 16 Oct 2000 13:11:51 +0000 Subject: IsStorageFile without downloading whole file --- sot/source/sdstor/stg.cxx | 10 ++++++++-- sot/source/sdstor/stgelem.cxx | 12 +++++++++--- sot/source/sdstor/stgelem.hxx | 5 +++-- sot/source/sdstor/storage.cxx | 8 ++++++-- 4 files changed, 26 insertions(+), 9 deletions(-) (limited to 'sot/source') diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx index 2048f4e14c53..ca0d18d0dcd3 100644 --- a/sot/source/sdstor/stg.cxx +++ b/sot/source/sdstor/stg.cxx @@ -2,9 +2,9 @@ * * $RCSfile: stg.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mm $ $Date: 2000-10-12 16:18:50 $ + * last change: $Author: mba $ $Date: 2000-10-16 14:08:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -332,6 +332,12 @@ BOOL Storage::IsStorageFile( const String & rFileName ) return FALSE; } +BOOL Storage::IsStorageFile( SvStream* pStream ) +{ + StgHeader aHdr; + return ( pStream && aHdr.Load( *pStream ) && aHdr.Check() ); +} + // Open the storage file. If writing is permitted and the file is not // a storage file, initialize it. diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx index ef568aca861f..4a43cb207147 100644 --- a/sot/source/sdstor/stgelem.cxx +++ b/sot/source/sdstor/stgelem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: stgelem.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:56:51 $ + * last change: $Author: mba $ $Date: 2000-10-16 14:08:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -133,6 +133,12 @@ void StgHeader::Init() BOOL StgHeader::Load( StgIo& rIo ) { SvStream& r = *rIo.GetStrm(); + Load( r ); + return rIo.Good(); +} + +BOOL StgHeader::Load( SvStream& r ) +{ r.Seek( 0L ); r.Read( cSignature, 8 ); r >> aClsId // 08 Class ID @@ -151,7 +157,7 @@ BOOL StgHeader::Load( StgIo& rIo ) >> nMaster; // 48 # of additional master blocks for( short i = 0; i < 109; i++ ) r >> nMasterFAT[ i ]; - return rIo.Good(); + return r.GetErrorCode() == ERRCODE_NONE; } BOOL StgHeader::Store( StgIo& rIo ) diff --git a/sot/source/sdstor/stgelem.hxx b/sot/source/sdstor/stgelem.hxx index 8273eb35b991..47e3e2dde270 100644 --- a/sot/source/sdstor/stgelem.hxx +++ b/sot/source/sdstor/stgelem.hxx @@ -2,9 +2,9 @@ * * $RCSfile: stgelem.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:56:51 $ + * last change: $Author: mba $ $Date: 2000-10-16 14:08:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,6 +106,7 @@ public: StgHeader(); void Init(); // initialize the header BOOL Load( StgIo& ); + BOOL Load( SvStream& ); BOOL Store( StgIo& ); BOOL Check(); // check the signature and version short GetByteOrder() const { return nByteOrder; } diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 207d3a5fb103..1fb542a78628 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: storage.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mm $ $Date: 2000-10-12 16:18:51 $ + * last change: $Author: mba $ $Date: 2000-10-16 14:08:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -562,6 +562,10 @@ BOOL SotStorage::IsStorageFile( const String & rFileName ) return Storage::IsStorageFile( rFileName ); } +BOOL SotStorage::IsStorageFile( SvStream* pStream ) +{ + return Storage::IsStorageFile( pStream ); +} /************************************************************************* |* SotStorage::GetStorage() |* -- cgit v1.2.3