// --------------------------------------------------------- // CCookieManagerServer::CheckDiskSpace // --------------------------------------------------------- // TBool CCookieManagerServer::CheckDiskSpace( RFs& aFileSystem, const TDesC& aFileName ) const { TInt err; TParse parse; err = parse.SetNoWild( aFileName, NULL, NULL ); if ( err == KErrNone ) { // This is in the form : drive-letter: (letter + semi-colon) TBuf<2> driveBuf( parse.Drive() ); TCharF driveLetter( driveBuf[0] ); TCharF driveALetter( 'A' ); TDriveNumber driveNum = (TDriveNumber)( (TUint)(driveLetter) - (TUint)(driveALetter) ); TBool noSpace = EFalse; TRAP( err, noSpace = SysUtil::DiskSpaceBelowCriticalLevelL ( &aFileSystem, KCookieMaxFileLength, driveNum ) ); if ( err == KErrNone && noSpace ) { err = KErrDiskFull; } } return ( err == KErrNone ? ETrue : EFalse ); }
TInt PosixFilesystem::SetDefaultDir (RFs& aFs) { TParse parse; parse.Set(RProcess().FileName(), NULL, NULL); #ifdef __SECURE_DATA__ return aFs.SetSessionToPrivate(TDriveUnit(parse.Drive())); #else return aFs.SetSessionPath(parse.DriveAndPath()); #endif }
void CMainControlEngine::SetResPath() { TFileName fileName; ::CompleteWithAppPath(fileName); TParse parse; parse.Set(fileName,NULL,NULL); iResPath.Zero(); iResPath.Append(parse.Drive()); iResPath.Append(KRESOURCEPATH); }
void CompleteWithAppPathM(TDes &aPath) { TFileName fullAppName = RProcess().FileName(); TParse parse; TParse parse1; parse.Set(fullAppName, NULL, NULL); parse1.Set(aPath, NULL, NULL); if(parse1.DrivePresent()) { aPath[0] = parse.Drive()[0]; } else { aPath.Insert(0, parse.Drive()); } #ifdef __WINS__ aPath[0] = 'c'; #endif }
void CMainControlEngine::SetAppDrive() { #ifdef __WINS__ iDrive.Append(_L("C:")); #else TFileName fileName; ::CompleteWithAppPath(fileName); TParse parse; parse.Set(fileName,NULL,NULL); iDrive.Zero(); iDrive.Append(parse.Drive()); #endif }
/*static*/ TInt CJournalFile::CheckFileNameL(RFs&, const TDesC& aFileName) { TParse parse; User::LeaveIfError(parse.Set(aFileName, NULL, NULL)); if (!parse.DrivePresent()) User::Leave(KErrArgument); if (!parse.PathPresent()) User::Leave(KErrArgument); TDriveUnit drive(parse.Drive()); return drive; }
/** The method parses aFileName argument and constructs the full database file name (including the path) there. The full file name will be constructed in aFileName input/output argument. @param aDbFileName Input/Output. Database file name will be constructed there. @param aSysDrivePrivatePath SQL server private path on the system drive. @param aDrive Output parameter. The drive number. @leave KErrBadName Missing file name. @panic SqlDb 7 In _DEBUG mode - no drive in the final file path. @internalComponent */ static void DoFullFileNameL(TDes& aDbFileName, const TDesC& aSysDrivePrivatePath, TDriveNumber& aDrive) { TParse parse; __SQLLEAVE_IF_ERROR2(parse.Set(aDbFileName, &aSysDrivePrivatePath, NULL)); if(!parse.NamePresent()) { __SQLLEAVE2(KErrBadName); } aDbFileName.Copy(parse.FullName()); TPtrC driveName = parse.Drive(); __ASSERT_DEBUG(driveName.Length() > 0, __SQLPANIC2(ESqlPanicInternalError)); TInt driveNumber = -1; __SQLLEAVE_IF_ERROR2(RFs::CharToDrive(driveName[0], driveNumber)); aDrive = static_cast <TDriveNumber> (driveNumber); }
void PrintDiskUsage(RFs& aFs, const TDesC& aPath, TInt aOffset = 0) { _LIT(KSpace, " "); TheTest.Printf(_L("%*.*S%S\r\n"), aOffset, aOffset, &KSpace, &aPath); TFindFile findFile(aFs); CDir* fileNameCol = NULL; TBuf<8> fileNameMask; fileNameMask.Copy(_L("*.*")); TInt err = findFile.FindWildByDir(fileNameMask, aPath, fileNameCol); if(err == KErrNone) { do { const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case. (void)TheParse.Set(file, NULL, NULL); TPtrC driveName = TheParse.Drive(); if(aPath.FindF(driveName) >= 0) { TInt cnt = fileNameCol->Count(); for(TInt i=0;i<cnt;++i) { const ::TEntry& entry = (*fileNameCol)[i]; if(!entry.IsDir()) { TheTest.Printf(_L("%*.*S %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize); } else { TBuf<100> path; path.Copy(aPath); path.Append(entry.iName); path.Append(_L("\\")); PrintDiskUsage(aFs, path, aOffset + 4); } } } // if(aPath.FindF(driveName) >= 0) delete fileNameCol; fileNameCol = NULL; } while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files } else { TheTest.Printf(_L(" FindWildByDir() failed with err=%d\r\n"), err); } }
// ----------------------------------------------------------------------------- // MVPbkContactFieldSelector* CContactMatcher::CreateFieldTypeSelectorLC( ) // ----------------------------------------------------------------------------- MVPbkContactFieldSelector* CContactMatcher::CreateFieldTypeSelectorLC ( TInt aResId ) { if ( !iResourceFileInitialized ) { TFileName tmpName; // Append the Resource Files Directory tmpName.Append( KDC_RESOURCE_FILES_DIR ); // Append the Ressource File Name tmpName.Append( KMsgCommonUtilsResourceFileName ); // Obtain the drive where the DLL is installed TFileName dllDrive; Dll::FileName( dllDrive ); // Obtain the Complete path for the Resource File TParse parse; parse.Set( dllDrive, NULL, NULL ); parse.Set( parse.Drive(), &tmpName, NULL ); TFileName fileName; fileName.Append( parse.FullName()); iResourceFile.OpenL( *iFsSession, fileName ); iResourceFile.ConfirmSignatureL( 0 ); iResourceFileInitialized = ETrue; } HBufC8* dataBuffer = iResourceFile.AllocReadLC( aResId ); TResourceReader reader; reader.SetBuffer( dataBuffer ); CVPbkFieldTypeSelector* fieldTypeSelector = CVPbkFieldTypeSelector::NewL( reader, FieldTypes() ); CleanupStack::PopAndDestroy( dataBuffer ); CleanupStack::PushL( fieldTypeSelector ); return fieldTypeSelector; }
// ----------------------------------------------------------------------------- // WebCannedImages::GetCannedImageDirL // Gets the folder where the canned image is located // ----------------------------------------------------------------------------- // HBufC* WebCannedImages::getImageDirL( ) { TFileName mbmDrive; HBufC* mbmFile = NULL; TParse parse; // get the drive letter - MBM is on the same drive as this DLL Dll::FileName( mbmDrive ); parse.Set( mbmDrive, NULL, NULL ); mbmDrive = parse.Drive(); // allocate memory for MBM file name mbmFile = HBufC::NewL( KMaxFileName ); // assemble the MBM file name TPtr ptr( mbmFile->Des() ); ptr.SetLength( 0 ); ptr.Append( mbmDrive ); ptr.Append( KDC_APP_BITMAP_DIR ); return mbmFile; }
// ----------------------------------------------------------------------------- // CPosLmLocalDatabaseManager::DatabaseExistsL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // TBool CPosLmLocalDatabaseManager::DatabaseExistsL(const TDesC& aDatabaseUri) { // validate URI HBufC* uri = PosLmDatabaseUtility::CreateDatabaseUriL(aDatabaseUri); CleanupStack::PushL(uri); TPtrC ptr(uri->Des()); PosLmDatabaseUtility::RemoveProtocolFromUriL(ptr); TParse parse; User::LeaveIfError(parse.Set(ptr, NULL, NULL)); TFileName searchUri = parse.NameAndExt(); searchUri.UpperCase(); TInt drive; User::LeaveIfError(RFs::CharToDrive(parse.Drive()[0], drive)); RDbs dbSession; CleanupClosePushL(dbSession); User::LeaveIfError(dbSession.Connect()); CDbDatabaseNames* names = dbSession.DatabaseNamesL( static_cast<TDriveNumber>(drive), KPosLmDbSecureUid); CleanupStack::PushL(names); TBool exists(EFalse); for (TInt i = 0; i < names->Count() && !exists; i++) { HBufC* databaseName = (*names)[i].AllocLC(); databaseName->Des().UpperCase(); if (searchUri == *databaseName) { exists = ETrue; } CleanupStack::PopAndDestroy(databaseName); } CleanupStack::PopAndDestroy(3, uri); //dbSession return exists; }
/** @SYMTestCaseID PDS-SQL-UT-4224 @SYMTestCaseDesc CSqlServer::GetBackUpListL() functional test @SYMTestPriority High @SYMTestActions Calls CSqlServer::GetBackUpListL() and tests the output, when the drive is read-only, when there is a sub-directory which name is matching the search pattern. @SYMTestExpectedResults Test must not fail */ void GetBackupListFunctionalTest() { CSqlServer* server = NULL; TRAPD(err, server = CreateSqlServerL()); TEST2(err, KErrNone); //Case 1: database with specified uid bellow do exist (on drive C). There will be one subdirectory matching the search pattern. const TDriveNumber KTestDrvNum1 = EDriveC; const TUid KDbUid = {0x98765432}; TDriveUnit testDrive(KTestDrvNum1); TDriveName testDriveName = testDrive.Name(); testDriveName.LowerCase(); //One test directory will be created, which name will be matching the search pattern. //The directory name should not be included in the list with the file names. TFileName testFileName; err = server->Fs().PrivatePath(testFileName); TEST2(err, KErrNone); testFileName.Append(KDbUid.Name()); _LIT(KTestPath, "t_startup\\"); testFileName.Append(KTestPath); testFileName.Append(_L("t_startup.db")); TParse parse; err = parse.Set(testFileName, &testDriveName, 0); TEST2(err, KErrNone); err = server->Fs().MkDirAll(parse.FullName()); TEST(err == KErrNone || err == KErrAlreadyExists); // RArray<HBufC*> files; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum1, files)); TEST2(err, KErrNone); TInt fileCnt = files.Count(); for(TInt i=0;i<fileCnt;++i) { TPtrC fname = files[i]->Des(); TheTest.Printf(_L("Db: %S\r\n"), &fname); TEST(fname.FindF(KTestPath) < 0); //The name should include the full path + the drive err = parse.Set(fname, 0, 0); TEST2(err, KErrNone); TEST(parse.DrivePresent()); TEST(parse.PathPresent()); TDriveName driveName(parse.Drive()); driveName.LowerCase(); delete files[i]; TEST(driveName == testDriveName); } files.Close(); //Case 2: drive Z:. No files should be returned. const TDriveNumber KTestDrvNum2 = EDriveZ; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum2, files)); TEST2(err, KErrNone); fileCnt = files.Count(); TEST2(fileCnt, 0); //Case 3: drive A:. The drive does not exist. No files should be returned. const TDriveNumber KTestDrvNum3 = EDriveA; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum3, files)); TheTest.Printf(_L("Drive %d, err=%d\r\n"), KTestDrvNum3, err); fileCnt = files.Count(); TEST2(fileCnt, 0); // delete server; }
/** Protected constructor. Extracts the initialisation data provided by the calling functions: ConstructSourceL() and ConstructSinkL(). Creates a file server session and sets up file name. If there is a file name and it cannot be found this function leaves. If there is no file name the function leaves. Does not attempt to open the file or check whether the file exists. If aInitData contains a TMMFFileHandleParams instead of TMMFFileParams, the source/sink is constructed from the file handle provided by the caller @param aInitData Initialisation data packaged in a TMMFFileParams or in a TMMFFileHandleParams (File Handle) */ void CFileMultimediaSource::ConstructL(const TDesC8& aInitData,TMMFileMode aFileMode) { User::LeaveIfError(iFsSession.Connect()); // on IPCv2 we auto attach User::LeaveIfError(iFsSession.ShareAuto()); User::LeaveIfError(iFsSession.ShareProtected()); TBool fileInit = EFalse; HBufC* filename = NULL; TBool filenamePushed = EFalse; iCAFParameters = new (ELeave) CCAFParameters; TBool drmContent = EFalse; RDesReadStream stream(aInitData); CleanupClosePushL(stream); TUid initUid; initUid = TUid::Uid(stream.ReadInt32L()); if (initUid == KMMFileHandleSourceUid) { TPckgBuf<RFile*> fileptr; stream.ReadL(fileptr); iHandle.Duplicate(*fileptr()); TInt length; length = stream.ReadInt32L(); if (length>0) { iCAFParameters->iUniqueId = HBufC::NewL(length); TPtr16 ptr = iCAFParameters->iUniqueId->Des(); stream.ReadL(ptr, length); } iFileHandle = ETrue; filename = HBufC::NewMaxL(KMaxFileName); TPtr ptr = filename->Des(); iHandle.Name(ptr); fileInit = ETrue; drmContent = ETrue; iCAFParameters->iEnableUI = stream.ReadInt32L(); } else if (initUid == KMMFileSourceUid) { TInt length; length = stream.ReadInt32L(); filename = HBufC::NewMaxLC(length); TPtr ptr = filename->Des(); stream.ReadL(ptr, length); length = stream.ReadInt32L(); if (length>0) { iCAFParameters->iUniqueId = HBufC::NewMaxL(length); ptr.Set(iCAFParameters->iUniqueId->Des()); stream.ReadL(ptr, length); } CleanupStack::Pop(filename); fileInit = ETrue; drmContent = ETrue; iFileHandle = EFalse; iCAFParameters->iEnableUI = stream.ReadInt32L(); } else { // TODO If the UID is unknown we should reject, but currently // code also used for older calls that just supply filename. // User::Leave(KErrNotSupported); } CleanupStack::PopAndDestroy(&stream); if (!fileInit && aInitData.Length() == sizeof(TMMFFileHandleParams)) { TMMFFileHandleParams params; TPckgC<TMMFFileHandleParams> config(params); config.Set(aInitData); params = config(); if (params.iUid == KFileHandleUid) { fileInit = ETrue; User::LeaveIfError(iHandle.Duplicate(*params.iFile)); TInt pos = 0; // make sure the duplicate handle is at the start of the file - the usage of the file handle really requires this User::LeaveIfError(iHandle.Seek(ESeekStart, pos)); iFileHandle = ETrue; filename = HBufC::NewMaxLC(KMaxFileName); filenamePushed = ETrue; TPtr ptr = filename->Des(); User::LeaveIfError(iHandle.Name(ptr)); } } if (!fileInit) // do old case as last resort { TMMFFileParams params; TPckgC<TMMFFileParams> config(params); config.Set(aInitData); params = config(); filename = params.iPath.AllocL(); fileInit = ETrue; } if (!filenamePushed) { // from now on it is assumed pushed. CleanupStack::PushL(filename); } TParse parser ; User::LeaveIfError(parser.Set(*filename, NULL, NULL)); CleanupStack::PopAndDestroy(filename); if ( !( parser.NamePresent() ) && !( parser.ExtPresent() ) ) User::Leave( KErrBadName ) ; iFullFileName.Copy( parser.FullName() ) ; iFileName = parser.Name().AllocL() ; iFileExt = parser.Ext().AllocL() ; iFilePath = parser.Path().AllocL() ; iFileDrive = parser.Drive().AllocL() ; // in order to simulate old behaviour we are not passing error out // but will try to create Content again during PrimeL() if (fileInit && drmContent && aFileMode==ESourceMode) { TInt contentError; if (iFileHandle) { TRAP(contentError, iFile = CContentFile::NewL(iHandle, UniqueId(), iCAFParameters->iEnableUI); ); }
// ----------------------------------------------------------------------------- // CLocalizationAppUi::HandleCommandL() // Takes care of command handling. // ----------------------------------------------------------------------------- // void CLocalizationAppUi::HandleCommandL( TInt aCommand ) { switch( aCommand ) { case EEikCmdExit: case EAknSoftkeyExit: Exit(); break; // Number case ELocalizationCommandNumber: { // buffer for localized text TBuf<50> myBuf; // Amount to show TReal myAmount = 1234.567; // Real number formatter, initialized with system's current locale settings TRealFormat myFormat; // Format real with current locales decimal separator setting myBuf.AppendNum(myAmount, myFormat); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Currency case ELocalizationCommandCurrency: { // locale is initialized with system's current locale settings TLocale myLocale; // buffer for localized text TBuf<50> myBuf; // amount is integer, but it is treated as last two digits // were decimal digits e.g. 1249 = 12.49, 2 = 0.02 ... TInt myAmount = 123456789; // Format currency according to current locale settings myLocale.FormatCurrency(myBuf, myAmount); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Date case ELocalizationCommandDate: { // buffer for localized text TBuf<50> myBuf; // Object for datetime data TTime myDate; // Set current datetime to object myDate.HomeTime(); // Format date according to current locale settings // Format string is universal, so that whatever the locale is, // date is always formatted correctly myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X")); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Time case ELocalizationCommandTime: { // buffer for localized text TBuf<50> myBuf; // Object for datetime data TTime myTime; // Set current datetime to object myTime.HomeTime(); // Format time to current locale // Format string is universal, so that whatever the locale is, // time is always formatted correctly myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B")); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Text case ELocalizationCommandText: { // buffer for string parameters that may change order CDesCArrayFlat* strings = new CDesCArrayFlat( 2 ); CleanupStack::PushL( strings ); // Initialize parameter buffer // First parameter strings->AppendL( _L("Heidi") ); // Second parameter strings->AppendL( _L("2") ); // Load a string from the resource file, and append parameters into it HBufC* textResource = StringLoader::LoadL( R_LOC_COMMANDTEXT_TEXT, *strings ); CleanupStack::PushL( textResource ); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( *textResource ); // Cleanupstack CleanupStack::PopAndDestroy( textResource ); CleanupStack::PopAndDestroy( strings ); } break; // Image case ELocalizationCommandImage: { // find the drive where the app has been installed TParse parse; parse.Set(Application()->AppFullName(),0,0); // Load bitmap name from the resource file HBufC* bmpFile = StringLoader::LoadLC( R_LOC_COMMANDIMAGE_BMPFILE, parse.Drive()); // bitmap pointer CFbsBitmap* bitmap; // Create and Load the Bitmap bitmap = new( ELeave )CFbsBitmap; CleanupStack::PushL( bitmap ); // Load the first bitmap (index 0) from multi-bitmap file User::LeaveIfError(bitmap->Load( *bmpFile, 0 )); CleanupStack::Pop( bitmap ); // Draw bitmap to screen // ownership of bitmap is transferred to view iAppView->DrawImage( bitmap ); // Cleanupstack CleanupStack::PopAndDestroy( bmpFile ); } break; // Default case default: break; } }
LOCAL_C void DoTestName(const TDesC& aName,TInt anError) // // Check errors returned // { TBuf<32> goodName=_L("\\GOODNAME.TXT"); TBuf<32> badName=_L("\\< > : \" / |"); TParse parser; TInt r=parser.Set(aName,NULL,NULL); test_Value(r, r == KErrNone || r==anError); goodName.Insert(0,parser.Drive()); badName.Insert(0,parser.Drive()); TBuf<KMaxFileName> name; // We need an 8-bit name to test RFs::GetLongName() in name.Copy(aName); // both builds TFileName dummy; // To use as an argument to RFs::GetLongName() will store the TBuf<12> dummyShortName; // To use as an argument to RFs::GetShortName() TUint dumVal; TTime dumTime; TBool dumAnswer; TEntry dumEntry; CDir* dumDir; TUidType dumUid; TInt dumInt=0; TFileName badPath=aName; badPath.Append(_L("\\")); // Test MKDIR with filename containing \000 TBuf<32> emptyName; emptyName.Format(_L("\\%c\\"),0); emptyName.Insert(0,parser.Drive()); r=TheFs.MkDir(emptyName); TestReturnValue(r, anError); emptyName.Format(_L("\\Big%cGreen\\"),0); emptyName.Insert(0,parser.Drive()); r=TheFs.MkDir(emptyName); TestReturnValue(r, anError); r=TheFs.SetSessionPath(badPath); TestReturnValue(r,KErrBadName); // Do not check drives r=TheFs.MkDir(badPath); TestReturnValue(r,anError); r=TheFs.MkDirAll(badPath); TestReturnValue(r,anError); r=TheFs.RmDir(badPath); TestReturnValue(r,anError); r=TheFs.GetDir(aName,dumInt,dumInt,dumDir); TestReturnValue(r,anError); r=TheFs.GetDir(aName,dumInt,dumInt,dumDir,dumDir); TestReturnValue(r,anError); r=TheFs.GetDir(aName,dumUid,dumInt,dumDir); TestReturnValue(r,anError); r=TheFs.Delete(aName); TestReturnValue(r,anError); r=TheFs.Rename(aName,goodName); TestReturnValue(r,anError); r=TheFs.Rename(aName,badName); TestReturnValue(r,anError); r=TheFs.Rename(goodName,aName); TestReturnValue(r,anError); r=TheFs.Rename(badName,aName); TestReturnValue(r,anError); r=TheFs.Replace(aName,goodName); TestReturnValue(r,anError); r=TheFs.Replace(aName,badName); TestReturnValue(r,anError); r=TheFs.Replace(goodName,aName); TestReturnValue(r,anError); r=TheFs.Replace(badName,aName); TestReturnValue(r,anError); r=TheFs.Att(aName,dumVal); TestReturnValue(r,anError); r=TheFs.SetAtt(aName,dumInt,dumInt); TestReturnValue(r,anError); r=TheFs.Modified(aName,dumTime); TestReturnValue(r,anError); r=TheFs.SetModified(aName,dumTime); TestReturnValue(r,anError); r=TheFs.Entry(aName,dumEntry); TestReturnValue(r,anError); r=TheFs.SetEntry(aName,dumTime,dumInt,dumInt); TestReturnValue(r,anError); r=TheFs.IsFileOpen(aName,dumAnswer); TestReturnValue(r,anError); r=TheFs.GetShortName(aName,dummyShortName); TestReturnValue(r,anError); r=TheFs.GetLongName(name,dummy); TestReturnValue(r,anError); RFile f; r=f.Open(TheFs,aName,EFileWrite); TestReturnValue(r,anError); r=f.Create(TheFs,aName,EFileWrite); TestReturnValue(r,anError); r=f.Replace(TheFs,aName,EFileWrite); TestReturnValue(r,anError); RDir d; r=d.Open(TheFs,aName,KEntryAttNormal); TestReturnValue(r,anError); r=d.Open(TheFs,aName,dumUid); TestReturnValue(r,anError); }
bool LongStream::freeSpace( const QString &path, int min) { unsigned long long boundary = minFree; if (min >= 0) boundary = min; QString partitionPath = tempDir() + "/."; if (!path.isEmpty()) partitionPath = path; #if defined(Q_OS_SYMBIAN) bool result(false); RFs fsSession; TInt rv; if ((rv = fsSession.Connect()) != KErrNone) { qDebug() << "Unable to connect to FS:" << rv; } else { TParse parse; TPtrC name(path.utf16(), path.length()); if ((rv = fsSession.Parse(name, parse)) != KErrNone) { qDebug() << "Unable to parse:" << path << rv; } else { TInt drive; if ((rv = fsSession.CharToDrive(parse.Drive()[0], drive)) != KErrNone) { qDebug() << "Unable to convert:" << QString::fromUtf16(parse.Drive().Ptr(), parse.Drive().Length()) << rv; } else { TVolumeInfo info; if ((rv = fsSession.Volume(info, drive)) != KErrNone) { qDebug() << "Unable to volume:" << drive << rv; } else { result = (info.iFree > boundary); } } } fsSession.Close(); } return result; #elif !defined(Q_OS_WIN) struct statfs stats; statfs(partitionPath.toLocal8Bit(), &stats); unsigned long long bavail = ((unsigned long long)stats.f_bavail); unsigned long long bsize = ((unsigned long long)stats.f_bsize); return ((bavail * bsize) > boundary); #else // MS recommend the use of GetDiskFreeSpaceEx, but this is not available on early versions // of windows 95. GetDiskFreeSpace is unable to report free space larger than 2GB, but we're // only concerned with much smaller amounts of free space, so this is not a hindrance. DWORD bytesPerSector(0); DWORD sectorsPerCluster(0); DWORD freeClusters(0); DWORD totalClusters(0); if (::GetDiskFreeSpace(partitionPath.utf16(), &bytesPerSector, §orsPerCluster, &freeClusters, &totalClusters) == FALSE) { qWarning() << "Unable to get free disk space:" << partitionPath; } return ((bytesPerSector * sectorsPerCluster * freeClusters) > boundary); #endif }
// Second-phase constructor void CPuttyAppUi::ConstructL() { #ifdef PUTTY_S60V3 #ifdef PUTTY_SYM3 BaseConstructL(CAknAppUi::EAknEnableSkin | EAknTouchCompatible | EAknSingleClickCompatible); #else BaseConstructL(CAknAppUi::EAknEnableSkin); #endif #else BaseConstructL(); #endif // Determine profile, data and font directories based on the executable // installation location. The files are on the same drive as the // executable, except if the exe is in ROM (z:), in which case profiles and // data use c:. TFileName name; name = RProcess().FileName(); TParse parsa; parsa.SetNoWild(name, NULL, NULL); TUint drive = parsa.Drive()[0]; // Font directory -- "<drv>:\resource\puttyfonts\" iFontDirectory.Format(KFontDirFormat, drive); // Fix drive for profiles and data if ( (drive == 'z') || (drive == 'Z') ) { drive = 'c'; } // Data directory -- "<drv>:\private\<SID>\data\" // If the data directory doesn't exist, create it and attempt to migrate // host keys from a previous installation iDataDirectory.Format(KDataDirFormat, drive, RProcess().SecureId().iId); RFs &fs = CEikonEnv::Static()->FsSession(); if ( !BaflUtils::FolderExists(fs, iDataDirectory) ) { BaflUtils::EnsurePathExistsL(fs, iDataDirectory); if ( BaflUtils::FileExists(fs, KOldHostKeysFile) ) { name = iDataDirectory; name.Append(KNewHostKeysFile); BaflUtils::CopyFile(fs, KOldHostKeysFile, name); } } // Profile directory -- "<drv>:\private\<SID>\profiles\" // If the profile directory doesn't exist, create it and attempt to migrate // default settings from a previous installation iProfileDirectory.Format(KProfileDirFormat, drive, RProcess().SecureId().iId); if ( !BaflUtils::FolderExists(fs, iProfileDirectory) ) { BaflUtils::EnsurePathExistsL(fs, iProfileDirectory); if ( BaflUtils::FileExists(fs, KOldSettingsFile) ) { name = iProfileDirectory; name.Append(KNewDefaultProfileFile); BaflUtils::CopyFile(fs, KOldSettingsFile, name); } } // Create navi pane iNaviPane = (CAknNavigationControlContainer*) (StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); // Build a list of available fonts iFonts = new CDesC16ArrayFlat(8); CDir *dir; User::LeaveIfError( CEikonEnv::Static()->FsSession().GetDir(iFontDirectory, KEntryAttNormal, ESortByName, dir)); CleanupStack::PushL(dir); for ( TInt i = 0; i < dir->Count(); i++ ) { parsa.SetNoWild((*dir)[i].iName, NULL, NULL); iFonts->AppendL(parsa.Name()); } CleanupStack::PopAndDestroy(); //dir // Build views iProfileListView = CProfileListView::NewL(); AddViewL(iProfileListView); iProfileEditView = CProfileEditView::NewL(); AddViewL(iProfileEditView); iTerminalView = CTerminalView::NewL(); AddViewL(iTerminalView); // Start from the profile list view. SetDefaultViewL(*iProfileListView); }