Changeset 236a439a5f7af66e6558a957dcbcbf34fcdbc680

Show
Ignore:
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:
1 modified

Legend:

Unmodified
Added
Removed
  • src/window.cpp

    r5843bef r236a439  
    10691069void Gobby::Window::save_local_file(Document& doc, const Glib::ustring& file) 
    10701070{ 
    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 
    10791074        try 
    10801075        { 
     
    10841079                                _("Could not open file '%0%' for writing") 
    10851080                        ); 
    1086                         str << temp_filename; 
     1081                        str << file; 
    10871082                        throw std::runtime_error(str.str() ); 
    10881083                } 
     
    10911086                stream << doc.get_content().raw(); 
    10921087                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                 } 
    11031088 
    11041089                // Set path of document