本文整理汇总了C++中AbstractFSList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractFSList::push_back方法的具体用法?C++ AbstractFSList::push_back怎么用?C++ AbstractFSList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractFSList
的用法示例。
在下文中一共展示了AbstractFSList::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getChildren
bool RoninCDDirectoryNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
DIR *dirp = opendir(_path.c_str());
struct dirent *dp;
if (dirp == NULL)
return false;
// ... loop over dir entries using readdir
while ((dp = readdir(dirp)) != NULL) {
Common::String newPath(_path);
if (newPath.lastChar() != '/')
newPath += '/';
newPath += dp->d_name;
if (dp->d_size < 0) {
// Honor the chosen mode
if (mode == Common::FSNode::kListFilesOnly)
continue;
myList.push_back(new RoninCDDirectoryNode(newPath+"/"));
} else {
// Honor the chosen mode
if (mode == Common::FSNode::kListDirectoriesOnly)
continue;
myList.push_back(new RoninCDFileNode(newPath));
}
}
closedir(dirp);
return true;
}
示例2: addFile
void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) {
WindowsFilesystemNode entry;
char *asciiName = toAscii(find_data->cFileName);
bool isDirectory;
// Skip local directory (.) and parent (..)
if (!strcmp(asciiName, ".") || !strcmp(asciiName, ".."))
return;
isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false);
if ((!isDirectory && mode == FilesystemNode::kListDirectoriesOnly) ||
(isDirectory && mode == FilesystemNode::kListFilesOnly))
return;
entry._isDirectory = isDirectory;
entry._displayName = asciiName;
entry._path = base;
entry._path += asciiName;
if (entry._isDirectory)
entry._path += "\\";
entry._isValid = true;
entry._isPseudoRoot = false;
list.push_back(new WindowsFilesystemNode(entry));
}
示例3: getChildren
bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
assert(_isDirectory);
#ifdef __OS2__
if (_path == "/") {
// Special case for the root dir: List all DOS drives
ULONG ulDrvNum;
ULONG ulDrvMap;
DosQueryCurrentDisk(&ulDrvNum, &ulDrvMap);
for (int i = 0; i < 26; i++) {
if (ulDrvMap & 1) {
char drive_root[] = "A:/";
drive_root[0] += i;
POSIXFilesystemNode *entry = new POSIXFilesystemNode();
entry->_isDirectory = true;
entry->_isValid = true;
entry->_path = drive_root;
entry->_displayName = "[" + Common::String(drive_root, 2) + "]";
myList.push_back(entry);
}
ulDrvMap >>= 1;
}
return true;
}
示例4: getChildren
bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bool hidden) const {
// consolePrintf("Listdir\n");
//TODO: honor the hidden flag
enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 };
char temp[128], fname[256], *path, *pathTemp;
strcpy(temp, _path.c_str());
path = temp + 3;
pathTemp = path;
while (*pathTemp) {
if (*pathTemp == '\\') {
*pathTemp = '/';
}
pathTemp++;
}
// consolePrintf("This dir: %s\n", path);
FAT_chdir(path);
int entryType = FAT_FindFirstFileLFN(fname);
while (entryType != TYPE_NO_MORE) {
if ( ((entryType == TYPE_DIR) && ((mode == Common::FSNode::kListDirectoriesOnly) || (mode == Common::FSNode::kListAll)))
|| ((entryType == TYPE_FILE) && ((mode == Common::FSNode::kListFilesOnly) || (mode == Common::FSNode::kListAll))) ) {
GBAMPFileSystemNode *dsfsn;
//consolePrintf("Fname: %s\n", fname);
if (strcmp(fname, ".") && strcmp(fname, "..")) {
if (!strcmp(path, "/")) {
dsfsn = new GBAMPFileSystemNode("mp:" + Common::String(path) + Common::String(fname), entryType == TYPE_DIR);
} else {
dsfsn = new GBAMPFileSystemNode("mp:" + Common::String(path) + Common::String("/") + Common::String(fname), entryType == TYPE_DIR);
}
// dsfsn->_isDirectory = entryType == DIR;
dirList.push_back((dsfsn));
}
} else {
// consolePrintf("Skipping %s\n", fname);
}
entryType = FAT_FindNextFileLFN(fname);
}
// consolePrintf("No more");
FAT_chdir("/");
return true;
}
示例5: getChildren
bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
DEBUG_ENTER_FUNC();
assert(_isDirectory);
//TODO: honor the hidden flag
bool ret = true;
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n"); // Make sure to block in case of suspend
PSP_DEBUG_PRINT_FUNC("Current path[%s]\n", _path.c_str());
int dfd = sceIoDopen(_path.c_str());
if (dfd > 0) {
SceIoDirent dir;
memset(&dir, 0, sizeof(dir));
while (sceIoDread(dfd, &dir) > 0) {
// Skip 'invisible files
if (dir.d_name[0] == '.')
continue;
PSPFilesystemNode entry;
entry._isValid = true;
entry._displayName = dir.d_name;
Common::String newPath(_path);
if (newPath.lastChar() != '/')
newPath += '/';
newPath += dir.d_name;
entry._path = newPath;
entry._isDirectory = dir.d_stat.st_attr & FIO_SO_IFDIR;
PSP_DEBUG_PRINT_FUNC("Child[%s], %s\n", entry._path.c_str(), entry._isDirectory ? "dir" : "file");
// Honor the chosen mode
if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) ||
(mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory))
continue;
myList.push_back(new PSPFilesystemNode(entry));
}
sceIoDclose(dfd);
ret = true;
} else { // dfd <= 0
ret = false;
}
PowerMan.endCriticalSection();
return ret;
}
示例6: getChildren
bool WindowsFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
assert(_isDirectory);
//TODO: honor the hidden flag
if (_isPseudoRoot) {
#ifndef _WIN32_WCE
// Drives enumeration
TCHAR drive_buffer[100];
GetLogicalDriveStrings(sizeof(drive_buffer) / sizeof(TCHAR), drive_buffer);
for (TCHAR *current_drive = drive_buffer; *current_drive;
current_drive += _tcslen(current_drive) + 1) {
WindowsFilesystemNode entry;
char drive_name[2];
drive_name[0] = toAscii(current_drive)[0];
drive_name[1] = '\0';
entry._displayName = drive_name;
entry._isDirectory = true;
entry._isValid = true;
entry._isPseudoRoot = false;
entry._path = toAscii(current_drive);
myList.push_back(new WindowsFilesystemNode(entry));
}
#endif
}
else {
// Files enumeration
WIN32_FIND_DATA desc;
HANDLE handle;
char searchPath[MAX_PATH + 10];
sprintf(searchPath, "%s*", _path.c_str());
handle = FindFirstFile(toUnicode(searchPath), &desc);
if (handle == INVALID_HANDLE_VALUE)
return false;
addFile(myList, mode, _path.c_str(), &desc);
while (FindNextFile(handle, &desc))
addFile(myList, mode, _path.c_str(), &desc);
FindClose(handle);
}
return true;
}
示例7: entry
bool N64FilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
assert(_isDirectory);
ROMDIR *dirp = romfs_opendir(_path.c_str());
romfs_dirent *dp;
if (dirp == NULL)
return false;
// loop over dir entries using readdir
while ((dp = romfs_readdir(dirp)) != NULL) {
// Skip 'invisible' files if necessary
if (dp->entryname[0] == '.' && !hidden) {
free(dp);
continue;
}
// Skip '.' and '..' to avoid cycles
if ((dp->entryname[0] == '.' && dp->entryname[1] == 0) || (dp->entryname[0] == '.' && dp->entryname[1] == '.')) {
free(dp);
continue;
}
// Start with a clone of this node, with the correct path set
N64FilesystemNode entry(*this);
entry._displayName = dp->entryname;
if (_path.lastChar() != '/')
entry._path += '/';
entry._path += entry._displayName;
// Force validity for now...
entry._isValid = 1;
entry._isDirectory = (dp->type == 0 || dp->type == 1);
// Honor the chosen mode
if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) ||
(mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory)) {
free(dp);
continue;
}
myList.push_back(new N64FilesystemNode(entry));
free(dp);
}
romfs_closedir(dirp);
return true;
}
示例8: getChildren
bool WiiFilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
assert(_isDirectory);
if (_path.empty())
return getDevopChildren(list, mode, hidden);
DIR* dp = opendir (_path.c_str());
DIR* tmpdir;
if (dp == NULL)
return false;
struct dirent *pent;
while ((pent = readdir(dp)) != NULL) {
if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0)
continue;
Common::String newPath(_path);
if (newPath.lastChar() != '/')
newPath += '/';
newPath += pent->d_name;
bool isDir = false;
tmpdir = opendir(newPath.c_str());
if(tmpdir)
{
isDir = true;
closedir(tmpdir);
}
if ((mode == Common::FSNode::kListFilesOnly && isDir) ||
(mode == Common::FSNode::kListDirectoriesOnly && !isDir))
continue;
struct stat st;
st.st_mode = 0;
st.st_mode |= ( isDir ? S_IFDIR : 0 );
st.st_mode |= S_IRUSR;
st.st_mode |= S_IWUSR;
list.push_back(new WiiFilesystemNode(newPath, &st));
}
closedir(dp);
return true;
}
示例9: getDevopChildren
// gets all registered devoptab devices
bool WiiFilesystemNode::getDevopChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
u8 i;
const devoptab_t* dt;
if (mode == Common::FSNode::kListFilesOnly)
return true;
// skip in, out and err
for (i = 3; i < STD_MAX; ++i) {
dt = devoptab_list[i];
if (!dt || !dt->name || !dt->open_r || !dt->diropen_r)
continue;
list.push_back(new WiiFilesystemNode(Common::String(dt->name) + ":/"));
}
return true;
}
示例10: listDir
bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
assert(_isDirectory);
GPDIRENTRY dirEntry;
GPFILEATTR attr;
GP32FilesystemNode entry;
uint32 read;
if (mode == FilesystemNode::kListAll)
LP("listDir(kListAll)");
else
LP("listDir(kListDirectoriesOnly)");
int startIdx = 0; // current file
String listDir(_path);
//listDir += "/";
while (GpDirEnumList(listDir.c_str(), startIdx++, 1, &dirEntry, &read) == SM_OK) {
if (dirEntry.name[0] == '.')
continue;
entry._displayName = dirEntry.name;
entry._path = _path;
entry._path += dirEntry.name;
GpFileAttr(entry._path.c_str(), &attr);
entry._isDirectory = attr.attr & (1 << 4);
// Honor the chosen mode
if ((mode == FilesystemNode::kListFilesOnly && entry._isDirectory) ||
(mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory))
continue;
if (entry._isDirectory)
entry._path += "\\";
myList.push_back(new GP32FilesystemNode(entry));
}
BP("Dir... %s", listDir.c_str());
return true;
}
示例11: getChildren
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool POSIXFilesystemNode::getChildren(AbstractFSList& myList, ListMode mode,
bool hidden) const
{
assert(_isDirectory);
DIR *dirp = opendir(_path.c_str());
struct dirent *dp;
if (dirp == NULL)
return false;
// loop over dir entries using readdir
while ((dp = readdir(dirp)) != NULL)
{
// Skip 'invisible' files if necessary
if (dp->d_name[0] == '.' && !hidden)
continue;
// Skip '.' and '..' to avoid cycles
if ((dp->d_name[0] == '.' && dp->d_name[1] == 0) || (dp->d_name[0] == '.' && dp->d_name[1] == '.'))
continue;
string newPath(_path);
if (newPath.length() > 0 && newPath[newPath.length()-1] != '/')
newPath += '/';
newPath += dp->d_name;
POSIXFilesystemNode entry(newPath, false);
#if defined(SYSTEM_NOT_SUPPORTING_D_TYPE)
/* TODO: d_type is not part of POSIX, so it might not be supported
* on some of our targets. For those systems where it isn't supported,
* add this #elif case, which tries to use stat() instead.
*
* The d_type method is used to avoid costly recurrent stat() calls in big
* directories.
*/
entry.setFlags();
#else
if (dp->d_type == DT_UNKNOWN)
{
// Fall back to stat()
entry.setFlags();
}
else
{
entry._isValid = (dp->d_type == DT_DIR) || (dp->d_type == DT_REG) || (dp->d_type == DT_LNK);
if (dp->d_type == DT_LNK)
{
struct stat st;
if (stat(entry._path.c_str(), &st) == 0)
entry._isDirectory = S_ISDIR(st.st_mode);
else
entry._isDirectory = false;
}
else
entry._isDirectory = (dp->d_type == DT_DIR);
}
#endif
// Skip files that are invalid for some reason (e.g. because we couldn't
// properly stat them).
if (!entry._isValid)
continue;
// Honor the chosen mode
if ((mode == FilesystemNode::kListFilesOnly && entry._isDirectory) ||
(mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory))
continue;
if (entry._isDirectory)
entry._path += "/";
myList.push_back(new POSIXFilesystemNode(entry));
}
closedir(dirp);
return true;
}
示例12:
bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
//TODO: honor the hidden flag
// dbg_printf("getChildren\n");
if (!_isDirectory)
return false;
if (_isRoot) {
if (g_systemPs2->cdPresent())
list.push_back(new Ps2FilesystemNode("cdfs:"));
if (g_systemPs2->hddPresent())
list.push_back(new Ps2FilesystemNode("pfs0:"));
if (g_systemPs2->usbMassPresent())
list.push_back(new Ps2FilesystemNode("mass:"));
if (g_systemPs2->netPresent())
list.push_back(new Ps2FilesystemNode("host:"));
if (g_systemPs2->mcPresent())
list.push_back(new Ps2FilesystemNode("mc0:"));
return true;
} else {
int fd;
if (_path == "pfs0:")
fd = fio.dopen("pfs0:/");
else
fd = fio.dopen(_path.c_str());
// dbg_printf("dopen = %d\n", fd);
if (fd >= 0) {
iox_dirent_t dirent;
Ps2FilesystemNode dirEntry;
int dreadRes;
while ((dreadRes = fio.dread(fd, &dirent)) > 0) {
if (dirent.name[0] == '.')
continue; // ignore '.' and '..'
if ( (mode == Common::FSNode::kListAll) ||
((mode == Common::FSNode::kListDirectoriesOnly) &&
(dirent.stat.mode & FIO_S_IFDIR)) ||
((mode == Common::FSNode::kListFilesOnly) &&
!(dirent.stat.mode & FIO_S_IFDIR)) ) {
dirEntry._isHere = true;
dirEntry._isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
dirEntry._isRoot = false;
dirEntry._path = _path;
dirEntry._path += dirent.name;
if (dirEntry._isDirectory && dirEntry._path.lastChar() != '/')
dirEntry._path += '/';
dirEntry._displayName = dirent.name;
dirEntry._verified = true;
list.push_back(new Ps2FilesystemNode(&dirEntry));
}
}
fio.dclose(fd);
return true;
}
}
return false;
}
示例13: listVolumes
AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
ENTER();
AbstractFSList myList;
const uint32 kLockFlags = LDF_READ | LDF_VOLUMES;
char buffer[MAXPATHLEN];
struct DosList *dosList = IDOS->LockDosList(kLockFlags);
if (!dosList) {
debug(6, "Cannot lock the DOS list");
LEAVE();
return myList;
}
dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
while (dosList) {
if (dosList->dol_Type == DLT_VOLUME &&
dosList->dol_Name &&
dosList->dol_Port) {
// The original line was
//if (dosList->dol_Type == DLT_VOLUME &&
//dosList->dol_Name &&
//dosList->dol_Task) {
// which errored using SDK 53.24 with a 'struct dosList' has no member called 'dol_Task'
// The reason for that was that
// 1) dol_Task wasn't a task pointer, it is a message port instead
// 2) It was redefined to be dol_Port in dos/obsolete.h in afore mentioned SDK
// Copy name to buffer
IDOS->CopyStringBSTRToC(dosList->dol_Name, buffer, MAXPATHLEN);
// Volume name + '\0'
char *volName = new char [strlen(buffer) + 1];
strcpy(volName, buffer);
strcat(buffer, ":");
BPTR volumeLock = IDOS->Lock((STRPTR)buffer, SHARED_LOCK);
if (volumeLock) {
char *devName = new char [MAXPATHLEN];
// Find device name
IDOS->DevNameFromLock(volumeLock, devName, MAXPATHLEN, DN_DEVICEONLY);
sprintf(buffer, "%s (%s)", volName, devName);
delete[] devName;
AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, buffer);
if (entry) {
myList.push_back(entry);
}
IDOS->UnLock(volumeLock);
}
delete[] volName;
}
dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
}
IDOS->UnLockDosList(kLockFlags);
LEAVE();
return myList;
}
示例14: getChildren
bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
ENTER();
bool ret = false;
// TODO: Honor the hidden flag
// There is no such thing as a hidden flag in AmigaOS...
if (!_bIsValid) {
debug(6, "Invalid node");
LEAVE();
return false; // Empty list
}
if (!_bIsDirectory) {
debug(6, "Not a directory");
LEAVE();
return false; // Empty list
}
if (isRootNode()) {
debug(6, "Root node");
LEAVE();
myList = listVolumes();
return true;
}
APTR context = IDOS->ObtainDirContextTags( EX_FileLockInput, _pFileLock,
EX_DoCurrentDir, TRUE, /* for softlinks */
EX_DataFields, (EXF_NAME|EXF_LINK|EXF_TYPE),
TAG_END);
if (context) {
struct ExamineData * pExd = NULL; // NB: No need to free the value after usage, everything will be dealt with by the DirContext release
AmigaOSFilesystemNode *entry ;
while ( (pExd = IDOS->ExamineDir(context)) ) {
if ( (EXD_IS_FILE(pExd) && ( Common::FSNode::kListFilesOnly == mode ))
|| (EXD_IS_DIRECTORY(pExd) && ( Common::FSNode::kListDirectoriesOnly == mode ))
|| Common::FSNode::kListAll == mode
)
{
BPTR pLock = IDOS->Lock( pExd->Name, SHARED_LOCK );
if (pLock) {
entry = new AmigaOSFilesystemNode( pLock, pExd->Name );
if (entry) {
myList.push_back(entry);
}
IDOS->UnLock(pLock);
}
}
}
if (ERROR_NO_MORE_ENTRIES != IDOS->IoErr() ) {
debug(6, "An error occurred during ExamineDir");
ret = false;
} else {
ret = true;
}
IDOS->ReleaseDirContext(context);
} else {
debug(6, "Unable to ObtainDirContext");
ret = false;
}
LEAVE();
return ret;
}
示例15: getChildren
bool BadaFilesystemNode::getChildren(AbstractFSList &myList,
ListMode mode, bool hidden) const {
AppAssert(isDirectory());
bool result = false;
if (_isVirtualDir && mode != Common::FSNode::kListFilesOnly) {
// present well known BADA file system areas
if (_path == PATH_ROOT) {
myList.push_back(new BadaFilesystemNode(PATH_HOME));
myList.push_back(new BadaFilesystemNode(PATH_HOME_EXT));
myList.push_back(new BadaFilesystemNode(PATH_MEDIA));
myList.push_back(new BadaFilesystemNode(PATH_CARD));
result = true; // no more entries
} else if (_path == PATH_CARD) {
myList.push_back(new BadaFilesystemNode(PATH_CARD_MEDIA));
result = true; // no more entries
} else if (_path == PATH_HOME) {
// ensure share path is always included
myList.push_back(new BadaFilesystemNode(PATH_HOME_SHARE));
myList.push_back(new BadaFilesystemNode(PATH_HOME_SHARE2));
}
}
if (!result) {
DirEnumerator *pDirEnum = 0;
Directory *pDir = new Directory();
// open directory
if (IsFailed(pDir->Construct(_unicodePath))) {
AppLog("Failed to open directory: %S", _unicodePath.GetPointer());
} else {
// read all directory entries
pDirEnum = pDir->ReadN();
if (pDirEnum) {
result = true;
}
// loop through all directory entries
while (pDirEnum && pDirEnum->MoveNext() == E_SUCCESS) {
DirEntry dirEntry = pDirEnum->GetCurrentDirEntry();
// skip 'invisible' files if necessary
Osp::Base::String fileName = dirEntry.GetName();
if (fileName[0] == '.' && !hidden) {
continue;
}
// skip '.' and '..' to avoid cycles
if (fileName == L"." || fileName == L"..") {
continue;
}
// Honor the chosen mode
if ((mode == Common::FSNode::kListFilesOnly && dirEntry.IsDirectory()) ||
(mode == Common::FSNode::kListDirectoriesOnly && !dirEntry.IsDirectory())) {
continue;
}
myList.push_back(new BadaFilesystemNode(_path, fromString(fileName)));
}
}
// cleanup
if (pDirEnum) {
delete pDirEnum;
}
// close the opened directory
if (pDir) {
delete pDir;
}
}
return result;
}