AcessNative - Implemented ReadDir in nativefs
authorJohn Hodge <[email protected]>
Mon, 24 Oct 2011 01:36:12 +0000 (09:36 +0800)
committerJohn Hodge <[email protected]>
Mon, 24 Oct 2011 01:36:12 +0000 (09:36 +0800)
AcessNative/acesskernel_src/Makefile.BuildNum
AcessNative/acesskernel_src/nativefs.c

index 9de8ae2..ca2f7df 100644 (file)
@@ -127,12 +127,16 @@ tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name)
                baseRet.FindDir = NativeFS_FindDir;\r
                baseRet.ReadDir = NativeFS_ReadDir;\r
                baseRet.Flags |= VFS_FFLAG_DIRECTORY;\r
+               baseRet.Size = -1;\r
        }\r
        else\r
        {\r
                LOG("File");\r
                baseRet.Inode = (Uint64) fopen(path, "r+");\r
                baseRet.Read = NativeFS_Read;\r
+               \r
+               fseek( (FILE*)(tVAddr)baseRet.Inode, 0, SEEK_END );\r
+               baseRet.Size = ftell( (FILE*)(tVAddr)baseRet.Inode );\r
        }\r
        \r
        // Create new node\r
@@ -146,9 +150,30 @@ tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name)
 \r
 char *NativeFS_ReadDir(tVFS_Node *Node, int Position)\r
 {\r
-       // Keep track of the current directory position\r
-       // TODO: Implement NativeFS_ReadDir\r
-       return NULL;\r
+       struct dirent   *ent;\r
+       DIR     *dp = (void*)(tVAddr)Node->Inode;\r
+       char    *ret;\r
+\r
+       ENTER("pNode iPosition", Node, Position);\r
+\r
+       // TODO: Keep track of current position in the directory\r
+       // TODO: Lock node during this\r
+       rewinddir(dp);\r
+       do {\r
+               ent = readdir(dp);\r
+       } while(Position-- && ent);\r
+\r
+       if( !ent ) {\r
+               LEAVE('n');\r
+               return NULL;\r
+       }\r
+       \r
+       ret = strdup(ent->d_name);\r
+\r
+       // TODO: Unlock node    \r
+\r
+       LEAVE('s', ret);\r
+       return ret;\r
 }\r
 \r
 Uint64 NativeFS_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r

UCC git Repository :: git.ucc.asn.au