-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathShimPath.cs
106 lines (94 loc) · 3.59 KB
/
ShimPath.cs
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
/*
* Copyright (c) 2013-2015, Cureos AB.
* All rights reserved.
* http://www.cureos.com
*
* This file is part of Shim.
*
* Shim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Shim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Shim. If not, see <http://www.gnu.org/licenses/>.
*/
#if NETFX_CORE
using Windows.Storage;
#endif
namespace System.IO
{
/// <summary>
/// Shim complement for the <see cref="Path"/> class, providing members that are
/// not included in the PCL member subset of the <see cref="Path"/> class.
/// </summary>
public static class ShimPath
{
#region FIELDS
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="F:System.IO.Path.PathSeparator"]/*' />
public static readonly char PathSeparator = '\\';
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="F:System.IO.Path.DirectorySeparatorChar"]/*' />
public static readonly char DirectorySeparatorChar = '\\';
#endregion
#region METHODS
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="M:System.IO.Path.GetTempPath"]/*' />
public static string GetTempPath()
{
#if NETFX_CORE
return ApplicationData.Current.TemporaryFolder.Path;
#elif WINDOWS_PHONE || DOTNET
return Path.GetTempPath();
#else
throw new PlatformNotSupportedException("PCL");
#endif
}
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="M:System.IO.Path.GetTempFileName"]/*' />
public static string GetTempFileName()
{
#if NETFX_CORE
const string DefaultFileExtension = ".tmp";
return Path.ChangeExtension(global::System.IO.Path.Combine(GetTempPath(),
global::System.IO.Path.GetRandomFileName()), DefaultFileExtension);
#elif WINDOWS_PHONE || DOTNET
return Path.GetTempFileName();
#else
throw new PlatformNotSupportedException("PCL");
#endif
}
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="M:System.IO.Path.GetFullPath(System.String)"]/*' />
public static string GetFullPath(string path)
{
#if NETFX_CORE
return path;
#elif WINDOWS_PHONE || DOTNET
return Path.GetFullPath(path);
#else
throw new PlatformNotSupportedException("PCL");
#endif
}
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="M:System.IO.Path.GetDirectoryName(System.String)"]/*' />
public static string GetDirectoryName(string path)
{
#if PROFILE328
throw new PlatformNotSupportedException("PCL");
#else
return Path.GetDirectoryName(path);
#endif
}
/// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="M:System.IO.Path.Combine(System.String[])"]/*' />
public static string Combine(params string[] paths)
{
#if PROFILE328
throw new PlatformNotSupportedException("PCL");
#else
return Path.Combine(paths);
#endif
}
#endregion
}
}