AcessNative - Fixing errors caused by API changes
[tpg/acess2.git] / AcessNative / acesskernel_src / nativefs.c
index 6d6e2fe..ca2f7df 100644 (file)
@@ -53,7 +53,10 @@ tVFS_Node *NativeFS_Mount(const char *Device, const char **Arguments)
        DIR     *dp;\r
        \r
        dp = opendir(Device);\r
-       if(!dp) return NULL;\r
+       if(!dp) {\r
+               Log_Warning("NativeFS", "ERRO: Unable to open device root '%s'", Device);\r
+               return NULL;\r
+       }\r
        \r
        // Check if directory exists\r
        // Parse flags from arguments\r
@@ -124,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
@@ -143,8 +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
-       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