Skip to content

Commit 2dc6a75

Browse files
committed
Update 1.0.2, added support for spaces in process names.
1 parent 2c00a0c commit 2dc6a75

File tree

3 files changed

+53
-29
lines changed

3 files changed

+53
-29
lines changed

ProcessAffinityControlTool.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
6-
<Version>1.0.1</Version>
6+
<Version>1.0.2</Version>
77
<PackageIcon>PACT Logo.png</PackageIcon>
88
<PackageIconUrl />
99
<RepositoryUrl>https://github.com/sas41/ProcessAffinityControlTool/</RepositoryUrl>
@@ -16,6 +16,7 @@
1616
<ApplicationIcon>PACT.ico</ApplicationIcon>
1717
<Win32Resource />
1818
<ApplicationManifest>app.manifest</ApplicationManifest>
19+
<AssemblyVersion>1.0.2.0</AssemblyVersion>
1920
</PropertyGroup>
2021

2122
<ItemGroup>

Program.cs

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -159,42 +159,64 @@ static void SaveConfig(PACTConfig conf)
159159
//////////////////////////////////////
160160
static void AddException(List<string> arguments)
161161
{
162-
int priority;
163-
List<int> cores = new List<int>();
164-
string exeName;
165-
166-
if (arguments.Count >= minArgumentCount_AddException && int.TryParse(arguments[2], out priority))
162+
if (arguments.Count >= minArgumentCount_AddException)
167163
{
168-
foreach (var str in arguments.Skip(3))
164+
int priority;
165+
List<int> cores = new List<int>();
166+
167+
arguments = arguments.Skip(1).ToList();
168+
string exeName = arguments[0];
169+
170+
if (exeName[0] == '\"')
169171
{
170-
int number;
171-
if (int.TryParse(str, out number) && number <= highestCoreNumber && number >= 0)
172-
{
173-
cores.Add(number);
174-
}
175-
else
172+
arguments = arguments.Skip(1).ToList();
173+
string current = arguments[0];
174+
175+
while (!current.Contains('\"'))
176176
{
177-
throw new ArgumentException();
177+
exeName = $"{exeName} {current}";
178+
arguments = arguments.Skip(1).ToList();
179+
current = arguments[0];
178180
}
181+
182+
exeName = $"{exeName} {current}";
179183
}
180184

181-
exeName = arguments[1];
182-
cores.Sort();
185+
arguments = arguments.Skip(1).ToList();
183186

184-
if (exeName.Substring(exeName.Length - 4, 4) == ".exe")
187+
if (int.TryParse(arguments[0], out priority))
185188
{
186-
exeName = exeName.Substring(0, exeName.Length - 4);
187-
}
189+
foreach (var str in arguments.Skip(1))
190+
{
191+
int number;
192+
if (int.TryParse(str, out number) && number <= highestCoreNumber && number >= 0)
193+
{
194+
cores.Add(number);
195+
}
196+
else
197+
{
198+
throw new ArgumentException();
199+
}
200+
}
188201

189-
if (conf.ProcessConfigs.ContainsKey(exeName))
190-
{
191-
conf.ProcessConfigs[exeName] = new ProcessConfig(cores, priority);
192-
Console.WriteLine($"Process [{exeName}] has been updated!");
193-
}
194-
else
195-
{
196-
conf.ProcessConfigs.Add(exeName, new ProcessConfig(cores, priority));
197-
Console.WriteLine($"Process [{exeName}] has been added!");
202+
exeName = exeName.Replace("\"", "");
203+
cores.Sort();
204+
205+
if (exeName.Length > 4 && exeName.Substring(exeName.Length - 4, 4) == ".exe")
206+
{
207+
exeName = exeName.Substring(0, exeName.Length - 4);
208+
}
209+
210+
if (conf.ProcessConfigs.ContainsKey(exeName))
211+
{
212+
conf.ProcessConfigs[exeName] = new ProcessConfig(cores, priority);
213+
Console.WriteLine($"Process [{exeName}] has been updated!");
214+
}
215+
else
216+
{
217+
conf.ProcessConfigs.Add(exeName, new ProcessConfig(cores, priority));
218+
Console.WriteLine($"Process [{exeName}] has been added!");
219+
}
198220
}
199221
}
200222
else

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ If you find this tool helpful and wish to donate, you can do so here: https://ww
3030
5: Real Time (Not Recommended)
3131
Cores:
3232
Can be from 0 to howevermany you have.
33-
Example:
33+
Examples:
3434
add firefox 2 0 3
35+
add "my program" 2 0 3
3536
3637
This will ensure every instance of [firefox]
3738
runs with [2-Normal] priority on cores [0 & 3].

0 commit comments

Comments
 (0)