-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathFileFunc.nsh
2008 lines (1706 loc) · 37.6 KB
/
FileFunc.nsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
_____________________________________________________________________________
File Functions Header v3.4
_____________________________________________________________________________
2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
See documentation for more information about the following functions.
Usage in script:
1. !include "FileFunc.nsh"
2. [Section|Function]
${FileFunction} "Param1" "Param2" "..." $var
[SectionEnd|FunctionEnd]
FileFunction=[Locate|GetSize|DriveSpace|GetDrives|GetTime|GetFileAttributes|
GetFileVersion|GetExeName|GetExePath|GetParameters|GetOptions|
GetOptionsS|GetRoot|GetParent|GetFileName|GetBaseName|GetFileExt|
BannerTrimPath|DirState|RefreshShellIcons]
_____________________________________________________________________________
Thanks to:
_____________________________________________________________________________
GetSize
KiCHiK (Function "FindFiles")
DriveSpace
sunjammer (Function "CheckSpaceFree")
GetDrives
deguix (Based on his idea of Function "DetectDrives")
GetTime
Takhir (Script "StatTest") and deguix (Function "FileModifiedDate")
GetFileVersion
KiCHiK (Based on his example for command "GetDLLVersion")
GetParameters
sunjammer (Based on his Function "GetParameters")
GetRoot
KiCHiK (Based on his Function "GetRoot")
GetParent
sunjammer (Based on his Function "GetParent")
GetFileName
KiCHiK (Based on his Function "GetFileName")
GetBaseName
comperio (Based on his idea of Function "GetBaseName")
GetFileExt
opher (author)
RefreshShellIcons
jerome tremblay (author)
*/
;_____________________________________________________________________________
;
; Macros
;_____________________________________________________________________________
;
; Change log window verbosity (default: 3=no script)
;
; Example:
; !include "FileFunc.nsh"
; !insertmacro Locate
; ${FILEFUNC_VERBOSE} 4 # all verbosity
; !insertmacro VersionCompare
; ${FILEFUNC_VERBOSE} 3 # no script
!ifndef FILEFUNC_INCLUDED
!define FILEFUNC_INCLUDED
!include Util.nsh
!verbose push
!verbose 3
!ifndef _FILEFUNC_VERBOSE
!define _FILEFUNC_VERBOSE 3
!endif
!verbose ${_FILEFUNC_VERBOSE}
!define FILEFUNC_VERBOSE `!insertmacro FILEFUNC_VERBOSE`
!verbose pop
!macro FILEFUNC_VERBOSE _VERBOSE
!verbose push
!verbose 3
!undef _FILEFUNC_VERBOSE
!define _FILEFUNC_VERBOSE ${_VERBOSE}
!verbose pop
!macroend
!macro LocateCall _PATH _OPTIONS _FUNC
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push $0
Push `${_PATH}`
Push `${_OPTIONS}`
GetFunctionAddress $0 `${_FUNC}`
Push `$0`
${CallArtificialFunction} Locate_
Pop $0
!verbose pop
!macroend
!macro GetSizeCall _PATH _OPTIONS _RESULT1 _RESULT2 _RESULT3
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PATH}`
Push `${_OPTIONS}`
${CallArtificialFunction} GetSize_
Pop ${_RESULT1}
Pop ${_RESULT2}
Pop ${_RESULT3}
!verbose pop
!macroend
!macro DriveSpaceCall _DRIVE _OPTIONS _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_DRIVE}`
Push `${_OPTIONS}`
${CallArtificialFunction} DriveSpace_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetDrivesCall _DRV _FUNC
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push $0
Push `${_DRV}`
GetFunctionAddress $0 `${_FUNC}`
Push `$0`
${CallArtificialFunction} GetDrives_
Pop $0
!verbose pop
!macroend
!macro GetTimeCall _FILE _OPTION _RESULT1 _RESULT2 _RESULT3 _RESULT4 _RESULT5 _RESULT6 _RESULT7
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_FILE}`
Push `${_OPTION}`
${CallArtificialFunction} GetTime_
Pop ${_RESULT1}
Pop ${_RESULT2}
Pop ${_RESULT3}
Pop ${_RESULT4}
Pop ${_RESULT5}
Pop ${_RESULT6}
Pop ${_RESULT7}
!verbose pop
!macroend
!macro GetFileAttributesCall _PATH _ATTR _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PATH}`
Push `${_ATTR}`
${CallArtificialFunction} GetFileAttributes_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetFileVersionCall _FILE _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_FILE}`
${CallArtificialFunction} GetFileVersion_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetExeNameCall _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
${CallArtificialFunction} GetExeName_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetExePathCall _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
${CallArtificialFunction} GetExePath_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetParametersCall _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
${CallArtificialFunction} GetParameters_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetOptionsCall _PARAMETERS _OPTION _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PARAMETERS}`
Push `${_OPTION}`
${CallArtificialFunction} GetOptions_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetOptionsSCall _PARAMETERS _OPTION _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PARAMETERS}`
Push `${_OPTION}`
${CallArtificialFunction} GetOptionsS_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetRootCall _FULLPATH _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_FULLPATH}`
${CallArtificialFunction} GetRoot_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetParentCall _PATHSTRING _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PATHSTRING}`
${CallArtificialFunction} GetParent_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetFileNameCall _PATHSTRING _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PATHSTRING}`
${CallArtificialFunction} GetFileName_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetBaseNameCall _FILESTRING _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_FILESTRING}`
${CallArtificialFunction} GetBaseName_
Pop ${_RESULT}
!verbose pop
!macroend
!macro GetFileExtCall _FILESTRING _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_FILESTRING}`
${CallArtificialFunction} GetFileExt_
Pop ${_RESULT}
!verbose pop
!macroend
!macro BannerTrimPathCall _PATH _LENGHT _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PATH}`
Push `${_LENGHT}`
${CallArtificialFunction} BannerTrimPath_
Pop ${_RESULT}
!verbose pop
!macroend
!macro DirStateCall _PATH _RESULT
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Push `${_PATH}`
${CallArtificialFunction} DirState_
Pop ${_RESULT}
!verbose pop
!macroend
!macro RefreshShellIconsCall
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
${CallArtificialFunction} RefreshShellIcons_
!verbose pop
!macroend
!define Locate `!insertmacro LocateCall`
!define un.Locate `!insertmacro LocateCall`
!macro Locate
!macroend
!macro un.Locate
!macroend
!macro Locate_
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Exch $2
Exch
Exch $1
Exch
Exch 2
Exch $0
Exch 2
Push $3
Push $4
Push $5
Push $6
Push $7
Push $8
Push $9
Push $R6
Push $R7
Push $R8
Push $R9
ClearErrors
StrCpy $3 ''
StrCpy $4 ''
StrCpy $5 ''
StrCpy $6 ''
StrCpy $7 ''
StrCpy $8 0
StrCpy $R7 ''
StrCpy $R9 $0 1 -1
StrCmp $R9 '\' 0 +3
StrCpy $0 $0 -1
goto -3
IfFileExists '$0\*.*' 0 FileFunc_Locate_error
FileFunc_Locate_option:
StrCpy $R9 $1 1
StrCpy $1 $1 '' 1
StrCmp $R9 ' ' -2
StrCmp $R9 '' FileFunc_Locate_sizeset
StrCmp $R9 '/' 0 -4
StrCpy $9 -1
IntOp $9 $9 + 1
StrCpy $R9 $1 1 $9
StrCmp $R9 '' +2
StrCmp $R9 '/' 0 -3
StrCpy $R8 $1 $9
StrCpy $R8 $R8 '' 2
StrCpy $R9 $R8 '' -1
StrCmp $R9 ' ' 0 +3
StrCpy $R8 $R8 -1
goto -3
StrCpy $R9 $1 2
StrCpy $1 $1 '' $9
StrCmp $R9 'L=' 0 FileFunc_Locate_mask
StrCpy $3 $R8
StrCmp $3 '' +6
StrCmp $3 'FD' +5
StrCmp $3 'F' +4
StrCmp $3 'D' +3
StrCmp $3 'DE' +2
StrCmp $3 'FDE' 0 FileFunc_Locate_error
goto FileFunc_Locate_option
FileFunc_Locate_mask:
StrCmp $R9 'M=' 0 FileFunc_Locate_size
StrCpy $4 $R8
goto FileFunc_Locate_option
FileFunc_Locate_size:
StrCmp $R9 'S=' 0 FileFunc_Locate_gotosubdir
StrCpy $6 $R8
goto FileFunc_Locate_option
FileFunc_Locate_gotosubdir:
StrCmp $R9 'G=' 0 FileFunc_Locate_banner
StrCpy $7 $R8
StrCmp $7 '' +3
StrCmp $7 '1' +2
StrCmp $7 '0' 0 FileFunc_Locate_error
goto FileFunc_Locate_option
FileFunc_Locate_banner:
StrCmp $R9 'B=' 0 FileFunc_Locate_error
StrCpy $R7 $R8
StrCmp $R7 '' +3
StrCmp $R7 '1' +2
StrCmp $R7 '0' 0 FileFunc_Locate_error
goto FileFunc_Locate_option
FileFunc_Locate_sizeset:
StrCmp $6 '' FileFunc_Locate_default
StrCpy $9 0
StrCpy $R9 $6 1 $9
StrCmp $R9 '' +4
StrCmp $R9 ':' +3
IntOp $9 $9 + 1
goto -4
StrCpy $5 $6 $9
IntOp $9 $9 + 1
StrCpy $1 $6 1 -1
StrCpy $6 $6 -1 $9
StrCmp $5 '' +2
IntOp $5 $5 + 0
StrCmp $6 '' +2
IntOp $6 $6 + 0
StrCmp $1 'B' 0 +3
StrCpy $1 1
goto FileFunc_Locate_default
StrCmp $1 'K' 0 +3
StrCpy $1 1024
goto FileFunc_Locate_default
StrCmp $1 'M' 0 +3
StrCpy $1 1048576
goto FileFunc_Locate_default
StrCmp $1 'G' 0 FileFunc_Locate_error
StrCpy $1 1073741824
FileFunc_Locate_default:
StrCmp $3 '' 0 +2
StrCpy $3 'FD'
StrCmp $4 '' 0 +2
StrCpy $4 '*.*'
StrCmp $7 '' 0 +2
StrCpy $7 '1'
StrCmp $R7 '' 0 +2
StrCpy $R7 '0'
StrCpy $7 'G$7B$R7'
StrCpy $8 1
Push $0
SetDetailsPrint textonly
FileFunc_Locate_nextdir:
IntOp $8 $8 - 1
Pop $R8
StrCpy $9 $7 2 2
StrCmp $9 'B0' +3
GetLabelAddress $9 FileFunc_Locate_findfirst
goto call
DetailPrint 'Search in: $R8'
FileFunc_Locate_findfirst:
FindFirst $0 $R7 '$R8\$4'
IfErrors FileFunc_Locate_subdir
StrCmp $R7 '.' 0 FileFunc_Locate_dir
FindNext $0 $R7
StrCmp $R7 '..' 0 FileFunc_Locate_dir
FindNext $0 $R7
IfErrors 0 FileFunc_Locate_dir
FindClose $0
goto FileFunc_Locate_subdir
FileFunc_Locate_dir:
IfFileExists '$R8\$R7\*.*' 0 FileFunc_Locate_file
StrCpy $R6 ''
StrCmp $3 'DE' +4
StrCmp $3 'FDE' +3
StrCmp $3 'FD' FileFunc_Locate_precall
StrCmp $3 'F' FileFunc_Locate_findnext FileFunc_Locate_precall
FindFirst $9 $R9 '$R8\$R7\*.*'
StrCmp $R9 '.' 0 +4
FindNext $9 $R9
StrCmp $R9 '..' 0 +2
FindNext $9 $R9
FindClose $9
IfErrors FileFunc_Locate_precall FileFunc_Locate_findnext
FileFunc_Locate_file:
StrCmp $3 'FDE' +3
StrCmp $3 'FD' +2
StrCmp $3 'F' 0 FileFunc_Locate_findnext
StrCpy $R6 0
StrCmp $5$6 '' FileFunc_Locate_precall
FileOpen $9 '$R8\$R7' r
IfErrors +3
FileSeek $9 0 END $R6
FileClose $9
System::Int64Op $R6 / $1
Pop $R6
StrCmp $5 '' +2
IntCmp $R6 $5 0 FileFunc_Locate_findnext
StrCmp $6 '' +2
IntCmp $R6 $6 0 0 FileFunc_Locate_findnext
FileFunc_Locate_precall:
StrCpy $9 0
StrCpy $R9 '$R8\$R7'
call:
Push $0
Push $1
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7
Push $8
Push $9
Push $R7
Push $R8
StrCmp $9 0 +4
StrCpy $R6 ''
StrCpy $R7 ''
StrCpy $R9 ''
Call $2
Pop $R9
Pop $R8
Pop $R7
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
IfErrors 0 +3
FindClose $0
goto FileFunc_Locate_error
StrCmp $R9 'StopLocate' 0 +3
FindClose $0
goto FileFunc_Locate_clearstack
goto $9
FileFunc_Locate_findnext:
FindNext $0 $R7
IfErrors 0 FileFunc_Locate_dir
FindClose $0
FileFunc_Locate_subdir:
StrCpy $9 $7 2
StrCmp $9 'G0' FileFunc_Locate_end
FindFirst $0 $R7 '$R8\*.*'
StrCmp $R7 '.' 0 FileFunc_Locate_pushdir
FindNext $0 $R7
StrCmp $R7 '..' 0 FileFunc_Locate_pushdir
FindNext $0 $R7
IfErrors 0 FileFunc_Locate_pushdir
FindClose $0
StrCmp $8 0 FileFunc_Locate_end FileFunc_Locate_nextdir
FileFunc_Locate_pushdir:
IfFileExists '$R8\$R7\*.*' 0 +3
Push '$R8\$R7'
IntOp $8 $8 + 1
FindNext $0 $R7
IfErrors 0 FileFunc_Locate_pushdir
FindClose $0
StrCmp $8 0 FileFunc_Locate_end FileFunc_Locate_nextdir
FileFunc_Locate_error:
SetErrors
FileFunc_Locate_clearstack:
StrCmp $8 0 FileFunc_Locate_end
IntOp $8 $8 - 1
Pop $R8
goto FileFunc_Locate_clearstack
FileFunc_Locate_end:
SetDetailsPrint both
Pop $R9
Pop $R8
Pop $R7
Pop $R6
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
!verbose pop
!macroend
!define GetSize `!insertmacro GetSizeCall`
!define un.GetSize `!insertmacro GetSizeCall`
!macro GetSize
!macroend
!macro un.GetSize
!macroend
!macro GetSize_
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7
Push $8
Push $9
Push $R3
Push $R4
Push $R5
Push $R6
Push $R7
Push $R8
Push $R9
ClearErrors
StrCpy $R9 $0 1 -1
StrCmp $R9 '\' 0 +3
StrCpy $0 $0 -1
goto -3
IfFileExists '$0\*.*' 0 FileFunc_GetSize_error
StrCpy $3 ''
StrCpy $4 ''
StrCpy $5 ''
StrCpy $6 ''
StrCpy $8 0
StrCpy $R3 ''
StrCpy $R4 ''
StrCpy $R5 ''
FileFunc_GetSize_option:
StrCpy $R9 $1 1
StrCpy $1 $1 '' 1
StrCmp $R9 ' ' -2
StrCmp $R9 '' FileFunc_GetSize_sizeset
StrCmp $R9 '/' 0 -4
StrCpy $9 -1
IntOp $9 $9 + 1
StrCpy $R9 $1 1 $9
StrCmp $R9 '' +2
StrCmp $R9 '/' 0 -3
StrCpy $8 $1 $9
StrCpy $8 $8 '' 2
StrCpy $R9 $8 '' -1
StrCmp $R9 ' ' 0 +3
StrCpy $8 $8 -1
goto -3
StrCpy $R9 $1 2
StrCpy $1 $1 '' $9
StrCmp $R9 'M=' 0 FileFunc_GetSize_size
StrCpy $4 $8
goto FileFunc_GetSize_option
FileFunc_GetSize_size:
StrCmp $R9 'S=' 0 FileFunc_GetSize_gotosubdir
StrCpy $6 $8
goto FileFunc_GetSize_option
FileFunc_GetSize_gotosubdir:
StrCmp $R9 'G=' 0 FileFunc_GetSize_error
StrCpy $7 $8
StrCmp $7 '' +3
StrCmp $7 '1' +2
StrCmp $7 '0' 0 FileFunc_GetSize_error
goto FileFunc_GetSize_option
FileFunc_GetSize_sizeset:
StrCmp $6 '' FileFunc_GetSize_default
StrCpy $9 0
StrCpy $R9 $6 1 $9
StrCmp $R9 '' +4
StrCmp $R9 ':' +3
IntOp $9 $9 + 1
goto -4
StrCpy $5 $6 $9
IntOp $9 $9 + 1
StrCpy $1 $6 1 -1
StrCpy $6 $6 -1 $9
StrCmp $5 '' +2
IntOp $5 $5 + 0
StrCmp $6 '' +2
IntOp $6 $6 + 0
StrCmp $1 'B' 0 +4
StrCpy $1 1
StrCpy $2 bytes
goto FileFunc_GetSize_default
StrCmp $1 'K' 0 +4
StrCpy $1 1024
StrCpy $2 Kb
goto FileFunc_GetSize_default
StrCmp $1 'M' 0 +4
StrCpy $1 1048576
StrCpy $2 Mb
goto FileFunc_GetSize_default
StrCmp $1 'G' 0 FileFunc_GetSize_error
StrCpy $1 1073741824
StrCpy $2 Gb
FileFunc_GetSize_default:
StrCmp $4 '' 0 +2
StrCpy $4 '*.*'
StrCmp $7 '' 0 +2
StrCpy $7 '1'
StrCpy $8 1
Push $0
SetDetailsPrint textonly
FileFunc_GetSize_nextdir:
IntOp $8 $8 - 1
Pop $R8
FindFirst $0 $R7 '$R8\$4'
IfErrors FileFunc_GetSize_show
StrCmp $R7 '.' 0 FileFunc_GetSize_dir
FindNext $0 $R7
StrCmp $R7 '..' 0 FileFunc_GetSize_dir
FindNext $0 $R7
IfErrors 0 FileFunc_GetSize_dir
FindClose $0
goto FileFunc_GetSize_show
FileFunc_GetSize_dir:
IfFileExists '$R8\$R7\*.*' 0 FileFunc_GetSize_file
IntOp $R5 $R5 + 1
goto FileFunc_GetSize_findnext
FileFunc_GetSize_file:
StrCpy $R6 0
StrCmp $5$6 '' 0 +3
IntOp $R4 $R4 + 1
goto FileFunc_GetSize_findnext
FileOpen $9 '$R8\$R7' r
IfErrors +3
FileSeek $9 0 END $R6
FileClose $9
StrCmp $5 '' +2
IntCmp $R6 $5 0 FileFunc_GetSize_findnext
StrCmp $6 '' +2
IntCmp $R6 $6 0 0 FileFunc_GetSize_findnext
IntOp $R4 $R4 + 1
System::Int64Op $R3 + $R6
Pop $R3
FileFunc_GetSize_findnext:
FindNext $0 $R7
IfErrors 0 FileFunc_GetSize_dir
FindClose $0
FileFunc_GetSize_show:
StrCmp $5$6 '' FileFunc_GetSize_nosize
System::Int64Op $R3 / $1
Pop $9
DetailPrint 'Size:$9 $2 Files:$R4 Folders:$R5'
goto FileFunc_GetSize_subdir
FileFunc_GetSize_nosize:
DetailPrint 'Files:$R4 Folders:$R5'
FileFunc_GetSize_subdir:
StrCmp $7 0 FileFunc_GetSize_preend
FindFirst $0 $R7 '$R8\*.*'
StrCmp $R7 '.' 0 FileFunc_GetSize_pushdir
FindNext $0 $R7
StrCmp $R7 '..' 0 FileFunc_GetSize_pushdir
FindNext $0 $R7
IfErrors 0 FileFunc_GetSize_pushdir
FindClose $0
StrCmp $8 0 FileFunc_GetSize_preend FileFunc_GetSize_nextdir
FileFunc_GetSize_pushdir:
IfFileExists '$R8\$R7\*.*' 0 +3
Push '$R8\$R7'
IntOp $8 $8 + 1
FindNext $0 $R7
IfErrors 0 FileFunc_GetSize_pushdir
FindClose $0
StrCmp $8 0 FileFunc_GetSize_preend FileFunc_GetSize_nextdir
FileFunc_GetSize_preend:
StrCmp $R3 '' FileFunc_GetSize_nosizeend
System::Int64Op $R3 / $1
Pop $R3
FileFunc_GetSize_nosizeend:
StrCpy $2 $R4
StrCpy $1 $R5
StrCpy $0 $R3
goto FileFunc_GetSize_end
FileFunc_GetSize_error:
SetErrors
StrCpy $0 ''
StrCpy $1 ''
StrCpy $2 ''
FileFunc_GetSize_end:
SetDetailsPrint both
Pop $R9
Pop $R8
Pop $R7
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Exch $2
Exch
Exch $1
Exch 2
Exch $0
!verbose pop
!macroend
!define DriveSpace `!insertmacro DriveSpaceCall`
!define un.DriveSpace `!insertmacro DriveSpaceCall`
!macro DriveSpace
!macroend
!macro un.DriveSpace
!macroend
!macro DriveSpace_
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
ClearErrors
StrCpy $2 $0 1 -1
StrCmp $2 '\' 0 +3
StrCpy $0 $0 -1
goto -3
IfFileExists '$0\NUL' 0 FileFunc_DriveSpace_error
StrCpy $5 ''
StrCpy $6 ''
FileFunc_DriveSpace_option:
StrCpy $2 $1 1
StrCpy $1 $1 '' 1
StrCmp $2 ' ' -2
StrCmp $2 '' FileFunc_DriveSpace_default
StrCmp $2 '/' 0 -4
StrCpy $3 -1
IntOp $3 $3 + 1
StrCpy $2 $1 1 $3
StrCmp $2 '' +2
StrCmp $2 '/' 0 -3
StrCpy $4 $1 $3
StrCpy $4 $4 '' 2
StrCpy $2 $4 1 -1
StrCmp $2 ' ' 0 +3
StrCpy $4 $4 -1
goto -3
StrCpy $2 $1 2
StrCpy $1 $1 '' $3
StrCmp $2 'D=' 0 FileFunc_DriveSpace_unit
StrCpy $5 $4
StrCmp $5 '' +4
StrCmp $5 'T' +3
StrCmp $5 'O' +2
StrCmp $5 'F' 0 FileFunc_DriveSpace_error
goto FileFunc_DriveSpace_option
FileFunc_DriveSpace_unit:
StrCmp $2 'S=' 0 FileFunc_DriveSpace_error
StrCpy $6 $4
goto FileFunc_DriveSpace_option
FileFunc_DriveSpace_default:
StrCmp $5 '' 0 +2
StrCpy $5 'T'
StrCmp $6 '' 0 +3
StrCpy $6 '1'
goto FileFunc_DriveSpace_getspace
StrCmp $6 'B' 0 +3
StrCpy $6 1
goto FileFunc_DriveSpace_getspace
StrCmp $6 'K' 0 +3
StrCpy $6 1024
goto FileFunc_DriveSpace_getspace
StrCmp $6 'M' 0 +3
StrCpy $6 1048576
goto FileFunc_DriveSpace_getspace
StrCmp $6 'G' 0 FileFunc_DriveSpace_error
StrCpy $6 1073741824
FileFunc_DriveSpace_getspace:
System::Call 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l)i(r0,.r2,.r3,.)'
StrCmp $5 T 0 +3
StrCpy $0 $3
goto FileFunc_DriveSpace_getsize
StrCmp $5 O 0 +4
System::Int64Op $3 - $2
Pop $0
goto FileFunc_DriveSpace_getsize
StrCmp $5 F 0 +2
StrCpy $0 $2
FileFunc_DriveSpace_getsize:
System::Int64Op $0 / $6
Pop $0
goto FileFunc_DriveSpace_end
FileFunc_DriveSpace_error:
SetErrors
StrCpy $0 ''
FileFunc_DriveSpace_end:
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
!verbose pop
!macroend
!define GetDrives `!insertmacro GetDrivesCall`
!define un.GetDrives `!insertmacro GetDrivesCall`
!macro GetDrives
!macroend
!macro un.GetDrives
!macroend
!macro GetDrives_
!verbose push
!verbose ${_FILEFUNC_VERBOSE}
Exch $1
Exch
Exch $0
Exch
Push $2
Push $3
Push $4
Push $5
Push $6
Push $8
Push $9
System::Alloc 1024
Pop $2
System::Call 'kernel32::GetLogicalDriveStringsA(i,i) i(1024, r2)'
StrCmp $0 ALL FileFunc_GetDrives_drivestring
StrCmp $0 '' 0 FileFunc_GetDrives_typeset
StrCpy $0 ALL
goto FileFunc_GetDrives_drivestring
FileFunc_GetDrives_typeset:
StrCpy $6 -1
IntOp $6 $6 + 1
StrCpy $8 $0 1 $6
StrCmp $8$0 '' FileFunc_GetDrives_enumex
StrCmp $8 '' +2
StrCmp $8 '+' 0 -4
StrCpy $8 $0 $6
IntOp $6 $6 + 1
StrCpy $0 $0 '' $6
StrCmp $8 'FDD' 0 +3
StrCpy $6 2
goto FileFunc_GetDrives_drivestring
StrCmp $8 'HDD' 0 +3
StrCpy $6 3
goto FileFunc_GetDrives_drivestring
StrCmp $8 'NET' 0 +3
StrCpy $6 4
goto FileFunc_GetDrives_drivestring
StrCmp $8 'CDROM' 0 +3
StrCpy $6 5
goto FileFunc_GetDrives_drivestring
StrCmp $8 'RAM' 0 FileFunc_GetDrives_typeset
StrCpy $6 6
FileFunc_GetDrives_drivestring:
StrCpy $3 $2
FileFunc_GetDrives_enumok: