use Total Commander Plugins(PAK) in PB, scan ISO-Files

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

use Total Commander Plugins(PAK) in PB, scan ISO-Files

Post by Rings »

Hi,
another present for the weekend from your
personal forum comedian.
here is Source to load and execute a Total Commander-Plugin.
There are 3 types of total commander plugins available, this
is the implemetation for packer plugins.
Download a plugin from the totalcommandersite,
for example here is the iso one.
For testing, also check the path of the ISO-file

Code: Select all


; load and use Total Commander plugin's
; here the PACKER implementation
; Written by Siegfried Rings 4.september,2008 in 1 hour
; (C) by Siegfried Rings
; USE THE SOURCE, luke


#Lib=1
dllname.s="d:\isotest\iso.wcx" ;This is the total commanderplugin (A std DLL file)
isofile.s="d:\isotest\test.iso"


Structure tHeaderData ;=packed record
   ArcName.s{260};:array [0..259] of char;
   FileName.s{260};:array [0..259] of char;
   Flags.l
   PackSize.l
   UnpSize.l
   HostOS.l
   FileCRC.l
   FileTime.l
   UnpVer.l
   Method.l
   FileAttr.l;:longint;
   CmtBuf.l;:pchar;
   CmtBufSize.l
   CmtSize.l
   CmtState.l;:longint;
EndStructure

Structure tOpenArchiveData
    ArcName.l;char* 
    OpenMode.l;int 
    OpenResult.l;int 
    CmtBuf.l;char* 
    CmtBufSize.l;int
    CmtSize.l;int 
    CmtState.l;int 
EndStructure

  ;These are the results of a operation
  #E_NO_ERROR =        0;
  #E_END_ARCHIVE=     10;       {No more files in archive}
  #E_NO_MEMORY=       11;       {Not enough memory}
  #E_BAD_DATA=        12;       {Data is bad}
  #E_BAD_ARCHIVE=     13;       {CRC error in archive data}
  #E_UNKNOWN_FORMAT=  14;       {Archive format unknown}
  #E_EOPEN=           15;       {Cannot open existing file}
  #E_ECREATE=         16;       {Cannot create file}
  #E_ECLOSE=          17;       {Error closing file}
  #E_EREAD=           18;       {Error reading from file}
  #E_EWRITE=          19;       {Error writing to file}
  #E_SMALL_BUF=       20;       {Buffer too small}
  #E_EABORTED=        21;       {Function aborted by user}
  #E_NO_FILES=        22;       {No files found}
  #E_TOO_MANY_FILES=  23;       {Too many files to pack}
  #E_NOT_SUPPORTED=   24;       {Function not supported}

  ;{Unpacking flags}
  #PK_OM_LIST=           0;
  #PK_OM_EXTRACT=        1;

  ;{Flags For ProcessFile}
  #PK_SKIP=              0;     {Skip file (no unpacking)}
  #PK_TEST=              1;     {Test file integrity}
  #PK_EXTRACT=           2;     {Extract file to disk}

  ;{Flags passed through ChangeVolProc}
  #PK_VOL_ASK=           0;     {Ask user for location of next volume}
  #PK_VOL_NOTIFY=        1;     {Notify app that next volume will be unpacked}

  ;{Packing flags}
  ;{For PackFiles}
  #PK_PACK_MOVE_FILES=   1;    {Delete original after packing}
  #PK_PACK_SAVE_PATHS=   2;    {Save path names of files}

  ;{Returned by GetPackCaps}
  #PK_CAPS_NEW=          1;    {Can create new archives}
  #PK_CAPS_MODIFY=       2;    {Can modify exisiting archives}
  #PK_CAPS_MULTIPLE=     4;    {Archive can contain multiple files}
  #PK_CAPS_DELETE=       8;    {Can delete files}
  #PK_CAPS_OPTIONS=     16;    {Supports the options dialogbox}
  #PK_CAPS_MEMPACK=     32;    {Supports packing in memory}
  #PK_CAPS_BY_CONTENT=  64;    {Detect archive type by content}
  #PK_CAPS_SEARCHTEXT= 128;    {Allow searching for text in archives
  ;                            { created With this plugin}
  #PK_CAPS_HIDE=       256;    { Show as normal files (hide packer icon) }
  ;                            { open With Ctrl+PgDn, Not Enter }

  ;{Flags For packing in memory}
  #MEM_OPTIONS_WANTHEADERS=1;  {Return archive headers with packed data}

  ;{Errors returned by PackToMem}
  #MEMPACK_OK=           0;    {Function call finished OK, but there is more data}
  #MEMPACK_DONE=         1;    {Function call finished OK, there is no more data}




ISOLib=OpenLibrary(#Lib,dllname.s)
If IsoLib
 
 GetPackerCaps=GetFunction(#Lib, "GetPackerCaps")
 CanYouHandleThisFile=GetFunction(#Lib, "CanYouHandleThisFile")
 SetChangeVolProc=GetFunction(#Lib, "SetChangeVolProc")
 SetProcessDataProc=GetFunction(#Lib, "SetProcessDataProc")
 
 ;Prototypes are so nice :) 
 
 Prototype.l Proto_OpenArchive(OpenArchiveData.l);.tOpenArchiveData)
 OpenArchive.Proto_OpenArchive=GetFunction(#Lib, "OpenArchive")
 
 Prototype.l Proto_CloseArchive(Handle.l)
 CloseArchive.Proto_CloseArchive=GetFunction(#Lib, "CloseArchive")
 
 
 Prototype.l Proto_ReadHeader(HANDLEhArcData.l, tHeaderData.l )
 ReadHeader.Proto_ReadHeader=GetFunction(#Lib, "ReadHeader")
 
 Prototype.l Proto_ProcessFile(HANDLEhArcData.l, operation.l ,Destpath.s,Destname.s)
 ProcessFile.Proto_ProcessFile=GetFunction(#Lib, "ProcessFile")

 OpenArchiveData.tOpenArchiveData
 OpenArchiveData\ArcName=@isofile
 OpenArchiveData\OpenMode=#PK_OM_LIST	
 OpenArchiveData\OpenResult=0
 Buffer.s=Space(260)
 OpenArchiveData\CmtBuf=@buffer;
 OpenArchiveData\CmtBufSize=260
;     CmtSize,
;     CmtState:longint;


 IsoHandle.l=OpenArchive(OpenArchiveData)
 ;Debug Isohandle

 HeaderData.tHeaderData
 HeaderData\CmtBuf=@Buffer
 HeaderData\CmtBufsize=Len(Buffer)
 
 Repeat
  result=ReadHeader(IsoHandle,HeaderData)
  ;Debug PeekS(@HeaderData\ArcName,260)
  Debug PeekS(@HeaderData\FileName,260)
  
  ;Debug HeaderDataFileCRC
  
  Filetype.s=""
  ;Debug Hex(HeaderData\FileAttr)
  If  HeaderData\FileAttr & 1:Filetype +"Readonly ":EndIf
  If  HeaderData\FileAttr & 2:Filetype +"Hidden ":EndIf
  If  HeaderData\FileAttr & 4:Filetype +"System ":EndIf
  If  HeaderData\FileAttr & 8:Filetype +"Volume ID ":EndIf
  If  HeaderData\FileAttr & $10:Filetype +"Directory ":EndIf
  If  HeaderData\FileAttr & $20:Filetype +"Archive ":EndIf
  ;If  HeaderData\FileAttr & $3F:Filetype +"Any File":EndIf
  Debug Filetype

  res=ProcessFile(IsoHandle,#PK_SKIP,"","")
 Until Result<>#E_NO_ERROR
 
 
 CloseArchive(IsoHandle)
 
 CloseLibrary(#Lib)
EndIf
SPAMINATOR NR.1
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

I get angry with me, because I didn't have this idea myself. :wink:
The majority of Total Commander plugins is on this website <http://www.totalcmd.net/>.

Regards, Little John
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

Post by buzzqw »

:oops: and.. how to handle and "play" with files inside iso ? (like copy to disk..)

BHH
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

buzzqw wrote::oops: and.. how to handle and "play" with files inside iso ? (like copy to disk..)
RTFM !!!

Code: Select all

 res=ProcessFile(IsoHandle,#PK_EXTRACT,"d:\temp",Filename)
SPAMINATOR NR.1
dige
Addict
Addict
Posts: 1411
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

WOW! There are a lot of powerfull plugins.. thank you very much for that hint and the source!
User avatar
Alireza
Enthusiast
Enthusiast
Posts: 143
Joined: Sat Aug 16, 2008 2:02 pm
Location: Iran

Post by Alireza »

Hi
how can i display result of this scaning in a TreeGadget?
I try for it but my experience is low than it.
if somebody able it, please help me.
Maxter
New User
New User
Posts: 3
Joined: Thu Jan 17, 2008 3:10 pm
Location: Argentina

Post by Maxter »

Hi Rings
Very good tip.
One question. I'm trying to use #PK_EXTRACT to extract the files but i'm geting "Invalid memory access" when i call ProcessFile with #PK_EXTRACT (all the call to the function exit with error 19 (Error writing to file).
I set OpenArchiveData\OpenMode to #PK_OM_EXTRACT but it's the same.
Can you give me another tip to find the way to fix this problem? ;-)

Thanks!
Post Reply