Example #1
0
//============================================================================
//		NDBHandlePool::Open : Open the database.
//----------------------------------------------------------------------------
NStatus NDBHandlePool::Open(const NFile &theFile, NDBFlags theFlags, const NString &theVFS)
{	NDBHandlePtr		dbHandle;
	NStatus				theErr;



	// Validate our parameters and state
	NN_ASSERT(theFile.IsValid());
	NN_ASSERT(!IsOpen());
	


	// Update our state
	mFile  = theFile;
	mFlags = theFlags;
	mVFS   = theVFS;



	// Create the initial connection
	//
	// The initial connection allows us to test that we can actually open the
	// database, and may be all that we need if we're only to connect once.
	theErr = CreateConnection(dbHandle);
	NN_ASSERT_NOERR(theErr);

	mIsOpen = (dbHandle != NULL);

	if (mIsOpen)
		mPool.PushBack(dbHandle);

	return(theErr);
}
Example #2
0
//============================================================================
//		NFileUtilities::GetDirectory : Get a standard directory.
//----------------------------------------------------------------------------
NFile NFileUtilities::GetDirectory(NDirectoryLocation theLocation, const NString &fileName, NDirectoryDomain theDomain, bool canCreate)
{	NFile		theFile;



	// Get the directory
	theFile = NTargetFile::GetDirectory(theDomain, theLocation);
	theFile.ResolveTarget();

	if (!fileName.IsEmpty() && theFile.IsValid())
		{
		theFile = theFile.GetChild(fileName);
		theFile.ResolveTarget();
		}



	// Create it if necessary
	if (!theFile.Exists() && canCreate)
		theFile.CreateDirectory();

	return(theFile);
}