@@ -14,5 +14,101 @@ This project was initially created by [**preseverence**](https://github.com/pres
14
14
### Limitations
15
15
* Compiled code sections will be skipped
16
16
17
+ ### Basic Usage Examples
18
+ #### Printing Uninstall Paths
19
+ ``` C#
20
+ using Hi3Helper .EncTool .Parser .InnoUninstallerLog ;
21
+ using LibISULR ;
22
+ using LibISULR .Records ;
23
+ using System ;
24
+
25
+ string innoFile = " path_to_unins000.dat" ;
26
+
27
+ // The CRC check can be skipped by setting the skipCrcCheck argument to true
28
+ using (InnoUninstLog innoLog = InnoUninstLog .Load (innoFile , skipCrcCheck : false ))
29
+ {
30
+ foreach (BaseRecord baseRecord in innoLog .Records )
31
+ {
32
+ switch (baseRecord .Type )
33
+ {
34
+ case RecordType .DeleteDirOrFiles :
35
+ DeleteDirOrFilesRecord deleteDirOrFilesRecord = (DeleteDirOrFilesRecord )baseRecord ;
36
+ Console .WriteLine (deleteDirOrFilesRecord .Paths [0 ]);
37
+ break ;
38
+ case RecordType .DeleteFile :
39
+ DeleteFileRecord deleteFileRecord = (DeleteFileRecord )baseRecord ;
40
+ Console .WriteLine (deleteFileRecord .Paths [0 ]);
41
+ break ;
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ #### Modify the base paths in `` DeleteDirOrFiles `` and `` DeleteFile `` records
48
+ ``` C#
49
+ using Hi3Helper .EncTool .Parser .InnoUninstallerLog ;
50
+ using LibISULR ;
51
+ using LibISULR .Flags ;
52
+ using LibISULR .Records ;
53
+ using System ;
54
+ using System .IO ;
55
+
56
+ namespace Test
57
+ {
58
+ internal class Program
59
+ {
60
+ private static void ChangeBasePath <TFlags >(BaseRecord record , string from , string to )
61
+ where TFlags : Enum
62
+ {
63
+ // Cast the base record to BasePathListRecord<TFlags>
64
+ BasePathListRecord < TFlags > listPathRecord = (BasePathListRecord <TFlags >)record ;
65
+
66
+ // Find the start index of the searched path from "from" argument
67
+ int indexOf = listPathRecord .Paths [0 ].IndexOf (from , StringComparison .InvariantCultureIgnoreCase );
68
+
69
+ // If the indexOf is > -1 (found), then try slicing the start of the path based on "from" argument
70
+ if (indexOf > - 1 )
71
+ {
72
+ // Slice the string to get the relative path (and trim \\ if necessary)
73
+ string sliced = listPathRecord .Paths [0 ].Substring (indexOf + from .Length ).TrimStart ('\\ ' );
74
+
75
+ // Combine the sliced relative path with base path from "to" argument
76
+ listPathRecord .Paths [0 ] = Path .Combine (to , sliced );
77
+ }
78
+ }
79
+
80
+ static void Main (string [] args )
81
+ {
82
+ string innoFile = @" C:\Program Files\Collapse Launcher\unins000.dat" ;
83
+
84
+ // The CRC check can be skipped by setting the skipCrcCheck argument to true
85
+ using (InnoUninstLog innoLog = InnoUninstLog .Load (innoFile ))
86
+ {
87
+ // Enumerate the record as BaseRecord
88
+ foreach (BaseRecord baseRecord in innoLog .Records )
89
+ {
90
+ switch (baseRecord .Type )
91
+ {
92
+ // Replace the base path for DeleteDirOrFiles type record
93
+ case RecordType .DeleteDirOrFiles :
94
+ // Use DeleteDirOrFilesFlags as TEnum for ChangeBasePath() method
95
+ ChangeBasePath <DeleteDirOrFilesFlags >(baseRecord , @" C:\Program Files" , @" D:\Program Files" );
96
+ break ;
97
+ // Replace the base path for DeleteFile type record
98
+ case RecordType .DeleteFile :
99
+ // Use DeleteFileFlags as TEnum for ChangeBasePath() method
100
+ ChangeBasePath <DeleteFileFlags >(baseRecord , @" C:\Program Files" , @" D:\Program Files" );
101
+ break ;
102
+ }
103
+ }
104
+
105
+ // Save the record
106
+ innoLog .Save (innoFile );
107
+ }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
17
113
## License
18
114
The initial license is using [ The WTFPL License] ( https://github.com/CollapseLauncher/InnoSetupLogParser/blob/main/LICENSE ) .
0 commit comments