本文整理汇总了C++中TFileName::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TFileName::SetLength方法的具体用法?C++ TFileName::SetLength怎么用?C++ TFileName::SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFileName
的用法示例。
在下文中一共展示了TFileName::SetLength方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DumpMetaData
void CRefTestAgentImportFile::DumpMetaData(const CMetaDataArray& aMetaDataArray)
{
_LIT(KMetaDataLogFile, "c:\\logs\\rta\\metadata");
_LIT(KExt, ".log");
TInt id(0);
TInt err(KErrNone);
TFileName filename;
RFile file;
do {
filename.SetLength(0);
filename.Append(KMetaDataLogFile);
filename.AppendNum(++id);
filename.Append(KExt);
err = file.Create(iFs,filename,EFileWrite);
} while(err == KErrAlreadyExists);
if(err == KErrNone)
{
for(TInt i=0;i<aMetaDataArray.Count();i++)
{
file.Write(aMetaDataArray[i].Field8());
file.Write(_L8(" "));
file.Write(aMetaDataArray[i].Data8());
file.Write(_L8("\r\n"));
}
file.Close();
}
}
示例2: doExampleL
LOCAL_C void doExampleL()
{
// Define descriptor constants using the _LIT macro
_LIT(KMessage1,"Default path for fsSession is %S\n");
_LIT(KMessage2,"Session path for fsSession is now %S\n");
_LIT(KMessage3,"Session path for fsSession2 is %S\n");
_LIT(KTestDir,"f32test\\");
// Open file server session
User::LeaveIfError(fsSession.Connect());
// Get the default session path, and display it.
// It should be the private path for this (process)
// i.e. c:\private\0fffff04.
TFileName path;
User::LeaveIfError(fsSession.SessionPath(path));
console->Printf(KMessage1,&path);
// Create a directory within the default session path.
// and then set the default path to the full directory.
//
// Steps.
//
// 1 Create the private path - it is not automatically created by Symbian OS.
// 2. Get the name of the private path
// 3. Create the new directory level f32test\ within the private path
// 4. Set the session path to \private\0fffff04\f32test.
User::LeaveIfError(fsSession.CreatePrivatePath(EDriveC)); // <--- 1.
fsSession.PrivatePath(path); // <------------------------------ 2.
path.Append(KTestDir);
User::LeaveIfError(fsSession.MkDir(path));// <------------------- 3.
User::LeaveIfError(fsSession.SetSessionPath(path)); // <--------- 4.
// Retrieve the session path to make sure that the system
// agrees with what we believe is the new session path.
// Clear the path descriptor; this is NOT necessary, but just
// shows that we are not cheating !
path.SetLength(0);
User::LeaveIfError(fsSession.SessionPath(path));
console->Printf(KMessage2,&path);
// Make another connection to the file server and show
// its default session path.It should be the original
// private path for this (process) i.e. c:\private\0fffff04.
RFs fsSession2;
User::LeaveIfError(fsSession2.Connect());
fsSession2.SessionPath(path);
console->Printf(KMessage3,&path);
// Remove the \f32test\ directory
fsSession.PrivatePath(path);
path.Append(KTestDir);
User::LeaveIfError(fsSession.RmDir(path));
// Close these two sessions with the file server.
fsSession2.Close();
fsSession.Close();
}
示例3: currentPath
//static
QFileSystemEntry QFileSystemEngine::currentPath()
{
TFileName fn;
QFileSystemEntry ret;
TInt r = qt_s60GetRFs().SessionPath(fn);
if(r == KErrNone) {
//remove terminating slash from non root paths (session path is clean, absolute and always ends in a \)
if(fn.Length() > 3 && fn[fn.Length() - 1] == '\\')
fn.SetLength(fn.Length() - 1);
ret = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath());
}
return ret;
}
示例4: ClientSessionGetWidgetPathL
TInt CWidgetRegistrySTIF::ClientSessionGetWidgetPathL( TTestResult& aResult )
{
aResult.SetResult( KErrGeneral, KFailed );
RWidgetRegistryClientSession* registryClient;
registryClient = new (ELeave) RWidgetRegistryClientSession;
CleanupStack::PushL( registryClient );
TInt error = registryClient->Connect();
if ( KErrNone == error )
{
TFileName fn;
fn.SetLength( 0 );
registryClient->GetWidgetPath( iValidUid, fn );
if ( 0 < fn.Length() )
{
aResult.SetResult( KErrNone, KPassed );
}
registryClient->Disconnect();
}
CleanupStack::PopAndDestroy( registryClient );
return KErrNone;
}
示例5: SetDirectory
void __fastcall TCDirectoryOutline::SetDirectory(const TFileName NewDir)
{
if (NewDir.Length() > 0) {
TFileName Path = ForceCase(ExpandFileName(NewDir));
int n = Path.Length();
if (n > 3 && Path.IsPathDelimiter(n))
Path.SetLength(n - 1);
if (Path != FDirectory) {
FDirectory = Path;
chdir(FDirectory.c_str());
if (!SameLetter(Path[1], Drive))
Drive = Path[1];
else {
WalkTree(Path);
Change();
}
}
}
}
示例6:
void
CNfsAppUi::ConstructL()
{
TFileName fnb;
fnb.Copy(Application()->AppFullName());
int l;
for(l = fnb.Length()-1; l; l--)
if(fnb[l] == '\\')
break;
fnb.SetLength(l+1);
fnb.Append(_L("nfsclient.exe"));
#if !defined(__int64) // Old SDK
EikDll::StartExeL(fnb);
#else
RProcess pr;
if(pr.Create(fnb,fnb) == KErrNone)
{
pr.Resume();
pr.Close();
}
#endif
User::Exit(0);
}
示例7: GetAlbumArtFilename
TInt CMusicPlayerImgEngine::GetAlbumArtFilename(const CMetadata &aMetadata, const TSize &aSize, TFileName &aCoverFilename, CImageDecoder **aDecoder)
{
/* Function returns KErrNotFound if we find nothing, it returns 0 if we find a file, and it returns 1 if the elemnt is in cache
* In aCacheIndex returns the cache index, if found there, or -1. If found in cache, the cache is updated.
* If NOT found in cache, aCoverFilename contains the cover filename. If aMetadata.iCover is valid (non-NULL)
* then the aCoverFilename is non-existent, e.g. e:\\Music\\Something\\Else.mp3_360.jpg The purpose in this case
* would be to identify the image in the cache.
*
* The algorithm for finding the album art:
* 1. Check if there is aMetadata.iCover. If it does, check the cache, update aCoverFilename, return.
* 2. Check for KAlbumCoverNameGeneric (cover.jpg) in song's folder.
* 3. Check for KAlbumCoverNameGeneric2 (folder.jpg) in song's folder.
* 4. If aMetadata artist and album are non-NULL, check the Source/__Covers/Artist-Album.jpg
* 5. If enabled in Preferences, create a "hint" Source/__Covers/Artist-Album.hint having 0 bytes
* 6. If here, return KErrNotFound
*/
aMetadata.iFileDirEntry->GetFullPath(aCoverFilename,ETrue);
LOG(ELogGeneral,1,"GetAlbumArtFilename++ (%S), iCover=%x",&aCoverFilename,aMetadata.iCover);
TInt r,err;
TEntry entry;
*aDecoder=NULL;
if(aMetadata.iCover) {
aMetadata.iFileDirEntry->GetFullPath(aCoverFilename);
//check if we have this in cache
if(IsInCache(aCoverFilename,aSize)) {
LOG(ELogGeneral,-1,"GetAlbumArtFilename-- (we have embedded cover, in cache)");
return 1;
}
else {
TRAP(err,*aDecoder=CImageDecoder::DataNewL(iEikEnv->FsSession(),*aMetadata.iCover));
if(!err) {
LOG(ELogGeneral,-1,"GetAlbumArtFilename-- (we have embedded cover)");
return 0;
}
else LOG0("Instantiating a CImageDecoder for the embedded cover failed. Checking other options.");
}
}
//check for KAlbumCoverNameGeneric
aMetadata.iFileDirEntry->iParent->GetFullPath(aCoverFilename,ETrue);
TInt pathLength=aCoverFilename.Length();
aCoverFilename.Append(KAlbumCoverNameGeneric);
if((r=GetAlbumArtFilenameHelper(aSize,aCoverFilename,aDecoder))>=0)
return r;
//check for KAlbumCoverNameGeneric2
aCoverFilename.SetLength(pathLength);
aCoverFilename.Append(KAlbumCoverNameGeneric2);
if((r=GetAlbumArtFilenameHelper(aSize,aCoverFilename,aDecoder))>=0)
return r;
//if we are here, we need to check if we have valid Artist and Album metadata
if(aMetadata.iAlbum && aMetadata.iArtist)
{
//we can construct Source/__Covers/Artist-Album.jpg
aMetadata.iFileDirEntry->GetSource()->GetFullPath(aCoverFilename,ETrue);
aCoverFilename.Append(KCoversFolderName);
pathLength=aCoverFilename.Length();
if(pathLength+aMetadata.iArtist->Length()+aMetadata.iAlbum->Length()+6<=KMaxFileName) //6= the dash + length of .jpg or .jpeg or .hint
{
//check for __Covers/Artist-Album.jpg
aCoverFilename.Append(*aMetadata.iArtist);
aCoverFilename.Append('-');
aCoverFilename.Append(*aMetadata.iAlbum);
aCoverFilename.Append(KAlbumCoverExtension);
if((r=GetAlbumArtFilenameHelper(aSize,aCoverFilename,aDecoder))>=0)
return r;
//if we are here, the file does not exist!
if((iPreferences->iPFlags&CMLauncherPreferences::EPreferencesCreateCoverHintFiles) &&
(pathLength+KIgnoreFolderName().Length()+aMetadata.iArtist->Length()+aMetadata.iAlbum->Length()+6<=KMaxFileName)) //filename size requirements
{
//check first if the hint file is in the "IGNORE" folder
aCoverFilename.SetLength(pathLength);
aCoverFilename.Append(KIgnoreFolderName);
aCoverFilename.Append(*aMetadata.iArtist);
aCoverFilename.Append('-');
aCoverFilename.Append(*aMetadata.iAlbum);
aCoverFilename.Append(KHintFileExtension);
if(iEikEnv->FsSession().Entry(aCoverFilename,entry)){
//the hint file was not found in the IGNORE folder
//we should create a hint file
aCoverFilename.SetLength(pathLength);
aCoverFilename.Append(*aMetadata.iArtist);
aCoverFilename.Append('-');
aCoverFilename.Append(*aMetadata.iAlbum);
aCoverFilename.Append(KHintFileExtension);
LOG0("Creating hint file for %S",&aCoverFilename);
//first, we try to make the folder
if(!iEikEnv->FsSession().MkDir(aCoverFilename.Left(pathLength))){
//set the entry as hidden
TTime modifTime;
modifTime.UniversalTime();
iEikEnv->FsSession().SetEntry(aCoverFilename.Left(pathLength),modifTime,KEntryAttHidden,0);
}
//now we create the file, IF it does not exist
if(iEikEnv->FsSession().Entry(aCoverFilename,entry)){
//.........这里部分代码省略.........
示例8: ProcessCommandParametersL
TBool CTstAppUi::ProcessCommandParametersL(TApaCommand, TFileName& aDocumentName, const TDesC8&)
{
aDocumentName.SetLength(0);
return EFalse;
}