-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMacros.Ish
More file actions
110 lines (94 loc) · 3.42 KB
/
Macros.Ish
File metadata and controls
110 lines (94 loc) · 3.42 KB
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
#ifndef _MACROS_ISH_
#Define _MACROS_ISH_ __PATHFILENAME__
//Author : KngStr
//Link : http://www.kngstr.com/
//Description : .
//Modified : 2013-11-05 22:17:39
//Tested Inno :
//Usage :
#define AddQuotes(str S) \
Local[0] = S, \
Local[0] = Copy(Local[0], 1, 1) == '"' ? Local[0] : ('"' + Local[0]), \
Copy(Local[0], Len(Local[0])) == '"' ? Local[0] : (Local[0] + '"')
#define RemoveQuotes(str S) \
Local[0] = S, \
Local[0] = Copy(Local[0], 1, 1) == '"' ? Copy(Local[0], 2, Len(Local[0])) : Local[0], \
Copy(Local[0], Len(Local[0])) == '"' ? Copy(Local[0], 1, Len(Local[0]) - 1) : Local[0]
#define FolderExists(str DirName) \
Local[0] = FindFirst(RemoveBackslash(DirName), faDirectory | faHidden | faSysFile ), \
Local[0] ? (FindClose(Local[0]), Local[0] = 1) : (Local[0] = 0), \
Local[0]
#ifndef DirExists
#define DirExists(str DirName) \
FolderExists(DirName)
#endif
#define GetCurDir() \
Exec("cmd.exe", '/c echo [Main]>"%Temp%\Defines.ini" & echo SrcPath="%cd%" >>"%Temp%\Defines.ini"', ".\", 1, SW_HIDE), \
ReadIni(GetEnv("Temp") + '\Defines.ini', 'Main', 'SrcPath', '')
#define SectionConst(str s) \
StringChange(s, "{", "{{")
#define CodeConst(str s) \
StringChange(s, "'", "''")
#define PercentConst(str s) \
Local[0] = StringChange(s, "{", "{{"), \
Local[0] = StringChange(Local[0], "%", "%25"), \
Local[0] = StringChange(Local[0], "}", "%7d"), \
Local[0] = StringChange(Local[0], "|", "%7c"), \
Local[0] = StringChange(Local[0], ",", "%2c"), \
Local[0]
//Author: KngStr
//Usage:
//#if InvalidFileName(FileName)
// #error "Error! FileName can not inlude£º\/:*?"<>| "
//#endif
#define InvalidFileName(str FileName) \
Pos("\", FileName) + Pos("/", FileName) + Pos(":", FileName) + Pos("*", FileName) + \
Pos("?", FileName) + Pos('"', FileName) + Pos("<", FileName) + Pos(">", FileName) + Pos("|", FileName)
//Author: KngStr
//Usage:
//ReadPrdVerDef("FileName", "0.0")
#define ReadPrdVerDef(str FileName, str DefVer) \
Local[0] = GetFileProductVersion(FileName), \
Local[0] == "" ? Local[0] = DefVer : Local[0] = StringChange(Local[0], ",", "."), \
Int(StringChange(Local[0], ".", ""), -1) > 0 ? Local[0] : DefVer
// Inno Setup Preprocessor macro to simplify the version string.
// The following situations are covered:
// http://www.vincenzo.net/isxkb/index.php?title=SimpleVersionMacro
// (1) 1.2.4.3 -> 1.2.4
// (2) 1.2.4.0 -> 1.2.4
// (3) 1.2.0.0 -> 1.2
// (4) 1.0.0.0 -> 1.0
// (5) 1.0.0.2 -> 1.0
// (6) 1.3.0.1 -> 1.3
#define SimpleVersion(str S) \
Local[0] = Pos (".0.0.", S), \
/* (4) and (5) */ \
(Local[0] > 0) ? Copy (S, 1, 3) : \
( \
Local[0] = Pos (".0.0", S), \
/* (3) */ \
(Local[0] > 0) ? Copy (S, 1, 3) : \
( \
Local[0] = Pos (".0", S), \
/* (2) */ \
(Local[0] > 5) ? Copy (S, 1, Local[0] - 1) : \
( \
Local[0] = Pos (".0.", S), \
/* (6) */ \
(Local[0] > 0) ? Copy (S, 1, 3) : \
( \
Copy (S, 1, 5) \
) \
) \
) \
);
// Read the previuos build number. If there is none take 0 instead.
// Increment the build number by one.
// Store the number in the ini file for the next build.
// http://www.vincenzo.net/isxkb/index.php?title=Incrementing_build_number_every_time_the_script_is_compiled
#define BuildNum(str SetFile = AddBackslash(SourcePath) + "BuildInfo.ini") \
Local[0] = Int(ReadIni(SetFile,"BuildInfo","Times","0")), \
Local[0] = Local[0] + 1, \
WriteIni(SetFile,"BuildInfo","Times", Local[0]), \
Local[0]
#endif