×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Problems with reading symbian binary file on windows platform.

    Hi.

    I have two appliactions. One application (on symbian platform) creating binary file. Then second application (on windows platform) copies it to desktop and tries to read it. It reads it, but in inproper way. Why? Is there any way to convert it?

    Justine

  2. #2
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    155

    Re: Problems with reading symbian binary file on windows platform.

    Improper how?

    Little Endian versus big Endian ?

    How was it created on Symbian, if it wasn't using the file write primatives there is likley to be proprietary data in the file.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Hi

    So for example first variable, which is written on symbian to file is Int32 and then string, but when I read Int32 in visual studia .net application by using BinaryReader it has diffrent value and string isn't read in proper way.
    So as you said problem might be with writing strings but it shouldn't be any with e.g. Int32.

    Justine

  4. #4
    Regular Contributor
    Join Date
    May 2004
    Posts
    462

    Re: Problems with reading symbian binary file on windows platform.

    Hi, how do you write binary data to file in Symbian? It shouldn't be a problem if you did correctly. One way to check it is to open the binary file with binary editor from visual studio.


    I use RFileWriteStream, and it works fine.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Hi

    Maybe it is a problem, because I save file on Symbian in inproper way. I save it like this:

    Code:
    User::LeaveIfError(iFs.Connect());
    	CFileStore* store = CDirectFileStore::ReplaceLC(iFs,iFile,EFileWrite);
    	store->SetTypeL(KDirectFileStoreLayoutUid);
            RStoreWriteStream stream;
    	TStreamId id = stream.CreateLC(*store);
    	TInt count= DBMSub->CountProduct();
    	stream.WriteInt32L(count);
            stream.CommitL();
    	CleanupStack::PopAndDestroy();
    	store->SetRootL(id);
    	store->CommitL();
    	CleanupStack::PopAndDestroy();
    	iFs.Close();
    iFile is the name of the file and here it is like I write Int32. And I read it in .net like this:

    Code:
    FileStream fs = File.OpenRead(strTmpDatFile);
              BinaryReader reader = new BinaryReader(fs);
              int count;
              count = reader.ReadInt32();
              reader.Close();
    Justine

  6. #6
    Regular Contributor
    Join Date
    May 2004
    Posts
    462

    Re: Problems with reading symbian binary file on windows platform.

    I think CFileStore also stores some other data(Header, symbian own defined syntax), so you have to write pure binary data in order to be compatible on PC or you can parse the file on pc if you know the file data structure.

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Hi.

    So I've changed it and right now it looks like this:

    Code:
            RFile file;
    
    	User::LeaveIfError(file.Replace(iFs,iFile,EFileWrite)); 
    	RFile f=file; 
    	RFileWriteStream out(f); 
        	
    	TInt count= DBMSub->CountProduct();
    	out.WriteInt32L(count);
    It doesn't have any problems with writing prmitive types, but it has with strings. Do you write strings char after char or is there any smarter solution?

    Justine

    But still .net doesn't read it in proper wayI have the same problem still

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Sorry in previous post shouldn't be this:

    "But still .net doesn't read it in proper wayI have the same problem still"

  9. #9
    Regular Contributor
    Join Date
    May 2004
    Posts
    462

    Re: Problems with reading symbian binary file on windows platform.

    I m not so sure how much data you want to write. I need write lots of data, so I also define the binary data syntax. each module has a 32bit id and 32 bit length. for string, I will write the legnth (TInt32) first, followed is the data, I use WriteL(const TUint8 *aPtr, TInt aLength) or 16 bits version.

    Also, be careful with byte allignment.

    Good luck.

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Thanks.

    I'll try it. I also have sended another post about conversion, maybe it is sth diffrent. Thanks for replying

    Justine

  11. #11
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Sorry. I've just caught the idea. I've spotted that VS ReadString() needs first size then data.

    Thanks very much

    Justine

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    And the last question you wrote:
    Code:
    WriteL(const TUint8 *aPtr, TInt aLength)
    for what u use this?

    for example:

    Code:
    	TPtrC symbol;
           _LIT(n1,"sth");
            symbol.Set(n1);
    
    	TInt32 length =symbol.Length();
    	out.WriteInt32L(length);
    	out.WriteL(symbol);
    isn't read by VS .net in proper way. Also this one:

    Code:
    	TPtrC symbol;
           _LIT(n1,"sth");
            symbol.Set(n1);
    
    	TInt32 length =symbol.Length();
    	out.WriteInt32L(length);
    	out<<symbol;;
    isn't corect

    Justine

  13. #13
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Even if I do it like this:

    Code:
    TInt32 i;
    	 TPtrC sth;
             _LIT(n1,"sth");
             sth.Set(n1);
             i=sth.Length();
             TUint8 *aPtr= new TUint8(i);
            out.WriteL(aPtr, i);
    	out<<sth;
    it doesn't work either. VS reads only first char, which is "\f". Then after this "\f" is our "sth" but I have to read it char after char. Any clues?

    Justine

  14. #14
    Registered User
    Join Date
    Oct 2006
    Posts
    45

    Re: Problems with reading symbian binary file on windows platform.

    Ok

    I just convert TInt32 to TInt8 and then save it, there is extra char, but I substring it in VS. net

    Justine

  15. #15
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    155

    Re: Problems with reading symbian binary file on windows platform.

    If you externalize a descriptor it will include the length of the data in the file, thus is not pure binary. Don't use the << operators. If you want to write a binary file just use RFile and its methods.

Similar Threads

  1. Downloading a Binary File using HTTP GET
    By razas in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2007-08-31, 19:53
  2. Replies: 1
    Last Post: 2006-08-28, 16:07
  3. Probelm after building abld file on C++ , Symbian 60 series environment
    By renaissancelabs in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-10-21, 09:47
  4. Symbian Development on Windows XP platform
    By ahmedb_ in forum Symbian
    Replies: 2
    Last Post: 2002-08-23, 06:38

Posting Permissions

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