#461 Improve error message when use does not have proper file permissions

Next_release
open
nobody
None
5
2013-11-12
2013-03-11
Brian
No

Whenever a user does not have the correct filesystem permissions for writing to a file, Notepad++ gives a less-than-useful error popup:

"Save failed
Please check if this file is opened in another program."

The problem is not, in fact, that the file is opened in another program, but that the user did not have permission to modify the file. I have a small patch that will change the error message, which I intend to attach to this message shortly.

Discussion

  • Brian

    Brian - 2013-03-11

    Attaching a patch that fixes the error message to say:

    "Please check if this file is opened in another program, or if file permissions are set correctly."

     
  • Tobias

    Tobias - 2013-06-07

    Wouldn't it be better to check if the permission was denied via

    else if(errno == EACCES)
        *error_msg = TEXT("Failed to save file.\nPermission denied!");
    return false;
    

    in FileManager::SaveBuffer

     
  • Brian

    Brian - 2013-06-08

    Yeah, something like that would be better. I was just taking the easiest path :)

    In the interest of a better patch: where are you getting 'error_msg' from? I'm not too familiar with the Npp codebase, but I assume you're suggesting returning the error string as a new char* argument to FileManager::saveBuffer?

     
  • Tobias

    Tobias - 2013-06-09

    you're right ;) This would be the else path of if (fp) at the very bottom of saveBuffer, error_msg is already defined in this method. Maybe it is possible to check for some additional errors e.g. EBADF, ENOSPC, EMFILE and the like (see http://msdn.microsoft.com/en-us/library/5814770t.aspx), because "file already opened" and "permission denied" are not the only errors which might occur.

    Either way checking for the error in this specific method is not that great, because there are other methods handling file access where the same errors could occur. A more general approach would be better, but time consuming since some file access methods would have to be modified.

     
    Last edit: Tobias 2013-06-09
  • Brian

    Brian - 2013-06-10

    I think I might have been looking at an old version of the source code previously; now I see the 'error_msg' parameter in saveBuffer.

    Does Npp have a revision control system (git, mercurial, svn, etc.), or is source code only found by downloading the 7z source archive for the latest release?

    Could we just use something like strerror(), rather than hand-rolling the error strings?

    http://msdn.microsoft.com/en-us/library/zc53h9bh%28v=vs.71%29.aspx

     
  • Tobias

    Tobias - 2013-06-16

    The source code is managed by a revision control system... to check out the code: svn checkout svn://svn.code.sf.net/p/notepad-plus/code/trunk notepad-plus-code

    I guess it depends on how user-friendly the output of strerror is, but it seems to fit.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks