blob: 6fbe46220e07c9fe0f13390cb376341f6800c721 (
plain)
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
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Portable.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// Defines the Portable type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrake.Worker
{
using System;
using System.Collections.Generic;
using System.IO;
public class Portable
{
private static readonly string PortableFile = Path.Combine(Environment.CurrentDirectory, "portable.ini");
private static Dictionary<string, string> keyPairs = new Dictionary<string, string>();
public static bool Initialise()
{
if (!IsPortable())
{
return true;
}
// Read the INI file
if (File.Exists(PortableFile))
{
try
{
using (StreamReader fileReader = new StreamReader(PortableFile))
{
string line;
while ((line = fileReader.ReadLine()) != null)
{
line = line.Trim();
if (line.StartsWith("#"))
{
continue; // Ignore Comments
}
string[] setting = line.Split('=');
if (setting.Length == 2)
{
keyPairs.Add(setting[0].Trim(), setting[1].Trim());
}
}
}
}
catch
{
return false;
}
}
return true;
}
public static bool IsPortable()
{
if (!File.Exists(PortableFile))
{
return false;
}
return true;
}
public static bool IsProcessIsolationEnabled()
{
if (keyPairs.ContainsKey("process.isolation.enabled"))
{
string enabled = keyPairs["process.isolation.enabled"];
if (!string.IsNullOrEmpty(enabled) && enabled.Trim() == "true")
{
return true;
}
return false;
}
return true; // Default to On.
}
}
}
|