xref: /trunk/main/tools/inc/tools/pathutils.hxx (revision 8b851043)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_TOOLS_PATHUTILS_HXX
25 #define INCLUDED_TOOLS_PATHUTILS_HXX
26 
27 #include "sal/config.h"
28 
29 #if defined WNT
30 
31 #include <cstddef>
32 
33 #define WIN32_LEAN_AND_MEAN
34 #include <windows.h>
35 
36 // The compiled code is not part of the tl dynamic library, but is delivered as
37 // pathutils-obj and pathutils-slo objects (it is linked into special
38 // executables and dynamic libraries that do not link against OOo libraries):
39 
40 namespace tools {
41 
42 // Determine the filename part of a path.
43 //
44 // @param path
45 // A non-NULL pointer to a null-terminated path.
46 //
47 // @return
48 // A pointer to the trailing filename part of the given path.
49 WCHAR * filename(WCHAR * path);
50 
51 // Concatenate two paths.
52 //
53 // Either the first path is empty and the second path is an absolute path.  Or
54 // the first path is an absolute path that ends in a backslash and the second
55 // path is a relative path.  In the latter case, to avoid paths that grow too
56 // long, leading .. segments of the second path are removed together with
57 // trailing segments from the first path.  This should not cause problems as
58 // long as there are no symbolic links on Windows (as with symbolic links,
59 // x\y\.. and x might denote different directories).
60 //
61 // @param path
62 // An output paremeter taking the resulting path; must point at a valid range of
63 // memory of size at least MAX_PATH.  If NULL is returned, the content is
64 // unspecified.
65 //
66 // @param frontBegin, frontEnd
67 // Forms a valid range [frontBegin .. frontEnd) of less than MAX_PATH size.
68 //
69 // @param backBegin, backLength
70 // Forms a valid range [backBeghin .. backBegin + backLength) of less than
71 // MAX_PATH size.
72 //
73 // @return
74 // A pointer to the terminating null character of the concatenation, or NULL if
75 // a failure occurred.
76 WCHAR * buildPath(
77     WCHAR * path, WCHAR const * frontBegin, WCHAR const * frontEnd,
78     WCHAR const * backBegin, std::size_t backLength);
79 
80 // Resolve a link file.
81 //
82 // @param path
83 // An input/output parameter taking the path; must point at a valid range of
84 // memory of size at least MAX_PATH.  On input, contains the null-terminated
85 // full path of the link file.  On output, contains the null-terminated full
86 // path of the resolved link; if NULL is returned, the content is unspecified.
87 //
88 // @return
89 // A pointer to the terminating null character of path, or NULL if a failure
90 // occurred.
91 WCHAR * resolveLink(WCHAR * path);
92 
93 }
94 
95 #endif
96 
97 #endif
98