×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    6

    Reading a Binary file

    Hi,
    I have a binary file to read and I wanna do it in series 60 symbian device.
    I m comfertable doing it in BREW where i create a file pointer and keep on reading the data.
    But what is the procedure in Symbian?
    Where am i suppose to keep my file? Y do i need a RFs session. How do i create its objects? I do i create an instance of TBUF and TBuf8?
    Here is what i did

    TBuf<50> Buffer_TB;
    TDes8& Data_TD8 = (TDes8&)Buffer_TB;
    RFs Session_RFs;
    User::LeaveIfError(Session_RFs.Connect());
    Session_RFs.MkDirAll(KDIR_NAME);

    RFile LevelFile_RF;
    User::LeaveIfError(LevelFile_RF.Open(Session_RFs,KFILE_NAME,EFileRead));

    Session_RFs.Close();
    LevelFile_RF.Close();


    I dont even know if it is correct!!!
    If somebody has done a binary file read pls help.....
    I need it

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6

    New problem

    Well i got the code to work and its storing the values properly. But i m stuck with a new problem.
    RFile.Read reads into a TBuf object but i need to get this value into a TInt16.
    Here is my code that is working

    RFs Session_RFs;
    User::LeaveIfError(Session_RFs.Connect());
    Session_RFs.MkDirAll(KDIR_NAME);
    RFile LevelFile_RF;
    User::LeaveIfError(LevelFile_RF.Open(Session_RFs,KFILE_NAME,EFileRead));
    TBuf8<1> Data_TB8;
    LevelFile_RF.Read(Data_TB8);

    TInt16 MapWidth_n16_m_ = Data_TB8.iBuf //this gives error

    LevelFile_RF.Read(Data_TB8);

    LevelFile_RF.Close();
    Session_RFs.Close();

    following are the error I am getting.

    error C2248: 'iBuf' : cannot access protected member declared in class 'TBuf8<1>'
    \Symbian\7.0s\Series60_v20\EPOC32\INCLUDE\e32des8.h(276) : see declaration of 'iBuf'
    D:\SYMBIAN\7.0S\SERIES60_V20\SERIES60EX\PREDATOR\SRC\Tilemap.cpp
    error C2440: '=' : cannot convert from 'unsigned char [4]' to 'signed char'
    This conversion requires a reinterpret_cast, a C-style cast or function-style cast

    I actually need to read 2 byte(one at a time) and then write it to 2 different TInt16 values and then OR those two TInt16 to get the actual value.
    I can easily do it in C or C++ , but how do i do it in Symbian??
    plzzzzzzzz help. M so close but still sooo far

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6

    I got it

    Well i got it.
    using filestreams

    thnx 4 viewing the post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×