File handling ideas ??? (Real Studio network user group Mailinglist archive)
Back to the thread list
Previous thread: Conkey Software
Next thread: [ANN] REAL Software Releases REALbasic 5.2.1 Update
|File handling ideas ???|
|Date: 13.08.03 15:43 (Wed, 13 Aug 2003 16:43:11 +0200)|
|From: Jan Erik Moström <|
I would like to ask how you would solve this problem:
I'm writing a class that does some manipulation of text before writing
to a file. One of the thing is that the class should do is to replace
certain tags with the name of the first, last, next and prev files. It
will be called in this way (template is an instance of this class)
for i = 1 to nrOfRecords
// some processing
So I know beforehand how many records/files that will be written, but I
don't know what the name of the last file is, when I write the records
before and the names/references are generated dynamically (they get a
name of the pattern 'prefix000023.html' where the number part is the
dynamic part and if a file/folder with a certain name already exists I
just increase the number and try until I find a unique file name).
I can easily handle the tags that represent the first, next and prev
files but the last is a bit of a problem. I need to know it to replace
the last tag in all files, but I don't know the name until the last
record ... this suggests a two-pass writing.
This wouldn't be a problem either if the number of records was small,
then I could just save a folderitem for each file in an array and pass
over all files once more ... but if the number of files are large I can
imagine that size of this array can be quite big.
So my ideas for solutions are:
1 Don't bother. Just use the array and let the OS handle the
memory, probably works for 99.99% of the cases but ...
2 Write the folderitem info to a temp file and then read it again
when it's time for the second pass.
3 Save all text info to a temp file, and then start by writing
the last and first file, followed by the rest.
Nr 1 is easiest but will use most memory, nr 2 should work for any
number of files (or at least until the disk is full 8-) but will use
least memory while nr 3 is probably something inbetween when it comes to
Any better suggestions?
|Re: File handling ideas ???|
|Date: 13.08.03 19:43 (Wed, 13 Aug 2003 11:43:11 -0700)|
|From: Will Leshner|
My guess is that you'd probably have to get to tens of thousands of
files before it would really start to be a problem.
Jan Erik Moström wrote:
> Will Leshner <<email address removed>> (2003-08-13 8:49) wrote:
>>Just how many files are we talking about here?
> To be honest, I have no idea at all. Right now, not that many but this
> class is going to be a part of my "tool chest" ... and will probably be
> used in several different application during the next year.
>>And what platform(s) will it have to run on?
> OS X, OS 9 and Windows.
A searchable archive of this list is available at:
Unsubscribe or switch delivery mode: