forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNet35.cs
More file actions
129 lines (108 loc) · 3.53 KB
/
Copy pathNet35.cs
File metadata and controls
129 lines (108 loc) · 3.53 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#if NET35
// ReSharper disable once CheckNamespace
namespace BD.WTTS;
partial class Program
{
//// https://www.codeproject.com/questions/641314/check-64-or-32-bit-in-net-3-5
//delegate bool IsWow64ProcessDelegate([In] IntPtr handle, [Out] out bool isWow64Process);
//public static bool Is64BitOperatingSystem
//{
// get
// {
// if (IntPtr.Size == 8 || (IntPtr.Size == 4 && Is32BitProcessOn64BitProcessor()))
// {
// return true;
// }
// else
// {
// return false;
// }
// }
//}
//static IsWow64ProcessDelegate? GetIsWow64ProcessDelegate()
//{
// IntPtr handle = Program.LoadLibrary("kernel32");
// if (handle != IntPtr.Zero)
// {
// IntPtr fnPtr = Program.GetProcAddress(handle, "IsWow64Process");
// if (fnPtr != IntPtr.Zero)
// {
// return (IsWow64ProcessDelegate)Marshal.GetDelegateForFunctionPointer(fnPtr, typeof(IsWow64ProcessDelegate));
// }
// }
// return null;
//}
//static bool Is32BitProcessOn64BitProcessor()
//{
// var fnDelegate = GetIsWow64ProcessDelegate();
// if (fnDelegate == null)
// {
// return false;
// }
// bool retVal = fnDelegate.Invoke(Process.GetCurrentProcess().Handle, out var isWow64);
// if (retVal == false)
// {
// return false;
// }
// return isWow64;
//}
#if NET35 || NET40
[MethodImpl((MethodImplOptions)0x100)]
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static bool IsNullOrWhiteSpace(string value)
{
if (value == null)
{
return true;
}
for (int i = 0; i < value.Length; i++)
{
if (!char.IsWhiteSpace(value[i]))
{
return false;
}
}
return true;
}
#if NET35 || NET40
[MethodImpl((MethodImplOptions)0x100)]
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
[Conditional("DEBUG")]
public static void DebugWriteLine(string format, params object[] args)
{
Debug.WriteLine(string.Format(format, args));
}
public const char DirectorySeparatorChar = '\\';
#if NET35 || NET40
[MethodImpl((MethodImplOptions)0x100)]
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static string PathCombine(string path1, string path2, string path3)
{
return $"{path1}{(path1[path1.Length - 1] == DirectorySeparatorChar ? "" : DirectorySeparatorChar)}{path2}{DirectorySeparatorChar}{path3}";
}
#if NET35 || NET40
[MethodImpl((MethodImplOptions)0x100)]
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static string PathCombine(string path1, string path2, string path3, string path4)
{
return $"{path1}{(path1[path1.Length - 1] == DirectorySeparatorChar ? "" : DirectorySeparatorChar)}{path2}{DirectorySeparatorChar}{path3}{DirectorySeparatorChar}{path4}";
}
#if NET35 || NET40
[MethodImpl((MethodImplOptions)0x100)]
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static string PathCombine(string path1, string path2, string path3, string path4, string path5)
{
return $"{path1}{(path1[path1.Length - 1] == DirectorySeparatorChar ? "" : DirectorySeparatorChar)}{path2}{DirectorySeparatorChar}{path3}{DirectorySeparatorChar}{path4}{DirectorySeparatorChar}{path5}";
}
}
#endif