Crystal Space
Welcome, Guest. Please login or register.
October 24, 2017, 06:38:59 am

Login with username, password and session length
Search:     Advanced search
9063 Posts in 2051 Topics by 77930 Members
Latest Member: Asknbalive
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  How to binary-read a file on VFS?
« previous next »
Pages: [1] Print
Author Topic: How to binary-read a file on VFS?  (Read 3703 times)
Full Member
Posts: 101

View Profile WWW Email
« on: July 04, 2006, 12:40:15 pm »

i need to rewrite this in VFS:
    FILE *f;
    f = fopen (filename, "rb");
    if (f == NULL)
        return false;
    fread (&version, sizeof (TBXVersion), 1, f);
so i tried this:
    csRef<iVFS> vfs;
    vfs = csQueryRegistry<iVFS> (obj_reg);
    csRef<iFile> f = vfs->Open (filename, VFS_FILE_READ);
    f->Read (version, sizeof (TBXVersion));
but i get errors:
tbx.cpp: In member function `bool TBXFile::Open(char*)':
tbx.cpp:14: error: no matching function for call to `iFile::Read(TBXVersion&,
   unsigned int)'
/usr/local/include/crystalspace/iutil/vfs.h:134: error: candidates are: virtual
   size_t iFile::Read(char*, unsigned int)
make: *** [obj/tbx.o] Error 1
so how to read structures?


Hero Member
Posts: 1706

View Profile
« Reply #1 on: July 28, 2006, 12:04:22 pm »

Note that in general you should avoid to read binary structures as that is highly unportable. But if you really want to do it I recommend you take a look at the iFile API. There are methods there to read data in a buffer which you can then copy to the structure.

Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.172 seconds with 15 queries.