本文整理汇总了C++中CFileMan::RmDir方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileMan::RmDir方法的具体用法?C++ CFileMan::RmDir怎么用?C++ CFileMan::RmDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileMan
的用法示例。
在下文中一共展示了CFileMan::RmDir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResetAndCreateNewMailStoreL
// Reset Mail Store(Mail2) so that old messages are deleted when new index file created..
void CMsvIndexContext::ResetAndCreateNewMailStoreL(TBool aDelete)
{
CFileMan* fileMan = CFileMan::NewL(iServer.FileSession());
CleanupStack::PushL(fileMan);
if(aDelete)
{
//Check if the mailfolder exists..
if(BaflUtils::FileExists(iServer.FileSession(), iMessageFolder))
{
// Remove the readonly attribute..
(void)fileMan->Attribs(iMessageFolder,0, KEntryAttReadOnly, TTime(0), CFileMan::ERecurse);
// Remove old message store if exists..
User::LeaveIfError(fileMan->RmDir(iMessageFolder));
}
}
// Create the folder for the message store
TInt err = iServer.FileSession().MkDirAll(iMessageFolder);
if(err != KErrAlreadyExists)
{
User::LeaveIfError(err);
}
CleanupStack::PopAndDestroy(fileMan);
}
示例2: ExecuteActionL
void CMtfTestActionDeleteMessageStore::ExecuteActionL()
{
TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteMessageStore);
HBufC* paramStorePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0));
TPtrC Store = paramStorePath->Des();
RFs fs;
fs.Connect();
CDictionaryFileStore* store = CDictionaryFileStore::SystemLC(fs);
const TUid KUidMsvMessageDriveStream = {0x1000163E};
if (store->IsPresentL(KUidMsvMessageDriveStream))
{
store->RemoveL(KUidMsvMessageDriveStream);
store->CommitL();
}
CleanupStack::PopAndDestroy(store);
CFileMan* fileMan = CFileMan::NewL(fs);
CleanupStack::PushL(fileMan);
TInt error;
error = fileMan->RmDir(Store);
error = fs.RmDir(Store);
if (!(error==KErrNotFound||error==KErrNone))
{
User::Leave(KErrAccessDenied);
}
CleanupStack::PopAndDestroy(fileMan);
fs.Close();
TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteMessageStore);
TestCase().ActionCompletedL(*this);
}
示例3: RemoveDirectoryL
// ---------------------------------------------------------------------------
// Utility function for removing a directory
// ---------------------------------------------------------------------------
//
void CNcdStorageManager::RemoveDirectoryL( RFs& aFileSession,
const TDesC& aDirectory )
{
CFileMan* fileman = CFileMan::NewL( aFileSession );
CleanupStack::PushL( fileman );
User::LeaveIfError( fileman->RmDir( aDirectory ) );
CleanupStack::PopAndDestroy( fileman );
}
示例4: DoDeleteTestDirL
//The function deletes a directory, identified by the aFullPath argument.
//The function leaves if the delete operation error is different than KErrNone and KErrNotFound.
static void DoDeleteTestDirL(CFileMan& aFm, const TDesC& aFullPath)
{
TInt err = aFm.Attribs(aFullPath, 0, KEntryAttReadOnly, TTime(0));
if(err == KErrNone)
{
err = aFm.RmDir(aFullPath);
}
if(err != KErrNone && err != KErrNotFound)
{
User::Leave(err);
}
}
示例5: CleanAllL
// ---------------------------------------------------------------------------
// Remove the entire prfw directory
// ---------------------------------------------------------------------------
//
EXPORT_C void CXIMPTestFileTool::CleanAllL()
{
RFs fs;
fs.Connect();
CleanupClosePushL( fs );
CFileMan* fileMan = CFileMan::NewL( fs );
CleanupStack::PushL( fileMan );
// remove the files and the directory
fileMan->RmDir( KFileToolMainDirFull );
CleanupStack::PopAndDestroy( 2 ); // fileman, fs
}
示例6: CleanScheduleFolderL
EXPORT_C void CSchSendTestUtils::CleanScheduleFolderL()
{
CFileMan* fileMan = CFileMan::NewL(iFs);
CleanupStack::PushL(fileMan);
TParse parse;
TFileName fileName(_L("\\system\\schedules\\"));
TBuf<4> drive=_L("C:");
parse.Set(fileName, &drive, NULL);
TInt error = fileMan->RmDir(parse.DriveAndPath());
error = iFs.RmDir(parse.DriveAndPath());
if (!(error==KErrNotFound||error==KErrNone))
{
TPtrC driveAndPath = parse.DriveAndPath();
Printf(_L("Directory %S cannot be removed. Error=%d"), &driveAndPath, error);
Printf(_L("Please ensure directory is not in use.\n"));
User::Leave(error);
}
iFs.MkDirAll(parse.DriveAndPath());
CleanupStack::PopAndDestroy(fileMan);
}
示例7: DeleteTestDirL
static void DeleteTestDirL()
{
RFs fsSession;
TInt err = fsSession.Connect();
if(err == KErrNone)
{
CleanupClosePushL(fsSession);
RDebug::Print(_L("Deleting \"%S\" directory.\n"), &KOpaqueDirectory);
CFileMan* fileMan = CFileMan::NewL(fsSession);
CleanupStack::PushL(fileMan);
TInt err = fileMan->RmDir(KOpaqueDirectory);
if(err == KErrPathNotFound)
{
err = KErrNone;
}
User::LeaveIfError(err);
CleanupStack::PopAndDestroy(fileMan);
CleanupStack::PopAndDestroy(&fsSession);
}
else
{
RDebug::Print(_L("Error %d connecting file session. Directory: %S.\n"), err, &KOpaqueDirectory);
}
}
示例8: IntegrityDeleteFileL
void IntegrityDeleteFileL(const TDesC& aPath, CIntegrityTreeLeaf* aLeaf, RFs& aFs,
RLoader& aLoader, CFileMan& aFileMan)
{
_LIT(KSysBin, "\\sys\\bin");
RBuf name;
name.CreateL(aPath, KMaxFileName);
CleanupClosePushL(name);
name.Append(aLeaf->Name());
TEntry entry;
TInt err = aFs.Entry(name, entry);
if (err == KErrNone)
{
aFs.SetAtt(name, 0, KEntryAttReadOnly);
if(entry.IsDir())
{
// Make sure to append slash before calling RmDir - otherwise it deletes the parent directory
if (name[name.Length()-1] != KPathDelimiter)
{
name.Append(KPathDelimiter);
}
User::LeaveIfError(aFileMan.RmDir(name));
}
else
{
if ( aLeaf->Type() == EBackupFile ) // Implies a commit operation is in progress
{
if ( IsBinary(entry) )
{
// Forming the file name so the renamed file can be under sys/bin
// for special delete mechanism using RLoader::Delete
RBuf tmpName;
TParsePtrC fileName(name);
tmpName.CreateL(name.Length() + KSysBin.iTypeLength);
CleanupClosePushL(tmpName);
tmpName.Append(fileName.Drive());
tmpName.Append(KSysBin);
tmpName.Append(fileName.Path());
tmpName.Append(fileName.NameAndExt());
DEBUG_PRINTF3(_L("Integrity Services - Renaming %S to %S"), &name, &tmpName);
aFileMan.Rename(name,tmpName,CFileMan::EOverWrite);
User::LeaveIfError(aLoader.Delete(tmpName)); // Using RLoader delete for paged binaries
DEBUG_PRINTF2(_L("Integrity Services - Deleted renamed file %S"), &tmpName);
// prune the directory tree if possible
RemoveDirectoryTreeL(aFs, tmpName);
CleanupStack::PopAndDestroy(&tmpName);
}
else
{
User::LeaveIfError(aFileMan.Delete(name));
}
}
else
{
// Need to use RLoader Delete which can be used during deletion of Added files during Rollback
User::LeaveIfError(aLoader.Delete(name));
}
}
// prune the directory tree if possible
RemoveDirectoryTreeL(aFs, name);
}
else if(err != KErrNotFound && err != KErrPathNotFound)
{
DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name);
User::Leave(err);
}
else
{
DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name);
// Check for any renamed files to move it to sys/bin for special delete mechanism
RBuf tmpName;
TParsePtrC fileName(name);
tmpName.CreateL(name.Length() + KSysBin.iTypeLength);
CleanupClosePushL(tmpName);
tmpName.Append(fileName.Drive());
tmpName.Append(KSysBin);
tmpName.Append(fileName.Path());
tmpName.Append(fileName.NameAndExt());
DEBUG_PRINTF2(_L("Integrity Services - Removing %S renamed binary files if any"), &tmpName);
aLoader.Delete(tmpName);
// prune the directory tree if possible
RemoveDirectoryTreeL(aFs, tmpName);
CleanupStack::PopAndDestroy(&tmpName);
}
CleanupStack::PopAndDestroy(&name);
}
示例9: TestCreateContactWithoutImagesFoldeL
LOCAL_C void TestCreateContactWithoutImagesFoldeL()
{
test.Next(_L("TestCreateContactWithoutImagesFoldeL"));
SETUP;
// Delete the images folder and all contents
TInt drive;
#ifdef __WINS__
TInt err = DriveInfo::GetDefaultDrive(DriveInfo::EDefaultPhoneMemory, drive);
#else
TInt err = DriveInfo::GetDefaultDrive(DriveInfo::EDefaultMassStorage, drive);
#endif
// Do not leave with this error. The phone does not have to have this support
if (err == KErrNone)
{
// Get the root path in this drive to create
// to create the images directory
TPath dir;
User::LeaveIfError(PathInfo::GetRootPath(dir, drive));
dir.Append(KImagesFolder);
CFileMan* fileMan = CFileMan::NewL(fs);
err = fileMan->RmDir(dir); // err not used
delete fileMan;
}
else
{
test.Printf(_L("Could not remove the images folder\n"));
return;
}
// Create an image and store an image without the images dir available
CContactItem *contact = CContactItem::NewLC(KUidContactCard);
CContactItemField *newField = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldCodImage);
newField->SetMapping(KUidContactFieldVCardMapUnknown);
newField->TextStorage()->SetTextL(KSrcImage());
contact->AddFieldL(*newField); // Takes ownership
CleanupStack::Pop(newField);
TContactItemId id = cntClient.CreateContactL(*contact);
CleanupStack::PopAndDestroy(contact);
// View definition to read image field
CContactItemViewDef *imageViewDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, CContactItemViewDef::EMaskHiddenFields);
imageViewDef->AddL(KUidContactFieldCodImage);
contact = cntClient.ReadContactL(imageViewDef ,id);
CleanupStack::PopAndDestroy(imageViewDef); // imageViewDef
TInt index = contact->CardFields().Find(KUidContactFieldCodImage, KUidContactFieldVCardMapUnknown);
// Test image field found
test(index != KErrNotFound);
CContactItemField& field = contact->CardFields()[index];
TPtrC imagePtr = field.TextStorage()->Text();
// Image path should not change
test(imagePtr.Compare(KSrcImage()) == 0);
cntClient.CloseContact(id);
delete contact;
TEAR_DOWN;
}
示例10: CleanMessageFolderL
EXPORT_C void CMsvTestUtils::CleanMessageFolderL()
{
//Kill the message server if its running
_LIT(KMsvServerPattern, "!MsvServer*");
TFindProcess findprocess(KMsvServerPattern);
TFullName name;
if(findprocess.Next(name)==KErrNone)
{
RProcess process;
User::LeaveIfError(process.Open(findprocess));
process.Kill(KErrCancel) ;
process.Close() ;
}
// Wait for the server to close before trying to remove
// the message folder
TInt loopCount = 0;
FOREVER
{
TFindServer find(KMsvServerPattern);
if (find.Next(name) != KErrNone)
break;
User::After(1000000);
++loopCount;
if(loopCount > 5)
{
User::Invariant();
}
}
// remove the drive from the system ini
CDictionaryFileStore* store = CDictionaryFileStore::SystemLC(iFs);
if (store->IsPresentL(KUidMsvMessageDriveStream))
{
store->RemoveL(KUidMsvMessageDriveStream);
store->CommitL();
}
CleanupStack::PopAndDestroy(); // store
CFileMan* fileMan = CFileMan::NewL(iFs);
CleanupStack::PushL(fileMan);
TParse parse;
TInt error;
TFileName fileName(KMsvDefaultFolder2);
TChar driveChar=FileSession().GetSystemDriveChar();
TBuf<2> systemDrive = iDriveName;
parse.Set(fileName, &systemDrive, NULL);
error = fileMan->RmDir(parse.DriveAndPath());
error = iFs.RmDir(parse.DriveAndPath());
if (!(error==KErrNotFound||error==KErrNone || error == KErrPathNotFound))
{
TPtrC driveAndPath = parse.DriveAndPath();
Printf(_L("Directory %S cannot be removed. "), &driveAndPath);
Printf(_L("Please ensure directory is not in use.\n"));
User::Leave(KErrAccessDenied);
}
//delete DBs in C:, D: and E:.
TPath pathNameTemp(iDriveName);
pathNameTemp.Append(KDbFileName);
RSqlDatabase::Delete(pathNameTemp);
pathNameTemp = _L("D:");
pathNameTemp.Append(KDbFileName);
RSqlDatabase::Delete(pathNameTemp);
pathNameTemp = _L("E:");
pathNameTemp.Append(KDbFileName);
RSqlDatabase::Delete(pathNameTemp);
// delete "StoreInit.tmp"
TPath pathName(iDriveName);
pathName.Append(KStoreInitFileName);
iFs.Delete(pathName);
CleanupStack::PopAndDestroy(fileMan);
}
示例11: DoL
static void DoL()
{
RFile policyConfigFile;
RFile certsFile;
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
TInt err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_policy.txt"), EFileStreamText | EFileRead);
TBuf8<256> oldPolicy;
TBuf8<256> newPolicy;
TBuf8<256> oldWarningsMode;
TBuf8<256> newWarningsMode;
bool updateCerts = false;
bool removeCerts = false;
if (err == KErrNone)
{
policyConfigFile.Read(oldPolicy);
policyConfigFile.Close();
}
else
{
err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\new_policy.txt"), EFileStreamText | EFileRead);
if (err == KErrNone)
{
policyConfigFile.Read(newPolicy);
policyConfigFile.Close();
}
}
err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_warnings_mode.txt"), EFileStreamText | EFileRead);
if (err == KErrNone)
{
policyConfigFile.Read(oldWarningsMode);
policyConfigFile.Close();
}
else
{
err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\new_warnings_mode.txt"), EFileStreamText | EFileRead);
if (err == KErrNone)
{
policyConfigFile.Read(newWarningsMode);
policyConfigFile.Close();
}
}
err = certsFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\update_certs"), EFileStreamText | EFileRead);
if (err == KErrNone)
{
updateCerts = true;
certsFile.Close();
}
err = certsFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\remove_certs"), EFileStreamText | EFileRead);
if (err == KErrNone)
{
removeCerts = true;
certsFile.Close();
}
if (oldPolicy.Length() > 0)
{
// restore the old policy
CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity);
HBufC* tmp = HBufC::NewLC(oldPolicy.Length());
TPtr tmpPtr(tmp->Des());
tmpPtr.Copy(oldPolicy);
repository->Set(KPolicy, tmpPtr);
CleanupStack::PopAndDestroy(tmp);
CleanupStack::PopAndDestroy(repository);
// remove the directory
CFileMan* fileMan = CFileMan::NewL(fsSession);
fileMan->RmDir(_L("c:\\private\\102033E6\\security\\tmp"));
delete fileMan;
}
else if (newPolicy.Length() > 0)
{
// save the old policy into old_policy.txt
CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity);
HBufC* buf = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength);
TPtr policy(buf->Des());
repository->Get(KPolicy, policy);
TInt err = policyConfigFile.Replace(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_policy.txt"), EFileStreamText | EFileWrite);
if (err == KErrNone)
{
HBufC8* tmp8 = HBufC8::NewLC(policy.Length());
TPtr8 tmpPtr8(tmp8->Des());
tmpPtr8.Copy(policy);
policyConfigFile.Write(tmpPtr8);
CleanupStack::PopAndDestroy(tmp8);
policyConfigFile.Close();
// write the new policy
HBufC* tmp = HBufC::NewLC(newPolicy.Length());
TPtr tmpPtr(tmp->Des());
tmpPtr.Copy(newPolicy);
repository->Set(KPolicy, tmpPtr);
CleanupStack::PopAndDestroy(tmp);
}
CleanupStack::PopAndDestroy(buf);
CleanupStack::PopAndDestroy(repository);
}
if (oldWarningsMode.Length() > 0)
{
// restore the old value
CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity);
if (oldWarningsMode == _L8("1"))
//.........这里部分代码省略.........
示例12: UpdateDriveStatusL
/**
* UpdateDriveStatusL()
* @param TUint: The index of the said drive in preferred
* drive list.
*/
void CMsvIndexContext::UpdateDriveStatusL(TUint aDriveIndex, TDriveState& aStoreStatus)
{
aStoreStatus = EMsvInvalidDriveStatus;
TBool deleteStore = EFalse;
TMsvPreferredDrive driveEntry;
CMsvPreferredDriveList::GetDriveList()->DriveInfoL(aDriveIndex, driveEntry);
// Check if the media is available in the drive.
TVolumeInfo volume;
if (iServer.FileSession().Volume(volume, driveEntry.driveNum) != KErrNone)
{
CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvDriveDiskNotAvailableStatus);
aStoreStatus = EMsvDriveDiskNotAvailableStatus;
return;
}
// Validate the database. The function opens the database
// and check its version and returns appropriate error.
TRAPD(err, CMsvDBAdapter::ValidateDatabaseL(driveEntry.driveNum));
// If no error, database is available.
if(KErrNone == err)
{
CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreAvailableStatus);
return;
}
// If the database is not found in the drive.
if(KErrNotFound == err)
{
// Check if index file exists.
RFile file;
TParse parse;
TPtrC drive(TDriveUnit(driveEntry.driveNum).Name());
parse.Set(KMsvDefaultIndexFile2, &drive, NULL);
TFileName indexFileName = parse.FullName();
err = file.Open(iServer.FileSession(), indexFileName, EFileShareAny|EFileWrite);
//file.Close();
// If index file exists, set drive status to NOT SUPPORTED.
if(KErrNone == err)
{
CPermanentFileStore* fileStoreIndex = NULL;
TRAPD(permError, fileStoreIndex = CPermanentFileStore::FromL(file));
if(KErrNone == permError)
{
// Check if the store is corrupt. If so then delete it.
if (fileStoreIndex->Type() != TUidType(KPermanentFileStoreLayoutUid, KUidMsvIndexFile))
{
deleteStore = ETrue;
}
}
// There was an error in getting a permanent filestore object.
// Mark the message store for deletion.
else
{
deleteStore = ETrue;
}
delete fileStoreIndex;
//If message store is corrupted, wipe it.
if(deleteStore)
{
TFileName mail2Folder = parse.DriveAndPath();
CFileMan* fileMan = CFileMan::NewL(iServer.FileSession());
// Remove the readonly attribute..
(void)fileMan->Attribs(mail2Folder, 0, KEntryAttReadOnly, TTime(0), CFileMan::ERecurse);
CleanupStack::PushL(fileMan);
//Check if the mailfolder exists..
TBool mail2FolderExists = BaflUtils::FileExists(iServer.FileSession(), mail2Folder);
if(mail2FolderExists)
{
// Remove old message store if exists..
User::LeaveIfError(fileMan->RmDir(mail2Folder));
}
CleanupStack::PopAndDestroy(fileMan);
CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus);
aStoreStatus = EMsvMessageStoreCorruptStatus;
// Create store delete file in the respective drive.
CreateStoreDeleteFile(driveEntry.driveNum);
}
//Else only set status as EMsvMessageStoreNotSupportedStatus.
else
{
CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreNotSupportedStatus);
aStoreStatus = EMsvMessageStoreNotSupportedStatus;
}
file.Close();
return;
}
// If index file does not exists, set drive status to STORE UNAVAILABLE.
//.........这里部分代码省略.........