Some editors (like TextMate and at least my configuration of Vim) save
the file using an "atomic write".
They write the file to a new, temporary filename, and then rename the new
filename to the old filename. This assures that the file is never
"half-written" or corrupted in case of a crash.
The solicit() code didn't support this. By using seek() to rewind the
file pointer he was assuming that the editor was reusing the same inode.
Signed-off-by: Pedro Melo <melo@simplicidade.org>
: "could not launch ($editor) program: $!";
}
- unless ( seek $fh, 0, 0 ) {
+ my $new_fh;
+ if (!open($new_fh, '<', $filename)) {
croak "could not seek on temp file: errno=$!";
}
- return $fh;
+ return $new_fh;
}
# this method based on Recipe 15.2