blob: 25bd7740a98b3fe457fbb87a00b291e5f64297d7 (
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
|
/**
* Namespace: System.Web.Utils
* Class: FilePathParser
*
* Author: Gaurav Vaish
* Maintainer: gvaish@iitk.ac.in
* Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
* Implementation: yes
* Status: ??%
*
* (C) Gaurav Vaish (2001)
*/
using System.IO;
namespace System.Web.Utils
{
internal class FilePathParser
{
private static char[] pathSeparators = {
Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar
};
private string dirName;
private string fileName;
private string shortDirName;
private string shortFileName;
private bool exists;
[MonoTODO]
public FilePathParser(string path, bool isFile, bool getShortNames)
{
path = path.Trim();
if(Path.GetPathRoot(path).Length < path.Length)
{
path = path.TrimEnd(pathSeparators);
}
if(!isFile)
{
dirName = GetBaseDirOrRoot(path);
} else
{
dirName = path;
}
if(getShortNames)
{
if(!Directory.Exists(dirName))
{
dirName = null;
return;
}
shortDirName = GetShortPathName(dirName);
if(shortDirName==null)
{
dirName = null;
return;
}
if(shortDirName == dirName)
{
shortDirName = null;
} else
{
throw new NotImplementedException();
}
}
}
public static string GetBaseDirOrRoot(string file)
{
string bDir = Path.GetDirectoryName(file);
return ( bDir!=null ? bDir : Path.GetPathRoot(file));
}
[MonoTODO("Native_Call_Required")]
public static string GetShortPathName(string path)
{
//TODO: Native calls required, it's in kernel32.dll for windows
throw new NotImplementedException();
}
}
}
|