📄 commonfunctions.cpp
字号:
/*
========================================================================
Name : CommonFunctions.cpp
Author :
Copyright :
Description : Useful functions that are necessary for many parts of the game.
License :
========================================================================
*/
#include "CommonFunctions.h"
const TInt NCommonFunctions::GetStoreDriveL(RFs& aFs)
{
TInt driveNum;
// Get the drive as a character
TChar driveChar = NCommonFunctions::GetStoreDriveCharL(aFs);
// And convert it to an integer to get the drive number
aFs.CharToDrive(driveChar, driveNum);
return driveNum;
}
const TChar NCommonFunctions::GetStoreDriveCharL(RFs& /*aFs*/)
{
// Symbian OS 9.2: could use: return aFs.GetSystemDrive();
// Get the full name and path of the application
TFileName appNamePath = CEikonEnv::Static()->EikAppUi()->Application()->AppFullName();
#if defined(__WINS__) // if the resources are in emulators c (not z)
appNamePath.Replace(0,1,_L("c"));
#endif
return appNamePath[0];
}
const void NCommonFunctions::AddPrivateDirL(RFs& aFs, const TDesC& aFilename, RBuf& aCompleteName)
{
// Retrieve the full drive + path + filename of the application
TFileName appNamePath = CEikonEnv::Static()->EikAppUi()->Application()->AppFullName();
if (appNamePath.Length() == 0)
User::Leave(KErrGeneral);
#if defined(__WINS__)
// The emulator returns z as the drive, as for it, applications
// are installed on the ROM-drive (z).
// However, the resources are placed in the simulated c:\-drive,
// so replace the drive in case we're running within the emulator
appNamePath.Replace(0,1,_L("c"));
#endif
// Make sure the private path exists on the drive we need
// Would actually not be needed, as we copy files into the
// private directory during the installation process, so we
// could be sure that it's here. But it's always better to
// make sure.
TInt driveNum;
aFs.CharToDrive(appNamePath[0], driveNum);
aFs.CreatePrivatePath(driveNum);
// Reset the RBuf-variable and create it with the required size
aCompleteName.Close();
aCompleteName.CreateL(KMaxPath);
// Get the private path, does not contain the drive
aFs.PrivatePath( aCompleteName );
// Insert the drive to the private path, otherwise it'd be missig
aCompleteName.Insert(0, appNamePath.Left(2));
// Add the filename to the path, so that we now have a full URI, containing
// the drive, path and filename
aCompleteName.Append(aFilename);
}
const void NCommonFunctions::AddResourceDirL(const TDesC& aFilename, RBuf& aCompleteName)
{
TFileName resourceFileName = CEikonEnv::Static()->EikAppUi()->Application()->ResourceFileName();
#if defined(__WINS__) // if the resources are in emulators c (not z)
//resourceFileName.Replace(0,1,_L("c"));
#endif
resourceFileName = BaflUtils::DriveAndPathFromFullName(resourceFileName);
// Reset the RBuf-variable and create it with the required size
aCompleteName.Close();
aCompleteName.CreateL(resourceFileName, resourceFileName.Length() + aFilename.Length());
aCompleteName.Append(aFilename);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -