Changeset 236a439a5f7af66e6558a957dcbcbf34fcdbc680
- Timestamp:
- 01/06/07 23:55:26 (6 years ago)
- Author:
- Philipp Kern <phil@…>
- Parents:
- e33c75600e7f2d70a5c290cbe1814b7582f37e98
- Children:
- d6b9af59ac2c315f9bac7e1c4c269e08e73c5d57
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:55:26Z+0000
- Message:
-
[project @ Atomic write failed if the destination directory was not on the same device as the temporary directory, use normal write]
Original author: Armin Burgmeier <armin@…>
Date: 2005-11-19 11:07:12+00:00
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5843bef
|
r236a439
|
|
| 1069 | 1069 | void Gobby::Window::save_local_file(Document& doc, const Glib::ustring& file) |
| 1070 | 1070 | { |
| 1071 | | // Write into a temporary file, rename afterwards |
| 1072 | | std::list<std::string> list; |
| 1073 | | list.push_back(Glib::get_tmp_dir() ); |
| 1074 | | list.push_back(Glib::path_get_basename(file) ); |
| 1075 | | std::string temp_filename(Glib::build_filename(list) ); |
| 1076 | | std::ofstream stream(temp_filename.c_str() ); |
| 1077 | | |
| 1078 | | // Could it be opened? |
| | 1071 | // Open stream to file |
| | 1072 | std::ofstream stream(file.c_str() ); |
| | 1073 | |
| 1079 | 1074 | try |
| 1080 | 1075 | { |
| … |
… |
|
| 1084 | 1079 | _("Could not open file '%0%' for writing") |
| 1085 | 1080 | ); |
| 1086 | | str << temp_filename; |
| | 1081 | str << file; |
| 1087 | 1082 | throw std::runtime_error(str.str() ); |
| 1088 | 1083 | } |
| … |
… |
|
| 1091 | 1086 | stream << doc.get_content().raw(); |
| 1092 | 1087 | stream.close(); |
| 1093 | | |
| 1094 | | // Rename file to destination path |
| 1095 | | if(std::rename(temp_filename.c_str(), file.c_str()) == -1) |
| 1096 | | { |
| 1097 | | obby::format_string str( |
| 1098 | | _("Could not save file '%0%': %1%") |
| 1099 | | ); |
| 1100 | | str << file << std::strerror(errno); |
| 1101 | | throw std::runtime_error(str.str() ); |
| 1102 | | } |
| 1103 | 1088 | |
| 1104 | 1089 | // Set path of document |