7fd59977 |
1 | // File: TDocStd_PathParser.cxx |
2 | // Created: Fri Sep 17 17:51:42 1999 |
3 | // Author: Denis PASCAL |
4 | // <dp@dingox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <TDocStd_PathParser.ixx> |
8 | |
9 | TDocStd_PathParser::TDocStd_PathParser(const TCollection_ExtendedString& path) |
10 | { |
11 | myPath = path; |
12 | Parse(); |
13 | } |
14 | |
15 | void TDocStd_PathParser::Parse() |
16 | { |
17 | TCollection_ExtendedString temp = myPath; |
18 | Standard_Integer PointPosition = myPath.SearchFromEnd(TCollection_ExtendedString(".")); |
19 | if (PointPosition>0) |
20 | myExtension = temp.Split(PointPosition); |
21 | else |
22 | return; |
23 | temp.Trunc(PointPosition-1); |
24 | Standard_Boolean isFileName = (temp.Length()) ? Standard_True : Standard_False; |
25 | Standard_Boolean isTrek = Standard_True; |
26 | #ifdef WNT |
27 | PointPosition = temp.SearchFromEnd(TCollection_ExtendedString("\\")); |
28 | if (!(PointPosition>0)) |
29 | PointPosition = temp.SearchFromEnd(TCollection_ExtendedString("/")); |
30 | if (PointPosition >0) |
31 | myName = temp.Split(PointPosition); |
32 | else { |
33 | if(isFileName) { |
34 | myName = temp; |
35 | isTrek = Standard_False;} |
36 | else |
37 | return; |
38 | } |
39 | #else |
40 | PointPosition = temp.SearchFromEnd(TCollection_ExtendedString("/")); |
41 | if (PointPosition >0) |
42 | myName = temp.Split(PointPosition); |
43 | else { |
44 | if(isFileName) { |
45 | myName = temp; |
46 | isTrek = Standard_False;} |
47 | else |
48 | return; |
49 | } |
50 | #endif //WNT |
51 | if(isTrek) { |
52 | temp.Trunc(PointPosition-1); |
53 | myTrek = temp; |
54 | } else |
55 | #ifdef WNT |
56 | myTrek = ".\\"; |
57 | #else |
58 | myTrek = "./"; |
59 | #endif |
60 | } |
61 | |
62 | |
63 | TCollection_ExtendedString TDocStd_PathParser::Extension() const |
64 | { |
65 | return myExtension; |
66 | } |
67 | |
68 | TCollection_ExtendedString TDocStd_PathParser::Name() const |
69 | { |
70 | return myName; |
71 | } |
72 | |
73 | TCollection_ExtendedString TDocStd_PathParser::Trek() const |
74 | { |
75 | return myTrek; |
76 | } |
77 | |
78 | TCollection_ExtendedString TDocStd_PathParser::Path() const |
79 | { |
80 | return myPath; |
81 | } |
82 | |
83 | |
84 | Standard_Integer TDocStd_PathParser::Length() const |
85 | { |
86 | return myPath.Length(); |
87 | } |