[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Compatibility / Path.cs
1 // ***********************************************************************
2 // Copyright (c) 2010 Charlie Poole
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
23 #define PORTABLE
24 #define TIZEN
25 #define NUNIT_FRAMEWORK
26 #define NUNITLITE
27 #define NET_4_5
28 #define PARALLEL
29 #if PORTABLE
30 namespace NUnit.Compatibility
31 {
32     /// <summary>
33     /// Some path based methods that we need even in the Portable framework which
34     /// does not have the System.IO.Path class
35     /// </summary>
36     public static class Path
37     {
38         /// <summary>
39         /// Windows directory separator
40         /// </summary>
41         public static readonly char WindowsSeparatorChar = '\\';
42         /// <summary>
43         /// Alternate directory separator
44         /// </summary>
45         public static readonly char AltDirectorySeparatorChar = '/';
46         /// <summary>
47         /// A volume separator character.
48         /// </summary>
49         public static readonly char VolumeSeparatorChar = ':';
50
51         /// <summary>
52         /// Get the file name and extension of the specified path string.
53         /// </summary>
54         /// <param name="path">The path string from which to obtain the file name and extension.</param>
55         /// <returns>The filename as a <see cref="T:System.String"/>. If the last character of <paramref name="path"/> is a directory or volume separator character, this method returns <see cref="F:System.String.Empty"/>. If <paramref name="path"/> is null, this method returns null.</returns>
56         public static string GetFileName(string path)
57         {
58             if (path != null)
59             {
60                 int length = path.Length;
61                 for( int index = length - 1; index >= 0; index--)
62                 {
63                     char ch = path[index];
64                     if (ch == Path.WindowsSeparatorChar || ch == Path.AltDirectorySeparatorChar || ch == Path.VolumeSeparatorChar)
65                         return path.Substring(index + 1, length - index - 1);
66                 }
67             }
68             return path;
69         }
70     }
71 }
72 #endif