2
0
Эх сурвалжийг харах

* unblock folded into chmls and deleted.

git-svn-id: trunk@15593 -
marco 15 жил өмнө
parent
commit
eead32ac62

+ 0 - 1
.gitattributes

@@ -1005,7 +1005,6 @@ packages/chm/src/lzxcompressthread.pas svneol=native#text/plain
 packages/chm/src/paslznonslide.pas svneol=native#text/plain
 packages/chm/src/paslzx.pas svneol=native#text/plain
 packages/chm/src/paslzxcomp.pas svneol=native#text/plain
-packages/chm/src/unblockchm.pp -text svneol=native#test/plain
 packages/cocoaint/Makefile svneol=native#text/plain
 packages/cocoaint/Makefile.fpc svneol=native#text/plain
 packages/cocoaint/src/CocoaAll.pas svneol=native#text/plain

+ 3 - 4
packages/chm/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/07/11]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/07/17]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -273,7 +273,7 @@ ifeq ($(FULL_TARGET),i386-go32v2)
 override TARGET_PROGRAMS+=chmcmd chmls
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_PROGRAMS+=chmcmd chmls  unblockchm
+override TARGET_PROGRAMS+=chmcmd chmls
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 override TARGET_PROGRAMS+=chmcmd chmls
@@ -399,7 +399,7 @@ ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_PROGRAMS+=chmcmd chmls
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_PROGRAMS+=chmcmd chmls  unblockchm
+override TARGET_PROGRAMS+=chmcmd chmls
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 override TARGET_PROGRAMS+=chmcmd chmls
@@ -2885,4 +2885,3 @@ endif
 .NOTPARALLEL:
 cdmcmd$(EXEEXT): chmcmd.lpr
 chmls$(EXEEXT): chmls.lpr
-unblockchm$(EXEEXT): unblockchm.pp

+ 1 - 3
packages/chm/Makefile.fpc

@@ -11,8 +11,6 @@ units=fasthtmlparser htmlutil paslzx paslzxcomp paslznonslide chmbase chmtypes \
       chmspecialfiles chmsitemap chmwriter chmfilewriter chmreader htmlindexer \
       chmfiftimain lzxcompressthread itolitlstypes itsftransform itolitlsreader
 programs=chmcmd chmls
-programs_win32=unblockchm
-programs_win64=unblockchm
 examples=
 
 [require]
@@ -35,4 +33,4 @@ cdmcmd$(EXEEXT): chmcmd.lpr
 
 chmls$(EXEEXT): chmls.lpr
 
-unblockchm$(EXEEXT): unblockchm.pp
+

+ 59 - 8
packages/chm/src/chmls.lpr

@@ -49,10 +49,10 @@ type
   end;
 
 
-  TCmdEnum = (cmdList,cmdExtract,cmdExtractall,cmdNone);        // One dummy element at the end avoids rangecheck errors.
+  TCmdEnum = (cmdList,cmdExtract,cmdExtractall,cmdUnblock,cmdNone);        // One dummy element at the end avoids rangecheck errors.
 
 Const
-  CmdNames : array [TCmdEnum] of String = ('LIST','EXTRACT','EXTRACTALL','');
+  CmdNames : array [TCmdEnum] of String = ('LIST','EXTRACT','EXTRACTALL','UNBLOCK','');
 
 var
   theopts : array[1..2] of TOption;
@@ -68,15 +68,17 @@ begin
   writeln(stderr,' -n          : do not page list output');
   writeln(stderr);
   writeln(stderr,'Where command is one of the following or if omitted, equal to LIST.');
-  writeln(stderr,' list     <filename> [section number] ');
+  writeln(stderr,' list       <filename> [section number] ');
   writeln(stderr,'            Shows contents of the archive''s directory');
-  writeln(stderr,' extract  <chm filename> <filename to extract> [saveasname]');
+  writeln(stderr,' extract    <chm filename> <filename to extract> [saveasname]');
   writeln(stderr,'            Extracts file "filename to get" from archive "filename",');
   writeln(stderr,'            and, if specified, saves it to [saveasname]');
   writeln(stderr,' extractall <chm filename> [directory]');
   writeln(stderr,'            Extracts all files from archive "filename" to directory ');
   writeln(stderr,'            "directory"');
-
+  writeln(stderr,' unblockchm <filespec1> [filespec2] ..' );
+  writeln(stderr,'            Mass unblocks (XPsp2+) the relevant CHMs. Multiple files');
+  writeln(stderr,'            and wildcards allowed');
   Halt(1);
 end;
 
@@ -118,9 +120,6 @@ procedure WriteStrAdj(Str: String; CharWidth: Integer);
     Write(OutString + Str); // to stdout
   end;
 
-{ TListObject }
-
-
 function craftpath(pth:string;filename:String):string;
 
 var lenpth,lenfn:integer;
@@ -323,6 +322,50 @@ begin
   r.free;
 end;
 
+procedure unblockchm(s:string);
+var f : file;
+begin
+ writeln('unblocking ',s);
+ assignfile(f,s+':Zone.Identifier');
+ rewrite(f,1);
+ truncate(f);
+ closefile(f);
+end;
+
+procedure populatefiles(files:TStringlist;filespec:string);
+var
+  searchResult : TSearchRec;
+begin
+ if FindFirst(filespec, faAnyFile, searchResult) = 0 then
+  begin
+    repeat
+      files.add(searchresult.name);
+    until FindNext(searchResult) <> 0;
+    // Must free up resources used by these successful finds
+    FindClose(searchResult);
+  end;
+end;
+
+procedure unblockchms(filespec:TStringDynArray);
+
+var files : TStringList;
+    i : Integer;
+
+begin
+ files :=TStringList.create;
+ try
+   for i:=0 to length(filespec)-1 do
+    populatefiles(files,filespec[i]);
+ except
+   writeln(stderr,'Error while scanning directory ',filespec[i]);
+   writeln(stderr,'Exiting....');
+   halt(1);
+  end;
+ if files.count>0 then
+   for i:=0 to files.count-1 do
+     unblockchm(files[i]);
+ Files.Free;
+end;
 
 procedure buildarglist(var params: TStringDynArray;var cmd :TCmdEnum);
 
@@ -421,6 +464,14 @@ begin
                       else
                         WrongNrParam(cmdnames[cmd],length(localparams));
                      end;
+
+      cmdunblock   : begin
+                      if length(localparams)>0 then
+                        Unblockchms(localparams)
+                      else
+                        WrongNrParam(cmdnames[cmd],length(localparams));
+                     end;
+
       end; {case cmd of}
   end
  else

+ 0 - 65
packages/chm/src/unblockchm.pp

@@ -1,65 +0,0 @@
-program unblockchm;
-
-// Marco van de Voort
-// BSD license 
-// Quick and dirty scritp to unblocks CHMs on xpsp2/vista/w7
-//
-// todo : populatefiles needs fix for when filespec contains a directory.
-//
-// based on http://stackoverflow.com/questions/1617509/unblock-a-file-with-powershell
-
-{$mode delphi}
-uses sysutils,classes;
-
-procedure usage;
-
-begin
-  writeln('unblockchm. Unblocks chms in XPsp2,vista,w7  (C) 2010 Marco van de Voort');
-  writeln;
-  Writeln('usage: unblockchm <filespec> <filespec2> ..');
-  writeln;
-  writeln('<filespec> may contain basic wildcards.');
-  writeln;
-end;
-
-procedure unblockchm(s:string);
-var f : file;
-begin
- writeln('unblocking ',s);
- assignfile(f,s+':Zone.Identifier');
- rewrite(f,1);
- truncate(f);
- closefile(f);
-end;
-
-procedure populatefiles(files:TStringlist;filespec:string);
-var
-  searchResult : TSearchRec;
-begin
- if FindFirst(filespec, faAnyFile, searchResult) = 0 then
-  begin
-    repeat
-      files.add(searchresult.name);
-    until FindNext(searchResult) <> 0;
-    // Must free up resources used by these successful finds
-    FindClose(searchResult);
-  end;
-end;
-
-var files : TStringList;
-    i : Integer;
-
-begin
- if paramcount=0 then
-   begin
-     Usage;
-     halt;
-   end;
- files :=TStringList.create;
- for i:=1 to paramcount do
-  populatefiles(files,paramstr(i));
- if files.count>0 then
-   for i:=0 to files.count-1 do
-     unblockchm(files[i]);
-end.
-