pub fn save_data<P: AsRef<Path>, R: Read>(file_path: P, src: R) -> Result<()>Expand description
The data read from src is saved to file_path.
The file is updated safely.
This means that even if the operation is interrupted,
file_path is guaranteed to contain either the complete old data or the complete new data.
However, it is assumed that the data is permanently written to storage when
File::fsync_all()
completes successfully.
If file_path exists, the data is first written to a temporary file,
then the file is replaced using rename.
Additionally, a backup file of the original file is created.
The path of the backup file is file_path appended with .orig.