×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    12

    Post Reading 'N' no of bytes from a file

    Hi,
    Here is the code snippet I am using to read a file data in a buffer.

    RFs fsSession;
    User::LeaveIfError(fsSession.Connect());
    RFile file;
    User::LeaveIfError(file.Open(fsSession,InputFileName,EFileShareExclusive|EFileRead));
    TInt fileSize;
    file.Size(fileSize);

    HBufC8* encData = HBufC8::NewLC(fileSize);
    TPtr8 encDataPtr = encData->Des();
    file.Read(encDataPtr);
    file.Close();


    From this I have to separate first 16 bit data and pass the remaining buffer to another function for further processing of the file.
    Can I do the normal pointer addition like encDataPtr + 16 and pass the pointer to the funtion or I have to do any conversion???
    I am a C++ developer just learning Symbian, so lot of confusion about the descritors. Plz any one help me to get the first 16 bit data and to pass the remaining to the function.

    I tried with encDataPtr + 16 and I got an error like ..\src\EncDec.cpp:165: illegal operands 'TPtr8' + 'int'

    Regards
    Rajeev

  2. #2
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Reading 'N' no of bytes from a file

    there are many API's available for doing descriptor manipulation.

    You can extract any portion , any length api's which can help you in this are Left, right, Mid etc. Please go through the api provided in the SDK.

    like you can use this one to extract the data after first 16 bytes.

    TPtr8 MidTPtr(TInt aPos) const;
    Regards,
    Shafali

  3. #3
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,988

    Re: Reading 'N' no of bytes from a file

    How about using this function from RFile:

    TInt Read(TDes8 &aDes, TInt aLength)

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Reading 'N' no of bytes from a file

    HBufC and TPtr are objects. However they have a Ptr method which gives you a pointer.
    Also note that HBufC may be oversized, so consider using Vineet.jain's suggestion.

Similar Threads

  1. help~~~about the CMdaAudioInputStream
    By Dragon_L in forum Symbian Media (Closed)
    Replies: 14
    Last Post: 2008-11-05, 06:11
  2. Replies: 15
    Last Post: 2007-10-24, 13:47
  3. Help needed with a 3gp file...
    By joedoe_1981 in forum Streaming and Video
    Replies: 0
    Last Post: 2007-07-18, 18:58
  4. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  5. reading text file from a jar file -> file not found!
    By iecomdev in forum Mobile Java General
    Replies: 1
    Last Post: 2002-09-30, 12:27

Posting Permissions

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