0022627: Change OCCT memory management defaults
[occt.git] / src / OSD / OSD_Path.cdl
1 --Copyright:      Matra Datavision 1992,1993
2
3 -- File:       OSD_Path.cdl
4 -- Created:    Tue Feb 18 10:54:35 1992
5 -- Author:     Stephan GARNAUD (ARM)
6 --             <sga@sparc4>
7 -- Modified by LD on Dec 15 1995
8 -- Methode SetSystemName added
9
10
11
12 class Path from OSD
13
14     --Purpose: Manage a system independent path.
15     --         It is possible to give this object a complete
16     --         path including VMS possibilities such as
17     --         Node"Username Password"::Disk:[path1.path2]
18     --         This system dependent syntax is avoided with the
19     --         SetValues method.
20  
21  uses Environment, SysType, Error, AsciiString from TCollection
22 raises ConstructionError, NullObject, OSDError, NumericError, ProgramError
23
24  is
25   Create returns Path;
26     ---Purpose: Creates a Path object initialized to an empty string.
27     --          i.e. current directory.
28     ---Level: Public
29
30   Create (aDependentName : AsciiString; aSysType : SysType=OSD_Default) returns Path
31     ---Purpose: Creates a Path object initialized by dependant path.
32     --          ex: OSD_Path me ("/usr/bin/myprog.sh",OSD_UnixBSD);
33     --              
34     --              OSD_Path me ("sys$common:[syslib]cc.exe",OSD_OSF) will
35     --              raise a ProgramError due to invalid name for this
36     --              type of system.
37     --              In order to avoid a 'ProgramError' , use IsValid(...)
38     --              to ensure you the validity of <aDependentName>.
39     --              Raises ConstructionError when the path is either null
40     --              or contains characters not in range of ' '...'~'.
41     ---Level: Public
42     raises ConstructionError;
43
44   Create (aNode,aUsername,aPassword,aDisk,aTrek,aName,anExtension: in AsciiString) returns Path;
45     ---Purpose: Initializes a system independent path.
46     --          By default , the Path conversion will be assumed using
47     --          currently used system.
48     --          A special syntax is used to specify a "aTrek" in an
49     --          independent manner :
50     --          a "|" represents directory separator
51     --          a "^" means directory above (father)
52     --          examples:
53     --          "|usr|bin" - On UNIX -> "/usr/bin"
54     --                     - On VMS  -> "[usr.bin]"
55     --                     - On MSDOS-> "\usr\bin"
56     --                     - On MacOs-> ": usr : bin"
57     --
58     --          "^|rep"    - On UNIX -> "../rep"
59     --                     - On VMS  -> "[-.rep]" 
60     --                     - On MSDOS -> "..\rep"
61     --                     - On MacOS->  ":: rep"
62     --          
63     --          "subdir|" - On UNIX -> "subdir/"
64     --                    - On VMS  -> "[.subdir.]"
65
66     ---Example: Create("amelix", "sga", "toto", "dk$22", "|bin|usr",myFile,"")
67     --          will give internaly
68     --          On MS-DOS/OS2           \DK22\BIN\USR\MYFILE
69     --          On UNIX                 sga"toto"@amelix:/dk22/bin/usr/myFile
70     --          On VMS                  AMELIX"SGA TOTO"::DK$22:[BIN.USR]MYFILE
71     --          On MacOs                dk$22 : bin : usr : myFile
72     --
73     -- As you can see, "aDisk" is  used under UNIX.
74     -- This is possible when one 'mounts' a directory from another system.
75     -- However, the syntax of <aDisk> can slightly change on several systems.
76     -- So "DK$22" on VMS becomes "dk22" on UNIX and Windows NT.
77     -- for instance when you mount a VMS directory under UNIX this gives:
78     --
79     -- lucide:/dk22/mydirectory mounted on /vms/mydirectory
80     ---Level: Public
81
82
83   Values (me ; aNode,aUsername,aPassword,aDisk,aTrek,aName,anExtension :
84      out AsciiString) is static;
85     ---Purpose: Gets each component of a path.
86     ---Level: Public
87
88   SetValues (me : in out; 
89     aNode,aUsername,aPassword,aDisk,aTrek,aName,anExtension : in AsciiString)
90     ---Purpose: Sets each component of a path.
91     ---Level: Public
92     raises ConstructionError is static;
93
94   SystemName(me ; FullName : out AsciiString ; aType : SysType=OSD_Default) 
95     is static;
96     ---Purpose: Returns system dependent path
97     --          <aType> is one among Unix,VMS ...
98     --          This function is not private because you may need to
99     --          display system dependent path on a front-end.
100     --          It can be useful when communicating with another system.
101     --          For instance when you want to communicate between VMS and Unix 
102     --          to transfer files, or to do a remote procedure call 
103     --          using files.
104     --          example : 
105     --          OSD_Path myPath ("sparc4", "sga", "secret_passwd",
106     --                           "$5$dkb100","|users|examples");
107     --          Internal ( Dependent_name );
108     --          On UNIX  sga"secret_passwd"@sparc4:/users/examples
109     --          On VMS   sparc4"sga secret_passwd"::$5$dkb100:[users.examples] 
110     ---Level: Public
111
112 --   SetSystemName(me : in out ; aDependentName : AsciiString; aSysType : SysType=OSD_Default)
113     ---Purpose: Sets each component of a Path giving its system dependent name.
114     ---Level: Public
115 --    raises ConstructionError is static;
116
117   ExpandedName(me : in out; aName : out AsciiString) 
118     is static;
119     ---Purpose: Returns system dependent path resolving logical symbols.
120
121   IsValid (me ; aDependentName : AsciiString; aSysType : SysType=OSD_Default) 
122     returns Boolean is static;
123     ---Purpose: Returns TRUE if <aDependentName> is valid for this SysType.
124     ---Level: Public
125
126
127   UpTrek (me : in out) is static;
128    ---Purpose: This removes the last directory name in <aTrek>
129    --          and returns result.
130    --          ex:  me = "|usr|bin|todo.sh" 
131    --               me.UpTrek() gives me = "|usr|todo.sh"
132    --          if <me> contains "|", me.UpTrek() will give again "|"
133    --          without any error.
134    ---Level: Public
135
136   DownTrek(me : in out; aName : AsciiString) is static;
137    ---Purpose: This appends a directory name into the Trek.
138    --          ex: me = "|usr|todo.sh"
139    --              me.DownTrek("bin") gives me = "|usr|bin|todo.sh".
140    ---Level: Public
141
142   TrekLength(me) returns Integer is static;
143    ---Purpose: Returns number of components in Trek of <me>.
144    --          ex: me = "|usr|sys|etc|bin"
145    --              me.TrekLength() returns 4.
146    ---Level: Public
147
148   RemoveATrek(me : in out; where : Integer)
149    ---Purpose: This removes a component of Trek in <me> at position <where>.
150    --          The first component of Trek is numbered 1.
151    --          ex:   me = "|usr|bin|"
152    --                me.RemoveATrek(1) gives me = "|bin|"
153    --          To avoid a 'NumericError' because of a bad <where>, use
154    --          TrekLength() to know number of components of Trek in <me>.
155    ---Level: Public
156    raises NumericError is static;
157
158   RemoveATrek(me : in out; aName : AsciiString) is static;
159    ---Purpose: This removes <aName> from <me> in Trek.
160    --          No error is raised if <aName> is not in <me>.
161    --          ex:  me = "|usr|sys|etc|doc"
162    --               me.RemoveATrek("sys") gives me = "|usr|etc|doc".
163    ---Level: Public
164
165   TrekValue(me ; where : Integer) returns AsciiString
166    ---Purpose: Returns component of Trek in <me> at position <where>.
167    --          ex:  me = "|usr|bin|sys|"
168    --               me.TrekValue(2) returns "bin"
169    raises NumericError is static;
170    ---Level: Public
171
172   InsertATrek(me : in out; aName : AsciiString; where : Integer)
173    ---Purpose: This inserts <aName> at position <where> into Trek of <me>.
174    --          ex:  me = "|usr|etc|"
175    --               me.InsertATrek("sys",2) gives me = "|usr|sys|etc" 
176    raises NumericError is static;
177    ---Level: Public
178
179   Node (me) returns AsciiString is static;
180    ---Purpose: Returns Node of <me>.
181    ---Level: Public
182
183   UserName (me) returns AsciiString is static;
184    ---Purpose: Returns UserName of <me>.
185    ---Level: Public
186
187   Password (me) returns AsciiString is static;
188    ---Purpose: Returns Password of <me>.
189    ---Level: Public
190
191   Disk(me) returns AsciiString is static;
192    ---Purpose: Returns Disk of <me>.
193    ---Level: Public
194
195   Trek(me) returns AsciiString is static;
196    ---Purpose: Returns Trek of <me>.
197    ---Level: Public
198
199   Name (me) returns AsciiString is static;
200    ---Purpose: Returns file name of <me>.
201      --          If <me> hasn't been initialized, it returns an empty AsciiString.
202    ---Level: Public
203                                              
204   Extension (me) returns AsciiString is static;
205    ---Purpose: Returns my extension name.
206      --          This returns an empty string if path contains no file name.
207    ---Level: Public
208
209   SetNode (me : in out; aName : AsciiString) is static;
210    ---Purpose: Sets Node of <me>.
211    ---Level: Public
212
213   SetUserName (me : in out; aName : AsciiString) is static;
214    ---Purpose: Sets UserName of <me>.
215    ---Level: Public
216
217   SetPassword (me : in out; aName : AsciiString) is static;
218    ---Purpose: Sets Password of <me>.
219    ---Level: Public
220
221   SetDisk(me : in out; aName : AsciiString) is static;
222    ---Purpose: Sets Disk of <me>.
223    ---Level: Public
224
225   SetTrek(me : in out; aName : AsciiString) is static;
226    ---Purpose: Sets Trek of <me>.
227    ---Level: Public
228
229   SetName (me : in out; aName : AsciiString) is static;
230    ---Purpose: Sets file name of <me>.
231    --          If <me> hasn't been initialized, it returns an empty AsciiString.
232    ---Level: Public
233                                              
234   SetExtension (me : in out; aName : AsciiString) is static;
235    ---Purpose: Sets my extension name.
236    ---Level: Public
237
238   LocateExecFile(me : in out; aPath: out Path from OSD )
239   returns Boolean from Standard ;
240    ---Purpose: Finds the full path of an executable file, like the
241    --          "which" Unix utility. Uses the path environment variable.
242    --          Returns False if executable file not found.
243    ---Level: Public    
244         
245   RelativePath(myclass; DirPath, AbsFilePath : AsciiString from TCollection)
246   returns AsciiString from TCollection ;
247    ---Purpose: Returns the relative file path between the absolute directory 
248    ---         path <DirPath>  and the absolute file path <AbsFilePath>.
249    ---         If <DirPath> starts with "/", pathes are handled as
250    ---         on Unix, if it starts with a letter followed by ":", as on
251    ---         WNT. In particular on WNT directory names are not key sensitive.
252    ---         If handling fails, an empty string is returned.
253    ---Level: Public
254
255
256   AbsolutePath(myclass; DirPath, RelFilePath : AsciiString from TCollection) 
257   returns AsciiString from TCollection ;
258    ---Purpose: Returns the absolute file path from the absolute directory path
259    ---         <DirPath> and the relative file path returned by RelativePath().
260    ---         If the RelFilePath is an absolute path, it is returned and the
261    ---         directory path is ignored.
262    ---         If handling fails, an empty string is returned.
263
264
265  fields
266   myNode      : AsciiString;
267   myUserName  : AsciiString;
268   myPassword  : AsciiString;
269   myDisk      : AsciiString;
270   myTrek      : AsciiString;
271   myName      : AsciiString;
272   myExtension : AsciiString;
273   myUNCFlag   : Boolean ;
274   SysDep      : SysType;  -- To allow system specific use
275 end Path from OSD;