Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2004

    Creating very big files raipdly

    I am trying to create big files (up to several megabytes) on my Symbian device and am experiencing some problems.

    Dealing with files on the memory card (flash) is a piece of cake because the file system (Fat) is able to recognize file sizes set using the method RFile::SetSize. This is no problem. I am able to set my file to any desired size.

    When it comes to the internal memory disk however, it is a bit trickier. It seems like this file system (Lffs) does not recognize file sizes set using the method above. This means I am bound to manually fill the file with data to achieve a file of a desired size. This is where the problem arises. Filling a file with e.g. 128 kB takes minutes on my device. I am using a simple for-loop that writes one "x" (on byte) to the file every loop.

    Is there a faster way to write huge amounts of data to files or some other way to aquire big files on the file system Lffs?

    Oh, and I am using temporary files but that should not matter.

    Thank you,

    Pink Lemonade

  2. #2
    Regular Contributor
    Join Date
    May 2003
    Nice, France
    Well, I don't know why RFile::SetSize does not work on internal card (maybe your disk is fragmented and for some reason there is no contigous room for the size you specify?).

    But writing bytes one by one is definitively NOT a good way to do that!!! Why don't you use at least 1K each time?
    Something like that (code written "as-is", ie never tested nor compiled):
    void CFileUtilities::SetFileSizeL(RFile& aFile, TInt aFileLength)
    #define BUF_SIZE 1024

    HBufC8* dummyBuffer = HBufC8::NewLC(BUF_SIZE);
    while (aFileLength > 0) {
    TInt nbBytesToWrite = min(aFileLength, BUF_SIZE);
    User::LeaveIfError(aFile.Write(*dummyBuffer, nbBytesToWrite));
    aFileLength -= nbBytesToWrite;

    But I think you should try to understand why SetSize fails. Do you have an error? Which one is it?


  3. #3
    Registered User
    Join Date
    Feb 2004
    Thank you for your quick answer, Daniel.

    The reason why SetSize does not work on the internal memory disk seems to lie in the nature of the file system (Lffs). I did read about this in some other thread but there was no sollution to the problem nor any accurate explanation. It does not generate any error. The file simply appears with the correct size but the free amount of disk space is not altered. I can tell because my code using SetSize works nicely on the Fat-file system.

    I will take at closer look at your code and see if it speeds up my program decently.

    Thank you once again.

Posting Permissions

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