OSDN Git Service

#37177 キーアサインでPOVを登録すると、同じ方向のHATが消える問題を修正。
[dtxmania/dtxmania.git] / DTXCreatorプロジェクト / コード / 06.汎用 / Cファイル選択・パス変換.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.IO;\r
5 \r
6 namespace DTXCreator.汎用\r
7 {\r
8         public class Cファイル選択_パス変換\r
9         {\r
10                 public static bool b絶対パスである( string strパス )\r
11                 {\r
12                         try\r
13                         {\r
14                                 new Uri( strパス );\r
15                         }\r
16                         catch\r
17                         {\r
18                                 return false;\r
19                         }\r
20                         return true;\r
21                 }\r
22                 public static string str基点からの相対パスに変換して返す( string str変換対象の絶対パス, string str基点となる絶対パス )\r
23                 {\r
24                         if( str基点となる絶対パス == "" )\r
25                         {\r
26                                 return str変換対象の絶対パス;\r
27                         }\r
28                         if( str変換対象の絶対パス == "" )\r
29                         {\r
30                                 return "";\r
31                         }\r
32                         Uri uri = new Uri( str基点となる絶対パス );\r
33                         return Uri.UnescapeDataString( uri.MakeRelativeUri( new Uri( str変換対象の絶対パス ) ).ToString() ).Replace( '/', '\\' );\r
34                 }\r
35                 public static string str指定されたファイルの存在するフォルダを絶対パスで返す( string strファイルのパス, string strパスが相対の場合の基点絶対パス )\r
36                 {\r
37                         if( !b絶対パスである( strファイルのパス ) )\r
38                         {\r
39                                 strファイルのパス = strパスが相対の場合の基点絶対パス + strファイルのパス;\r
40                         }\r
41                         string directoryName = Path.GetDirectoryName( strファイルのパス );\r
42                         if( directoryName == null )\r
43                         {\r
44                                 return @"\";\r
45                         }\r
46                         if( !directoryName.EndsWith( @"\" ) )\r
47                         {\r
48                                 directoryName = directoryName + @"\";\r
49                         }\r
50                         return directoryName;\r
51                 }\r
52         }\r
53 }\r