Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Prevent file loading

    Plugin Development
    3
    4
    1773
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ian Darken
      Ian Darken last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • Meta Chuh
        Meta Chuh last edited by

        @Ian-Darken

        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

        1 Reply Last reply Reply Quote 0
        • Ian Darken
          Ian Darken last edited by

          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

          Claudia Frank 1 Reply Last reply Reply Quote 0
          • Claudia Frank
            Claudia Frank @Ian Darken last edited by

            @Ian-Darken

            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.cpp

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors