Hi people,
I'm trying to write a handy utility class that lets me write to
files, quickly, and safely.
The idea is, that it creates a temp file, and then after the save
operation is complete, it renames the temp file over to the old
file's name. (It deletes the old file before renaming the temp file.)
Now, this has one main problem. File metadata. Creation dates, unix
permissions, finder label coloring, all that sort of stuff.
Is there some handy way to copy file metadata from one file to
another? Setting the file's creation date is no problem. But what
about the Unix permissions? I'd be pretty annoyed if I edited a nice
perl script, only to find that this script no longer executes due to
unix permissions disapearing :(
Anyone made a handy "CopyFileMeta(fromFile as folderitem, toFile as
folderitem)" function??
I'd really like it, if anyone has it.
For anyone who uses my ElfData plugin... this utility class is pretty
handy! It's just a subclass of my FastString class, so basically, it
writes directly into the file! This saves huge allocation of RAM,
when all we really wanted to do was dump that data to file, anyhow.
The FastString class is still faster than using a binarystream
directly, due to my FastString class's fast buffered approach, and
also FastString has tons of utility methods that BinaryStream doesn't
offer, such as .AppendIntegerAsText .
This technique is also really cool, because you can write to a file,
or write to an ordinary string, and all your writing code stays the
same, because it's just writing to a FastString class! By
subclassing, we can just redirected the outputted stream whereever we
like :) I suppose my FastString class is stream-like in that respect.
At least, it has that capability, although it's sort of neatly tucked
away in an RB subclassed event, without being overly obvious. Thus it
doesn't impose stream-like overhead in the coding or understanding of
FastString. You can simplistically think of FastString as just a
buffer and get 90% of the functionality from FastString.
I might release this utility class sometime, after it's done of course.
--
http://elfdata.com/plugin/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>