Prevent file loading
-
Is there an option to prevent file loading? We have some kind of logs that are encrypted by default. When NPP loads these files, it gets stuck for a some time since in encrypted version files consist of non-unicode symbols at all. So before I can press “Decrypt”, I have to wait. Sometimes, to wait a lot.
And I want to make an option to prevent file from loading once I get filename and determine that file is encrypted - so I will create new file manually and fill it with decrypted content. So far, everything works but prevention of opening of original file. -
welcome to the notepad++ community
if i understood your request correctly: yes you can prevent live files from being loaded again if a change has occured since the last opening
to prevent opened files from reloading, go to
settings > misc. > file status autodetection
then uncheck “enable”this way once opened you can decrypt it without the file being reloaded automatically, forcing you to wait again
if you want to reload the file manually, after changing this setting, you can do it manually from the menu:
file > reload from disk -
Well, that’s not what I’m talking about. It’s not about NPP settings, but about plugin messages.
I can catch
case NPPN_FILEBEFOREOPEN:
{
onBeforeOpen(notifyCode->nmhdr.idFrom);
}to run my decoder, smth like
void onBeforeOpen(uptr_t bID)
{
fileName = (wchar_t*)malloc(MAX_PATH);
::SendMessage(nppData._nppHandle, NPPM_GETFULLPATHFROMBUFFERID, bID, (LPARAM)fileName);
wchar_t * pos = wcsstr(fileName, L".encoded");
if (pos) {
encDecrypt(fileName);
}
}
It creates new file with decoded content, but it also still opens original “.encoded” file, that I don’t want to be opened -
Yes, as there is no way to veto on a file load notification
I would give it a try to hook WM_DOOPEN and NPPM_DOOPEN messages.
See NppBigSwitch.cppCheers
Claudia