AcessNative - Added write support to nativefs
authorJohn Hodge <[email protected]>
Fri, 13 Jul 2012 04:53:03 +0000 (12:53 +0800)
committerJohn Hodge <[email protected]>
Fri, 13 Jul 2012 04:53:03 +0000 (12:53 +0800)
AcessNative/acesskernel_src/nativefs.c

index cfdae75..4fc0f31 100644 (file)
@@ -33,10 +33,12 @@ void        NativeFS_Unmount(tVFS_Node *Node);
 tVFS_Node      *NativeFS_FindDir(tVFS_Node *Node, const char *Name);\r
 char   *NativeFS_ReadDir(tVFS_Node *Node, int Position);\r
 size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void *Buffer);\r
+size_t NativeFS_Write(tVFS_Node *Node, _acess_off_t Offset, size_t Length, const void *Buffer);\r
 \r
 // === GLOBALS ===\r
 tVFS_NodeType  gNativeFS_FileNodeType = {\r
-       .Read = NativeFS_Read\r
+       .Read = NativeFS_Read,\r
+       .Write = NativeFS_Write,\r
 };\r
 tVFS_NodeType  gNativeFS_DirNodeType = {\r
        .FindDir = NativeFS_FindDir,\r
@@ -187,11 +189,27 @@ char *NativeFS_ReadDir(tVFS_Node *Node, int Position)
 size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void *Buffer)\r
 {\r
        ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);\r
-       if( fseek( (void *)(tVAddr)Node->Inode, Offset, SEEK_SET ) != 0 )\r
+       if( fseek( (FILE *)(tVAddr)Node->Inode, Offset, SEEK_SET ) != 0 )\r
        {\r
                LEAVE('i', 0);\r
                return 0;\r
        }\r
        LEAVE('-');\r
-       return fread( Buffer, 1, Length, (void *)(tVAddr)Node->Inode );\r
+       return fread( Buffer, 1, Length, (FILE *)(tVAddr)Node->Inode );\r
+}\r
+\r
+size_t NativeFS_Write(tVFS_Node *Node, _acess_off_t Offset, size_t Length, const void *Buffer)\r
+{\r
+       FILE    *fp = (FILE *)(tVAddr)Node->Inode;\r
+       ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer);\r
+       if( fseek( fp, Offset, SEEK_SET ) != 0 )\r
+       {\r
+               LEAVE('i', 0);\r
+               return 0;\r
+       }\r
+       size_t ret = fwrite( Buffer, 1, Length, fp );\r
+       fflush( fp );\r
+       LEAVE('i', ret);\r
+       return ret;\r
+\r
 }\r

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