コード例 #1
0
/**
A static method to determine if a given Contacts database exists.

@param	aFileName The Contacts database to search for.

@return ETrue if the Contacts database is found, EFalse otherwise.
*/
TBool CPplContactsFile::DatabaseExistsL(const TDesC& aFileName)
	{
	TFileName fileName;
	GetPhysicalFileNameL(fileName, aFileName);
	LocalFsL();
	return BaflUtils::FileExists(iLocalFs, fileName);
	}
コード例 #2
0
/**
Utility method used to construct physical path for a given file name

@param aPhysicalFileName in/out paramter; file name to which physical path will be append
@param aSecuredFileName secured file name
*/
void CPplContactsFile::GetPhysicalPathL(TDes& aPhysicalFileName, const TDesC& aSecuredFileName)
	{
	const TUint16 KDriveDelimiter = ':';

	// Check for the drive delimiter.
	__ASSERT_ALWAYS(aSecuredFileName.Length() > 2 &&
		aSecuredFileName[1] == KDriveDelimiter, User::Leave(KErrBadName)); 

	// Check for malformed file name (path included explicitly).
	__ASSERT_ALWAYS(aSecuredFileName.Locate('\\') == KErrNotFound, User::Leave(KErrBadName)); 

	// Get the private path from the file session.
	const TInt KMaxPrivatePathLength = 32;
	TBuf<KMaxPrivatePathLength> privatePath;
	
  	LocalFsL();
  	iLocalFs.PrivatePath(privatePath);
	
	aPhysicalFileName = aSecuredFileName.Left(KDriveNameWidth);
		
	// Set current drive.
	iDatabaseDrive = aPhysicalFileName;

	aPhysicalFileName.Append(privatePath);

  	// Make sure private path exists.
  	TInt err = iLocalFs.MkDirAll(aPhysicalFileName);
	if (err != KErrNone && err != KErrAlreadyExists)
		{
		User::Leave(err);
		}
	}
コード例 #3
0
/**
Create a new database.
*/
EXPORT_C void CPplContactsFile::CreateL(const TDesC& aFileName, TPlCreateMode aMode)
{
    TFileName fileName;
    GetPhysicalFileNameL(fileName, aFileName);

    TUint attVal;
    LocalFsL();
    TInt err = iLocalFs.Att(fileName, attVal);
    TBool fileExists = (err == KErrNone);

    if (fileExists)
    {
        switch (aMode)
        {
        case EPlLeaveIfExist:
            User::Leave(KErrAlreadyExists);
            break;

        case EPlOverwrite:
            err = iLocalFs.Delete(fileName);
            break;
        }
    }

    // If the database is not created propertly delete the database file using
    // the cleanup item.
    TFileCleanup cleanupData(iDatabase, iLocalFs, fileName);
    CleanupStack::PushL(TCleanupItem(TFileCleanup::Cleanup,&cleanupData));

    if ((err != KErrNone) && (err != KErrNotFound))
    {
        User::LeaveIfError(err);
    }

    User::LeaveIfError(iDatabase.Create(fileName, iConfigureStr));
    iItemManager->CreateTablesL();

    // If the folder exists recreate it since the database is new
    TRAP_IGNORE(TCntImageRescaleUtility::DeleteImageDirectoryL());
    TRAP_IGNORE(TCntImageRescaleUtility::CreateImageDirectoryL());

    iContactProperties.SystemTemplateManager().RecreateSystemTemplateL();

    CleanupStack::Pop(); // The TCleanupItem.

    iDatabase.Close();
}
コード例 #4
0
/**
Get a list of the contacts database on the given drive.
*/
CDesCArray* CPplContactsFile::ListL(TDriveUnit* aDriveUnit)  
	{
 	LocalFsL();
  	return CCntFileScanner::ListFilesL(iLocalFs, aDriveUnit);
	}