|
From: Frank V. C. <fr...@us...> - 2001-04-10 21:17:53
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv31067/src/libs/Persist
Modified Files:
SchemaCatalog.cpp SchemaSponsor.cpp
Log Message:
Added profile and schema location support
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** SchemaCatalog.cpp 2001/04/08 12:59:07 1.2
--- SchemaCatalog.cpp 2001/04/10 21:17:50 1.3
***************
*** 43,46 ****
--- 43,51 ----
extern "C"
{
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <errno.h>
#include <gdbm.h>
}
***************
*** 48,59 ****
namespace corelinux
{
! static FrameworkString nameKey("Name");
! static FrameworkString locationKey("Location");
! static FrameworkString guidKey("GUID");
!
! static FrameworkString catName;
! static FrameworkString catLocation;
! static FrameworkString storesLocation;
//
// Constructor
--- 53,71 ----
namespace corelinux
{
! // Property constants
+ const FrameworkString nameKey("Name");
+ const FrameworkString locationKey("Location");
+ const FrameworkString collectionType("Collection");
+ const FrameworkString guidKey("GUID");
+
+ // Environmental constants
+
+ const FrameworkString homeEnviron("HOME");
+ const FrameworkString catEnviron("CLFW++HOME");
+ const FrameworkString catLocation("/.clfw++");
+ const FrameworkString schemaLocation("/schemas");
+ const FrameworkString catName("schemcat");
+
//
// Constructor
***************
*** 64,67 ****
--- 76,83 ----
StoreCatalog()
{
+ //
+ // Initialize the catalog
+ //
+ resolveLocations();
}
***************
*** 74,78 ****
StoreCatalog( aType )
{
! ; // do nothing
}
--- 90,97 ----
StoreCatalog( aType )
{
! //
! // Initialize the catalog
! //
! resolveLocations();
}
***************
*** 170,173 ****
--- 189,267 ----
SchemaPtr aSchm( NULLPTR );
return aSchm;
+ }
+
+ //
+ // Setup environmental information for this caller
+ //
+
+ void SchemaCatalog::resolveLocations( void )
+ {
+ //
+ // Resolve home location for catalog
+ //
+
+ CharPtr aVal
+ (
+ Environment::getEnvironmentValue( catEnviron.getValue() )
+ );
+
+ if( aVal == NULLPTR )
+ {
+ aVal = Environment::getEnvironmentValue( homeEnviron.getValue() );
+
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ theCatalogRoot = aVal;
+ theCatalogRoot += catLocation;
+
+ if( std::mkdir
+ (
+ theCatalogRoot.getValue(),S_IRWXU
+ ) != 0 )
+ {
+
+ if( Thread::getKernelError() != EEXIST )
+ {
+ throw Exception( theCatalogRoot.getValue(), LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ //
+ // Resolve default location for schemas
+ //
+
+ theStoresRoot = theCatalogRoot;
+ theStoresRoot += schemaLocation;
+
+ if( std::mkdir
+ (
+ theStoresRoot.getValue(),S_IRWXU
+ ) != 0 )
+ {
+ if( Thread::getKernelError() != EEXIST )
+ {
+ throw Exception( theStoresRoot.getValue(), LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+ }
+ else
+ {
+ ; // do nothing
+ }
}
Index: SchemaSponsor.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaSponsor.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SchemaSponsor.cpp 2001/04/08 10:50:43 1.1
--- SchemaSponsor.cpp 2001/04/10 21:17:50 1.2
***************
*** 35,38 ****
--- 35,40 ----
namespace corelinux
{
+ StoreCatalogPtr SchemaSponsor::theStoreCatalog( NULLPTR );
+
//
// Constructor
***************
*** 85,90 ****
StoreCatalogPtr SchemaSponsor::getCatalog( void ) const
{
! SchemaCatalogPtr aSchemaCtlg( NULLPTR );
! return aSchemaCtlg;
}
--- 87,99 ----
StoreCatalogPtr SchemaSponsor::getCatalog( void ) const
{
! if( theStoreCatalog == NULLPTR )
! {
! theStoreCatalog = new SchemaCatalog;
! }
! else
! {
! ; // do nothing
! }
! return theStoreCatalog;
}
|