xref: /trunk/main/tools/inc/tools/pathutils.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_TOOLS_PATHUTILS_HXX
29 #define INCLUDED_TOOLS_PATHUTILS_HXX
30 
31 #include "sal/config.h"
32 
33 #if defined WNT
34 
35 #include <cstddef>
36 
37 #define WIN32_LEAN_AND_MEAN
38 #include <windows.h>
39 
40 // The compiled code is not part of the tl dynamic library, but is delivered as
41 // pathutils-obj and pathutils-slo objects (it is linked into special
42 // executables and dynamic libraries that do not link against OOo libraries):
43 
44 namespace tools {
45 
46 // Determine the filename part of a path.
47 //
48 // @param path
49 // A non-NULL pointer to a null-terminated path.
50 //
51 // @return
52 // A pointer to the trailing filename part of the given path.
53 WCHAR * filename(WCHAR * path);
54 
55 // Concatenate two paths.
56 //
57 // Either the first path is empty and the second path is an absolute path.  Or
58 // the first path is an absolute path that ends in a backslash and the second
59 // path is a relative path.  In the latter case, to avoid paths that grow too
60 // long, leading .. segments of the second path are removed together with
61 // trailing segments from the first path.  This should not cause problems as
62 // long as there are no symbolic links on Windows (as with symbolic links,
63 // x\y\.. and x might denote different directories).
64 //
65 // @param path
66 // An output paremeter taking the resulting path; must point at a valid range of
67 // memory of size at least MAX_PATH.  If NULL is returned, the content is
68 // unspecified.
69 //
70 // @param frontBegin, frontEnd
71 // Forms a valid range [frontBegin .. frontEnd) of less than MAX_PATH size.
72 //
73 // @param backBegin, backLength
74 // Forms a valid range [backBeghin .. backBegin + backLength) of less than
75 // MAX_PATH size.
76 //
77 // @return
78 // A pointer to the terminating null character of the concatenation, or NULL if
79 // a failure occurred.
80 WCHAR * buildPath(
81     WCHAR * path, WCHAR const * frontBegin, WCHAR const * frontEnd,
82     WCHAR const * backBegin, std::size_t backLength);
83 
84 // Resolve a link file.
85 //
86 // @param path
87 // An input/output parameter taking the path; must point at a valid range of
88 // memory of size at least MAX_PATH.  On input, contains the null-terminated
89 // full path of the link file.  On output, contains the null-terminated full
90 // path of the resolved link; if NULL is returned, the content is unspecified.
91 //
92 // @return
93 // A pointer to the terminating null character of path, or NULL if a failure
94 // occurred.
95 WCHAR * resolveLink(WCHAR * path);
96 
97 }
98 
99 #endif
100 
101 #endif
102