Skip to content

Commit 605cd3c

Browse files
committed
release version 0.2
1 parent e93738d commit 605cd3c

9 files changed

Lines changed: 2683 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ OpenSource swf to exe converter.
88

99
### Usage
1010

11-
Download release version and open it.
11+
Download newest release version and open it.
1212

1313
### References
1414

src/OpenSWF2EXE/OpenSWF2EXE/AboutForm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
namespace OpenSWF2EXE
2+
{
3+
public static class Config
4+
{
5+
private static string configPath;
6+
7+
static Config()
8+
{
9+
configPath = Path.Combine(new string[] { Environment.CurrentDirectory, "s2e_config.txt" });
10+
if (!File.Exists(configPath))
11+
{
12+
FileStream fileStream = File.Create(configPath);
13+
fileStream.Close();
14+
}
15+
}
16+
17+
public static int GetLanguage()
18+
{
19+
string value = GetString("language", "2");
20+
return int.Parse(value);
21+
}
22+
23+
public static void SetLanguage(int value)
24+
{
25+
SetString("language", value.ToString());
26+
}
27+
28+
public static string GetString(string key, string defaultVal)
29+
{
30+
string[] lines = File.ReadAllLines(configPath);
31+
32+
foreach (string line in lines)
33+
{
34+
int signIndex = line.IndexOf('=');
35+
if (signIndex == -1) continue;
36+
37+
string keyStr = line.Substring(0, signIndex);
38+
string keyStrWithoutSpace = keyStr.Trim();
39+
40+
//return first key
41+
if (keyStrWithoutSpace.Equals(key))
42+
{
43+
string valueStr = line.Substring(signIndex + 1, line.Length - 1 - keyStr.Length);
44+
string valueStrWithoutSpace = valueStr.Trim();
45+
return valueStrWithoutSpace;
46+
}
47+
}
48+
49+
return defaultVal;
50+
}
51+
52+
public static void SetString(string key, string value)
53+
{
54+
string[] lines = File.ReadAllLines(configPath);
55+
56+
//If the file is empty, just write!
57+
if (lines.Length == 0 || (lines.Length == 1 && string.IsNullOrWhiteSpace(lines[0])))
58+
{
59+
string content = key + " = " + value;
60+
File.WriteAllText(configPath, content);
61+
return;
62+
}
63+
64+
bool keyExists = false;
65+
bool needToWrite = false;
66+
67+
for (int i = 0; i < lines.Length; i++)
68+
{
69+
string line = lines[i];
70+
71+
int signIndex = line.IndexOf('=');
72+
if (signIndex == -1) continue;
73+
74+
string keyStr = line.Substring(0, signIndex);
75+
string keyStrWithoutSpace = keyStr.Trim();
76+
//Find first key
77+
if (keyStrWithoutSpace.Equals(key))
78+
{
79+
keyExists = true;
80+
string valueStr = line.Substring(signIndex + 1, line.Length - 1 - keyStr.Length);
81+
string valueStrWithoutSpace = valueStr.Trim();
82+
//If value changed
83+
if (valueStrWithoutSpace != value)
84+
{
85+
needToWrite = true;
86+
lines[i] = keyStrWithoutSpace + " = " + value;
87+
}
88+
break;
89+
}
90+
}
91+
92+
if (needToWrite)
93+
{
94+
File.WriteAllLines(configPath, lines);
95+
}
96+
else if (!keyExists)
97+
{
98+
string newLine = "\n" + key + " = " + value;
99+
List<string> newLines = new List<string>();
100+
newLines.AddRange(lines);
101+
newLines.Add(newLine);
102+
File.WriteAllLines(configPath, newLines.ToArray());
103+
}
104+
}
105+
}
106+
}

src/OpenSWF2EXE/OpenSWF2EXE/EXE2SWF.Designer.cs

Lines changed: 233 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)