1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-08 15:21:12 +00:00

ttvfs update

This commit is contained in:
fgenesis 2014-04-15 15:04:33 +02:00
commit 3cf3ac7659
13 changed files with 220 additions and 120 deletions

View file

@ -5,6 +5,8 @@
#include "VFSTools.h"
#include <algorithm>
//#include <stdio.h>
VFS_NAMESPACE_START
@ -119,11 +121,10 @@ void InternalDir::forEachDir(DirEnumCallback f, void *user /* = NULL */, bool sa
bool InternalDir::fillView(const char *path, DirView& view)
{
SkipSelfPath(path);
view.init(path);
size_t len = strlen(path) + 1;
size_t len = view.fullnameLen() + 1;
char *pathcopy = (char*)VFS_STACK_ALLOC(len);
memcpy(pathcopy, path, len);
memcpy(pathcopy, view.fullname(), len);
bool added = _addToView(pathcopy, view);
VFS_STACK_FREE(pathcopy);
return added;
@ -132,6 +133,7 @@ bool InternalDir::fillView(const char *path, DirView& view)
bool InternalDir::_addToView(char *path, DirView& view)
{
bool added = false;
SkipSelfPath(path);
if(!*path)
{
@ -143,14 +145,20 @@ bool InternalDir::_addToView(char *path, DirView& view)
}
else
{
SkipSelfPath(path);
char dummy = 0;
char slash[2] = {'/', 0};
char *slashpos = strchr(path, '/');
char *tail = slashpos ? slashpos+1 : &dummy;
// if the first char is a slash, use "/" to lookup
if(slashpos == path)
path = &slash[0];
if(slashpos)
*slashpos = 0;
//printf("InternalDir::_addToView [%s] [%s]\n", path, tail);
for(MountedDirs::iterator it = _mountedDirs.begin(); it != _mountedDirs.end(); ++it)
if(DirBase *subdir = (*it)->getDirByName(path))
added = subdir->_addToView(tail, view) || added;