On Apr 24, 2008, at 6:54 AM, luke saunders wrote:

On Wed, Apr 23, 2008 at 8:42 PM, Matt S Trout <dbix- [EMAIL PROTECTED]> wrote:
On Wed, Apr 23, 2008 at 04:37:54PM +0100, Drew Taylor wrote:
What if you used link() instead of a copy?

Or just make the dump code make the tmp dir, and populate open a file handle to everything in advance so you don't have to worry about paths changing
under you?

As I understand your suggestion, dumping to the tmp dir wouldn't work for me because I make a dump only every so often, but populate from it
many times per day as I run my tests. I just want to zip through the
existing files w/o any IO other than reading/slurping the .fix files.

If dumping uses a temp dir, and populate just opens the filehandles,
that's exactly what you'd get.


Seems like a reasonable idea. My understanding here is that if a
filehandle is opened and that file is then removed, the filehandle can
still be read from. However I'm not clear on how that works,
presumably Perl doesn't read the file into memory when you first open
the handle, so what happens?

What happens (on reasonable OSes anyway) is that the original file still exists, even if there are no references to it in the directory structure. In perl terms, you can think of both the directory entry and the filehandle as references, pointing to the same underlying data. The file doesn't actually go away until it's refcount drops to 0, which means that all the references to it in the directory structure are gone, and any filehandles that reference it are closed. If you delete the original directory entry that pointed to it, and create a new file in it's place, that reference doesn't point at the original data, it's a new reference pointing to a new chunk of data on the disk.

Also I don't think link() works on all platforms.

This isn't entirely portable either, but I don't have any recent enough windows experience to say if it will explode on versions of windows released in this century or not...

--
Jason Kohles, RHCA RHCDS RHCE
[EMAIL PROTECTED] - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to