From: "Steve [RubyTalk]" Date: 2005-12-02T20:55:11+09:00 Subject: Re: What is the best way to edit a file to eliminate a line Alan Chen wrote: > I don't think you can get away without a tempfile and get safe > "in-place" > modifications. It looks to me like the best compromise would be to > > - read in the original > - write the modified file to a temp (use ruby's 'tempfile' which, I > think, should create a temp with secure permissions) > - use the most atomic os facility you can to copy the modified atop the > original > > On many platforms this might map to Rubys File.rename or FileUtils.mv, > I'm not sure... > Yup... that seems pretty reasonable to me too....though I have to say I'm surprised that I seem to be defining something to do this rather than just using a library component. It's exactly the sort of thing I'd have previously been sure someone would have contributed. Steve