From: John Hodge Date: Mon, 24 Oct 2011 01:36:12 +0000 (+0800) Subject: AcessNative - Implemented ReadDir in nativefs X-Git-Tag: rel0.14~200 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=08da2c76fdd23f09118f86bc1ebaa8f8378791c1;p=tpg%2Facess2.git AcessNative - Implemented ReadDir in nativefs --- diff --git a/AcessNative/acesskernel_src/Makefile.BuildNum b/AcessNative/acesskernel_src/Makefile.BuildNum index c5576010..6e0adbc1 100644 --- a/AcessNative/acesskernel_src/Makefile.BuildNum +++ b/AcessNative/acesskernel_src/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 29 +BUILD_NUM = 33 diff --git a/AcessNative/acesskernel_src/nativefs.c b/AcessNative/acesskernel_src/nativefs.c index 9de8ae2d..ca2f7dfe 100644 --- a/AcessNative/acesskernel_src/nativefs.c +++ b/AcessNative/acesskernel_src/nativefs.c @@ -127,12 +127,16 @@ tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name) baseRet.FindDir = NativeFS_FindDir; baseRet.ReadDir = NativeFS_ReadDir; baseRet.Flags |= VFS_FFLAG_DIRECTORY; + baseRet.Size = -1; } else { LOG("File"); baseRet.Inode = (Uint64) fopen(path, "r+"); baseRet.Read = NativeFS_Read; + + fseek( (FILE*)(tVAddr)baseRet.Inode, 0, SEEK_END ); + baseRet.Size = ftell( (FILE*)(tVAddr)baseRet.Inode ); } // Create new node @@ -146,9 +150,30 @@ tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name) char *NativeFS_ReadDir(tVFS_Node *Node, int Position) { - // Keep track of the current directory position - // TODO: Implement NativeFS_ReadDir - return NULL; + struct dirent *ent; + DIR *dp = (void*)(tVAddr)Node->Inode; + char *ret; + + ENTER("pNode iPosition", Node, Position); + + // TODO: Keep track of current position in the directory + // TODO: Lock node during this + rewinddir(dp); + do { + ent = readdir(dp); + } while(Position-- && ent); + + if( !ent ) { + LEAVE('n'); + return NULL; + } + + ret = strdup(ent->d_name); + + // TODO: Unlock node + + LEAVE('s', ret); + return ret; } Uint64 NativeFS_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)