📄 chxavdirectoryreader.cpp
字号:
/*****************************************************************************
* chxavdirectoryreader.cpp
* ------------------------
*
* Synopsis:
* Makes locating files and sub-dirs within a dir a bit easier.
*
* Target:
* Symbian OS
*
*
* (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
*
*****************************************************************************/
// Symbian includes...
#include <eikfutil.h>
#include <f32file.h>
// Helix includes...
#include "hxtypes.h"
#include "hxstring.h"
// Includes fromt this project...
#include "hxsym_debug.h"
#include "chxavdirectoryreader.h"
#include "chxavstringutils.h"
CHXAvDirectoryReader::CHXAvDirectoryReader(RFs& rfs)
: m_rfs(rfs)
, m_pFileEntries(0)
, m_pDirEntries(0)
, m_lastError(KErrNone)
, m_sortFlags(ESortByName | EAscending)
, m_attributes(KEntryAttNormal) // | KEntryAttSystem | KEntryAttHidden;
{
}
CHXAvDirectoryReader::~CHXAvDirectoryReader()
{
HX_DELETE(m_pFileEntries);
HX_DELETE(m_pDirEntries);
}
////////////////////////////////////////////////////////
// if \documents is a directory:
//
// \documents -> file list is empty, dir list contains 1 entry
// \documents\ -> file list contains files; dir list contains child dirs
// \documents\* -> " "
// \documents\*.rm -> file list contains all .rm files; dir list is empty
//
// dir must have trailing back-slash to collect its contents; otherwise it
// is interpreted as an entry (filename or dir)
//
//
bool
CHXAvDirectoryReader::SetToPath(const TDesC& path)
{
_LIT(KWildcardText, "*");
bool bSuccess = false;
HX_DELETE(m_pFileEntries);
HX_DELETE(m_pDirEntries);
// check that the specified path is parseable
m_lastError = EikFileUtils::Parse(path);
if(KErrNone == m_lastError )
{
m_path = path;
// append wildcard if name component is missing (dir specified)
TParse parsedPath;
parsedPath.Set(m_path, NULL, NULL);
if( !parsedPath.NamePresent() && m_path.Length() < KMaxFileName )
{
m_path.Append(KWildcardText);
}
m_lastError = m_rfs.GetDir(m_path, m_attributes, m_sortFlags, m_pFileEntries, m_pDirEntries);
bSuccess = (KErrNone == m_lastError);
if( bSuccess )
{
HX_ASSERT(m_pDirEntries);
BaflUtils::RemoveSystemDirectory(*m_pDirEntries);
}
}
else
{
CHXString str;
CHXAvStringUtils::DesToString(path, str);
DPRINTF(SYMP_FILE, ("CHXAvDirectoryReader::SetToPath(): bad path '%s'\n", (const char*)str));
str.GetLength();
}
return bSuccess;
}
////////////////////////////////////////////////////////
// descend from current directory to a child directory
//
// name must not start or end with '\\'
//
bool CHXAvDirectoryReader::SetToChild(const TDesC& dir)
{
TParse parsedPath;
parsedPath.Set(m_path, NULL, NULL);
parsedPath.AddDir(dir);
return SetToPath(parsedPath.FullName());
}
////////////////////////////////////////////////////////
// move up from current directory to parent directory
//
bool CHXAvDirectoryReader::SetToParent()
{
TParse parsedPath;
parsedPath.Set(m_path, NULL, NULL);
parsedPath.PopDir();
return SetToPath(parsedPath.FullName());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -