Total Commander Plugin Support For PB

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Total Commander Plugin Support For PB

Post by gnozal »

Total Commander Plugin Support For PB

The following libraries provide an interface to TotalCMD plugins.

1. PureWLX

  Provides an interface to TotalCMD lister plugins (*.wlx).
  Available functions : http://gnozal.ucoz.com/PureWLX_.htm

2. PureWCX

  Provides an interface to TotalCMD archive plugins (*.wcx), with functions to list, compress or extract files from archives.
  Available functions : http://gnozal.ucoz.com/PureWCX_.htm

Downloads :
Only available for Purebasic Windows x86
PureWLX :
  PB 4.3x : http://gnozal.ucoz.com/PureWLX_430.zip
  PB 4.4x : http://gnozal.ucoz.com/PureWLX_440.zip
  PB 4.5x : http://gnozal.ucoz.com/PureWLX_450.zip
  PB 4.6x : http://gnozal.ucoz.com/PureWLX_460.zip
  PB 5.0x : http://gnozal.ucoz.com/PureWLX_500.zip
PureWCX :
  PB4.3x : http://gnozal.ucoz.com/PureWCX_430.zip
  PB4.4x : http://gnozal.ucoz.com/PureWCX_440.zip
  PB4.5x : http://gnozal.ucoz.com/PureWCX_450.zip
  PB4.6x : http://gnozal.ucoz.com/PureWCX_460.zip
  PB5.0x : http://gnozal.ucoz.com/PureWCX_500.zip

Code examples :

Code: Select all

Enumeration
  #WLXWindow
EndEnumeration
Enumeration
  #WLXContainer
  #LoadFile
  #PrintFile
EndEnumeration
;
; Download plugin from http://www.totalcmd.net/plugring/imagine.html
*WLX_Plugin = PureWLX_LoadPlugin("c:\WINNT\wincmd\Imagine\Imagine.wlx")
If *WLX_Plugin
  ;
  PluginSupportsUpdatePluginWindow = PureWLX_PluginSupportsUpdatePluginWindow(*WLX_Plugin)
  ;
  If OpenWindow(#WLXWindow, 400, 216, 446, 431, "WLX Test", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_SizeGadget)
    ButtonGadget(#LoadFile, 10, 399, 113, 26, "LoadFile")
    ButtonGadget(#PrintFile, 324, 399, 113, 26, "Print")
    TextGadget(#WLXContainer, 10, 10, 427, 384, "")
    PluginParent = GadgetID(#WLXContainer)
    PureRESIZE_SetGadgetResize(#WLXContainer, 1, 1, 1, 1)
    PureRESIZE_SetGadgetResize(#LoadFile, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#PrintFile, 0, 0, 1, 1)
  EndIf
  ;
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Gadget
        EventGadget = EventGadget()
        EventType = EventType()
        If EventGadget = #LoadFile
          SupportedFile$ = #PB_Compiler_Home + "Examples\Sources\Data\clouds.jpg"
          SupportedFile$ = OpenFileRequester("Select a supported file", SupportedFile$, "*.*", 0)
          If SupportedFile$
            If PluginSupportsUpdatePluginWindow And PluginWindow
              If PureWLX_UpdatePluginWindow(*WLX_Plugin, PluginParent, PluginWindow, SupportedFile$, #lcp_center) = #False
                MessageRequester("ERROR", "PureWLX_UpdatePluginWindow()" + Chr(10) + "Unsupported file ?")
              EndIf
            Else
              If PluginWindow
                PureWLX_ClosePluginWindow(*WLX_Plugin, PluginWindow)
              EndIf
              PluginWindow = PureWLX_CreatePluginWindow(*WLX_Plugin, PluginParent, SupportedFile$, #lcp_center, #True)
              If PluginWindow = #Null
                MessageRequester("ERROR", "PureWLX_CreatePluginWindow()" + Chr(10) + "Unsupported file ?")
              EndIf
            EndIf
          EndIf
        ElseIf EventGadget = #PrintFile
          If FileSize(SupportedFile$) > 0 And PluginWindow
            If PureWLX_PrintFile(*WLX_Plugin, PluginWindow, SupportedFile$, "") = #False
              MessageRequester("ERROR", "PureWLX_PrintFile()")
            EndIf
          EndIf
        EndIf
      Case #PB_Event_CloseWindow
        PureWLX_ClosePluginWindow(*WLX_Plugin, PluginWindow)
        CloseWindow(#WLXWindow)
        Break
    EndSelect
  ForEver
  ;
  PureWLX_FreePlugin(*WLX_Plugin)
Else
  MessageRequester("ERROR", "PureWLX_LoadPlugin()")
EndIf
End

Code: Select all

*SevenZIP = PureWCX_LoadPlugin("c:\WinNT\WinCmd\7-Zip\7zip.wcx")
If *SevenZIP
  hArc = PureWCX_OpenArchive(*SevenZIP, "c:\PureBasic430\Program\wcx\Test-pack.7z")
  If hArc
    While PureWCX_GetFileInfo(*SevenZIP, hArc, @HeaderData.PureWCXFileInfo)
      Debug "Archive name  : " + HeaderData\ArcName
      Debug "Archived file : " + HeaderData\Filename
      Debug "Archived file packed size   : "  + Str(HeaderData\PackSize)
      Debug "Archived file unpacked size : " + Str(HeaderData\UnpSize)
      PureWCX_NextFile(*SevenZIP, hArc)
    Wend
    PureWCX_CloseArchive(*SevenZIP, hArc)
  EndIf
  PureWCX_FreePlugin(*SevenZIP)
EndIf
End

Code: Select all

Procedure MyWCXCallback(*Filename, Size.l)
  ;
  ; *Filename : currently processed filename
  ; Size      : number of bytes processed since the previous call to the function
  ;             Some plugins send negative percent values [-1 : 1% ... -100 : 100%]
  ;
  If *Filename
    Debug "Callback -> " + PeekS(*Filename, #PB_Any, #PB_Ascii) + " -> " + Str(Size)
  EndIf
  ;
  ; IMPORTANT : return #True to continue, #False to cancel archive processing
  ;
  ProcedureReturn #True
EndProcedure
;
; Extract files in archive
;
*SevenZIP = PureWCX_LoadPlugin("c:\WinNT\WinCmd\7-Zip\7zip.wcx")
If *SevenZIP
  ; Optional callback
  PureWCX_SetCallback(*SevenZIP, @MyWCXCallback())
  ;
  hArc = PureWCX_OpenArchive(*SevenZIP, "c:\PureBasic430\Program\wcx\Test-pack.7z")
  If hArc
    While PureWCX_GetFileInfo(*SevenZIP, hArc, @HeaderData.PureWCXFileInfo)
      Debug "Archive name  : " + HeaderData\ArcName
      Debug "Archived file : " + HeaderData\Filename
      Debug "Archived file packed size   : "  + Str(HeaderData\PackSize)
      Debug "Archived file unpacked size : " + Str(HeaderData\UnpSize)
      ; Extract with archived path
      If PureWCX_ExtractFile(*SevenZIP, hArc, "c:\PureBasic430\Program\wcx\extraction\" + GetPathPart(HeaderData\Filename)) = #False
        Debug "EXTRACTION FAILED !!!"
      EndIf
      ; Extract without archived path
      ; PureWCX_ExtractFile(*SevenZIP, hArc, "c:\PureBasic430\Program\wcx\extraction\")
    Wend
    PureWCX_CloseArchive(*SevenZIP, hArc)
  EndIf
  PureWCX_FreePlugin(*SevenZIP)
EndIf
End
Last edited by gnozal on Tue Apr 15, 2008 1:48 pm, edited 13 times in total.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Total Commander Plugin Support For PB

Post by gnozal »

Update (PureWCX PB4.60 version)

Changes :
- added unicode functions to support unicode only packer plugins like the new 7zip.wcx (version >= 0.750).
  (see PureWCX-U.chm)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply