Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _OSL_FILE_PATH_HELPER_HXX_
21 : #define _OSL_FILE_PATH_HELPER_HXX_
22 :
23 : #include "file_path_helper.h"
24 :
25 : #include <rtl/ustring.hxx>
26 :
27 : namespace osl
28 : {
29 :
30 : /*******************************************
31 : systemPathRemoveSeparator
32 : Removes the last separator from the
33 : given system path if any and if the path
34 : is not the root path '/'
35 :
36 : @param ppustrPath [inout] a system path
37 : if the path is not the root path
38 : and the last character is a
39 : path separator it will be cut off
40 : ppustrPath must not be NULL and
41 : must point to a valid rtl_uString
42 :
43 : @returns nothing
44 :
45 : ******************************************/
46 :
47 2 : inline void systemPathRemoveSeparator(/*inout*/ rtl::OUString& Path)
48 : {
49 2 : osl_systemPathRemoveSeparator(Path.pData);
50 2 : }
51 :
52 : /*******************************************
53 : systemPathEnsureSeparator
54 : Adds a trailing path separator to the
55 : given system path if not already there
56 : and if the path is not the root path '/'
57 :
58 : @param pustrPath [inout] a system path
59 : if the path is not the root path
60 : '/' and has no trailing separator
61 : a separator will be added
62 : ppustrPath must not be NULL and
63 : must point to a valid rtl_uString
64 :
65 : @returns nothing
66 :
67 : ******************************************/
68 :
69 0 : inline void systemPathEnsureSeparator(/*inout*/ rtl::OUString& Path)
70 : {
71 0 : osl_systemPathEnsureSeparator(&Path.pData);
72 0 : }
73 :
74 : /*******************************************
75 : systemPathIsRelativePath
76 : Returns true if the given path is a
77 : relative path and so starts not with '/'
78 :
79 : @param pustrPath [in] a system path
80 : pustrPath must not be NULL
81 :
82 : @returns sal_True if the given path
83 : doesn't start with a separator
84 : else sal_False will be returned
85 :
86 : ******************************************/
87 :
88 127526 : inline bool systemPathIsRelativePath(const rtl::OUString& Path)
89 : {
90 127526 : return osl_systemPathIsRelativePath(Path.pData);
91 : }
92 :
93 : /******************************************
94 : systemPathMakeAbsolutePath
95 : Append a relative path to a base path
96 :
97 : @param pustrBasePath [in] a system
98 : path that will be considered as
99 : base path
100 : pustrBasePath must not be NULL
101 :
102 : @param pustrRelPath [in] a system path
103 : that will be considered as
104 : relative path
105 : pustrBasePath must not be NULL
106 :
107 : @param ppustrAbsolutePath [out] the
108 : resulting path which is a
109 : concatination of the base and
110 : the relative path
111 : if base path is empty the
112 : resulting absolute path is the
113 : relative path
114 : if relative path is empty the
115 : resulting absolute path is the
116 : base path
117 : if base and relative path are
118 : empty the resulting absolute
119 : path is also empty
120 : ppustrAbsolutePath must not be
121 : NULL and *ppustrAbsolutePath
122 : must be 0 or point to a valid
123 : rtl_uString
124 :
125 : *****************************************/
126 :
127 0 : inline void systemPathMakeAbsolutePath(
128 : const rtl::OUString& BasePath,
129 : const rtl::OUString& RelPath,
130 : rtl::OUString& AbsolutePath)
131 : {
132 : osl_systemPathMakeAbsolutePath(
133 0 : BasePath.pData, RelPath.pData, &AbsolutePath.pData);
134 0 : }
135 :
136 : /********************************************
137 : systemPathIsHiddenFileOrDirectoryEntry
138 : Returns sal_True if the last part of
139 : given system path is not '.' or '..'
140 : alone and starts with a '.'
141 :
142 : @param pustrPath [in] a system path,
143 : must not be NULL
144 :
145 : @returns sal_True if the last part of
146 : the given system path starts
147 : with '.' or sal_False the last
148 : part is '.' or '..' alone or
149 : doesn't start with a dot
150 :
151 : *********************************************/
152 :
153 212656 : inline bool systemPathIsHiddenFileOrDirectoryEntry(
154 : const rtl::OUString& Path)
155 : {
156 212656 : return osl_systemPathIsHiddenFileOrDirectoryEntry(Path.pData);
157 : }
158 :
159 : /************************************************
160 : searchPath
161 : ***********************************************/
162 :
163 0 : inline bool searchPath(
164 : const rtl::OUString& ustrFilePath,
165 : const rtl::OUString& ustrSearchPathList,
166 : rtl::OUString& ustrPathFound)
167 : {
168 : return osl_searchPath(
169 : ustrFilePath.pData,
170 : ustrSearchPathList.pData,
171 0 : &ustrPathFound.pData);
172 : }
173 :
174 : } // namespace osl
175 :
176 : #endif /* #ifndef _OSL_PATH_HELPER_HXX_ */
177 :
178 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|