Ticket #5521: stylededit_stylededitwindow-iswritable.patch

File stylededit_stylededitwindow-iswritable.patch, 1.1 KB (added by ver, 10 years ago)

patch against svn 35718 (mar 2, 2010)

  • src/apps/stylededit/StyledEditWindow.cpp

     
    842842    status_t status = B_ERROR;
    843843    if (dir.InitCheck() == B_OK && entry.InitCheck() == B_OK) {
    844844        BFile file(&entry, B_READ_WRITE | B_CREATE_FILE);
    845         if (file.InitCheck() == B_OK)
     845        if (file.InitCheck() == B_OK) {
     846            // Ver: 2010-03-02 / Added check for read-only mode bit.
     847            if( file.IsWritable() == false ) {
     848                BString alertText;
     849                bs_printf(&alertText, TR("This file is marked Read-Only.  Save changes to the document \"%s\"? "), name);
     850   
     851                int32 index = _ShowAlert(alertText, TR("Cancel"), TR("Don't save"), TR("Save"),
     852                    B_WARNING_ALERT);
     853
     854                if (index == 0)
     855                    return B_ERROR; // "cancel": dont save, dont close the window
     856           
     857                if (index == 1)
     858                    return B_ERROR; // "don't save": just close the window
     859            }
     860
    846861            status = fTextView->WriteStyledEditFile(&file);
     862        }
    847863    }
    848864
    849865    if (status != B_OK) {