LCOV - code coverage report
Current view: top level - libreoffice/sal/osl/unx - file_path_helper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 15 66.7 %
Date: 2012-12-27 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          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             : 
      24             : #include "file_path_helper.h"
      25             : 
      26             : #include <rtl/ustring.hxx>
      27             : 
      28             : 
      29             : namespace osl
      30             : {
      31             : 
      32             :  /*******************************************
      33             :     systemPathRemoveSeparator
      34             :     Removes the last separator from the
      35             :     given system path if any and if the path
      36             :     is not the root path '/'
      37             : 
      38             :     @param  ppustrPath [inout] a system path
      39             :             if the path is not the root path
      40             :             and the last character is a
      41             :             path separator it will be cut off
      42             :                ppustrPath must not be NULL and
      43             :             must point to a valid rtl_uString
      44             : 
      45             :     @returns nothing
      46             : 
      47             :   ******************************************/
      48             : 
      49          46 :  inline void systemPathRemoveSeparator(/*inout*/ rtl::OUString& Path)
      50             :  {
      51          46 :      osl_systemPathRemoveSeparator(Path.pData);
      52          46 :  }
      53             : 
      54             :  /*******************************************
      55             :     systemPathEnsureSeparator
      56             :     Adds a trailing path separator to the
      57             :     given system path if not already there
      58             :     and if the path is not the root path '/'
      59             : 
      60             :       @param    pustrPath [inout] a system path
      61             :             if the path is not the root path
      62             :             '/' and has no trailing separator
      63             :             a separator will be added
      64             :             ppustrPath must not be NULL and
      65             :             must point to a valid rtl_uString
      66             : 
      67             :     @returns nothing
      68             : 
      69             :   ******************************************/
      70             : 
      71           0 :  inline void systemPathEnsureSeparator(/*inout*/ rtl::OUString& Path)
      72             :  {
      73           0 :      osl_systemPathEnsureSeparator(&Path.pData);
      74           0 :  }
      75             : 
      76             :  /*******************************************
      77             :     systemPathIsRelativePath
      78             :     Returns true if the given path is a
      79             :     relative path and so starts not with '/'
      80             : 
      81             :     @param  pustrPath [in] a system path
      82             :             pustrPath must not be NULL
      83             : 
      84             :     @returns sal_True if the given path
      85             :              doesn't start with a separator
      86             :              else sal_False will be returned
      87             : 
      88             :   ******************************************/
      89             : 
      90       33130 :  inline bool systemPathIsRelativePath(const rtl::OUString& Path)
      91             :  {
      92       33130 :     return osl_systemPathIsRelativePath(Path.pData);
      93             :  }
      94             : 
      95             :  /******************************************
      96             :     systemPathMakeAbsolutePath
      97             :     Append a relative path to a base path
      98             : 
      99             :     @param  pustrBasePath [in] a system
     100             :             path that will be considered as
     101             :             base path
     102             :             pustrBasePath must not be NULL
     103             : 
     104             :     @param  pustrRelPath [in] a system path
     105             :             that will be considered as
     106             :             relative path
     107             :             pustrBasePath must not be NULL
     108             : 
     109             :     @param  ppustrAbsolutePath [out] the
     110             :             resulting path which is a
     111             :             concatination of the base and
     112             :             the relative path
     113             :             if base path is empty the
     114             :             resulting absolute path is the
     115             :             relative path
     116             :             if relative path is empty the
     117             :             resulting absolute path is the
     118             :             base path
     119             :             if base and relative path are
     120             :             empty the resulting absolute
     121             :             path is also empty
     122             :             ppustrAbsolutePath must not be
     123             :             NULL and *ppustrAbsolutePath
     124             :             must be 0 or point to a valid
     125             :             rtl_uString
     126             : 
     127             :   *****************************************/
     128             : 
     129        9062 :  inline void systemPathMakeAbsolutePath(
     130             :      const rtl::OUString& BasePath,
     131             :     const rtl::OUString& RelPath,
     132             :     rtl::OUString&       AbsolutePath)
     133             :  {
     134             :     osl_systemPathMakeAbsolutePath(
     135        9062 :         BasePath.pData, RelPath.pData, &AbsolutePath.pData);
     136        9062 :  }
     137             : 
     138             :  /*****************************************
     139             :      systemPathGetFileOrLastDirectoryPart
     140             :     Returns the file or the directory part
     141             :     of the given path
     142             : 
     143             :     @param pustrPath [in] a system path,
     144             :            must not be NULL
     145             : 
     146             :     @param ppustrFileOrDirPart [out] on
     147             :            return receives the last part
     148             :            of the given directory or the
     149             :            file name
     150             :            if pustrPath is the root path
     151             :            '/' an empty string will be
     152             :            returned
     153             :            if pustrPath has a trailing
     154             :            '/' the last part before the
     155             :            '/' will be returned else
     156             :            the part after the last '/'
     157             :            will be returned
     158             : 
     159             :     @returns nothing
     160             : 
     161             :   ****************************************/
     162             : 
     163             :  inline void systemPathGetFileNameOrLastDirectoryPart(
     164             :      const rtl::OUString& Path,
     165             :     rtl::OUString&       FileNameOrLastDirPart)
     166             :  {
     167             :     osl_systemPathGetFileNameOrLastDirectoryPart(
     168             :         Path.pData, &FileNameOrLastDirPart.pData);
     169             :  }
     170             : 
     171             : 
     172             :  /********************************************
     173             :      systemPathIsHiddenFileOrDirectoryEntry
     174             :     Returns sal_True if the last part of
     175             :     given system path is not '.' or '..'
     176             :     alone and starts with a '.'
     177             : 
     178             :     @param pustrPath [in] a system path,
     179             :            must not be NULL
     180             : 
     181             :     @returns sal_True if the last part of
     182             :              the given system path starts
     183             :              with '.' or sal_False the last
     184             :              part is '.' or '..' alone or
     185             :              doesn't start with a dot
     186             : 
     187             :  *********************************************/
     188             : 
     189        4080 :  inline bool systemPathIsHiddenFileOrDirectoryEntry(
     190             :      const rtl::OUString& Path)
     191             :  {
     192        4080 :     return osl_systemPathIsHiddenFileOrDirectoryEntry(Path.pData);
     193             :  }
     194             : 
     195             : 
     196             :  /************************************************
     197             :      systemPathIsLocalOrParentDirectoryEntry
     198             :     Returns sal_True if the last part of the given
     199             :     system path is the local directory entry '.'
     200             :     or the parent directory entry '..'
     201             : 
     202             :     @param pustrPath [in] a system path,
     203             :            must not be NULL
     204             : 
     205             :     @returns sal_True if the last part of the
     206             :              given system path is '.' or '..'
     207             :              else sal_False
     208             : 
     209             :  ************************************************/
     210             : 
     211             :  inline bool systemPathIsLocalOrParentDirectoryEntry(
     212             :      const rtl::OUString& Path)
     213             :  {
     214             :     return osl_systemPathIsLocalOrParentDirectoryEntry(Path.pData);
     215             :  }
     216             : 
     217             :  /************************************************
     218             :   searchPath
     219             :   ***********************************************/
     220             : 
     221           0 :  inline bool searchPath(
     222             :      const rtl::OUString& ustrFilePath,
     223             :     const rtl::OUString& ustrSearchPathList,
     224             :     rtl::OUString& ustrPathFound)
     225             :  {
     226             :      return osl_searchPath(
     227             :         ustrFilePath.pData,
     228             :         ustrSearchPathList.pData,
     229           0 :         &ustrPathFound.pData);
     230             :  }
     231             : 
     232             : 
     233             :  } // namespace osl
     234             : 
     235             : 
     236             :  #endif /* #ifndef _OSL_PATH_HELPER_HXX_ */
     237             : 
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10