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.
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
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.