mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-18 04:19:31 +00:00
Update inlcuded ttvfs
This commit is contained in:
parent
fe0a91129f
commit
ffa26e4105
22 changed files with 327 additions and 153 deletions
72
ExternalLibs/ttvfs/VFSDebug.cpp
Normal file
72
ExternalLibs/ttvfs/VFSDebug.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
#include "VFSDebug.h"
|
||||
#include "VFSInternal.h"
|
||||
#include "VFSRoot.h"
|
||||
#include "VFSDir.h"
|
||||
#include "VFSFile.h"
|
||||
#include "VFSTools.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
||||
|
||||
VFS_NAMESPACE_START
|
||||
namespace debug {
|
||||
|
||||
|
||||
struct _DbgParams
|
||||
{
|
||||
_DbgParams(std::ostream& os_, const std::string& path, const std::string& sp_)
|
||||
: os(os_), mypath(path), sp(sp_) {}
|
||||
|
||||
std::ostream& os;
|
||||
std::string mypath;
|
||||
const std::string& sp;
|
||||
std::set<std::string> dirnames;
|
||||
};
|
||||
|
||||
static void _DumpFile(File *vf, void *user)
|
||||
{
|
||||
_DbgParams& p = *((_DbgParams*)user);
|
||||
p.os << p.sp << " F:" << vf->fullname() << " [" << vf->getType() << ", ref " << vf->getRefCount() << ", 0x" << vf << "]" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
static void _DumpDir(DirBase *vd, void *user)
|
||||
{
|
||||
_DbgParams& p = *((_DbgParams*)user);
|
||||
if(!(vd->fullname()[0] == '/' && vd->fullnameLen() == 1)) // don't recurse down the root dir.
|
||||
p.dirnames.insert(vd->name());
|
||||
p.os << p.sp << "D : " << vd->fullname() << " [" << vd->getType() << ", ref " << vd->getRefCount() << ", 0x" << vd << "]" << std::endl;
|
||||
}
|
||||
|
||||
static void _DumpTree(_DbgParams& p, Root& vfs, int level)
|
||||
{
|
||||
p.os << ">> [" << p.mypath << "]" << std::endl;
|
||||
|
||||
vfs.ForEach(p.mypath.c_str(), _DumpFile, _DumpDir);
|
||||
|
||||
if(!level)
|
||||
return;
|
||||
|
||||
std::string sub = p.sp + " ";
|
||||
for(std::set<std::string>::iterator it = p.dirnames.begin(); it != p.dirnames.end(); ++it)
|
||||
{
|
||||
_DbgParams recP(p.os, joinPath(p.mypath, it->c_str()), sub);
|
||||
_DumpTree(recP, vfs, level - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void dumpTree(Root& root, std::ostream& os, const char *path /* = NULL */, int level /* = -1 */)
|
||||
{
|
||||
if(!path)
|
||||
path = "";
|
||||
os << ">>> FILE TREE DUMP <<<" << std::endl;
|
||||
_DbgParams recP(os, path, "");
|
||||
_DumpTree(recP, root, level);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace debug
|
||||
|
||||
VFS_NAMESPACE_END
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue