LCOV - code coverage report
Current view: top level - libreoffice/cosv/source/storage - ploc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 40 100.0 %
Date: 2012-12-27 Functions: 10 10 100.0 %
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             : #define CSV_USE_CSV_ASSERTIONS
      21             : #include <cosv/csv_env.hxx>
      22             : 
      23             : #include <cosv/comfunc.hxx>
      24             : #include <cosv/string.hxx>
      25             : #include <cosv/streamstr.hxx>
      26             : #include <cosv/std_outp.hxx>
      27             : #include <cosv/tpl/dyn.hxx>
      28             : #include <cosv/ploc.hxx>
      29             : 
      30             : // NOT FULLY DECLARED SERVICES
      31             : #include <cosv/bstream.hxx>
      32             : 
      33             : 
      34             : 
      35             : 
      36             : namespace csv
      37             : {
      38             : namespace ploc
      39             : {
      40             : 
      41             : 
      42       19925 : Path::Path( const char *        i_sPath,
      43             :             bool                i_bPathIsAlwaysDir,
      44             :             const char *        i_sDelimiter        )
      45       19925 :     :   pRoot(0)
      46             :         // aPath,
      47             :         // sFile
      48             : {
      49       19925 :     Set(i_sPath, i_bPathIsAlwaysDir, i_sDelimiter );
      50       19925 : }
      51             : 
      52         122 : Path::Path( const Path & i_rPath )
      53         122 :     :   pRoot(i_rPath.pRoot->CreateCopy()),
      54             :         aPath(i_rPath.aPath),
      55         122 :         sFile(i_rPath.sFile)
      56             : {
      57         122 : }
      58             : 
      59       20047 : Path::~Path()
      60             : {
      61       20047 : }
      62             : 
      63             : Path &
      64           3 : Path::operator=( const Path & i_rPath )
      65             : {
      66           3 :     pRoot = i_rPath.pRoot->CreateCopy();
      67           3 :     aPath = i_rPath.aPath;
      68           3 :     sFile = i_rPath.sFile;
      69           3 :     return *this;
      70             : }
      71             : 
      72             : 
      73             : void
      74       19925 : Path::Set( const char *        i_sPath,
      75             :            bool                i_bPathIsAlwaysDir,
      76             :            const char *        i_sDelimiter        )
      77             : {
      78       19925 :     if ( *i_sDelimiter != '\\' AND *i_sDelimiter != '/' )
      79             :         return;
      80             : 
      81             :     const char *
      82       19925 :         restPath = 0;
      83       19925 :     pRoot = Root::Create_( restPath, i_sPath, i_sDelimiter );
      84       19925 :     if (restPath == 0)
      85             :         return;
      86             : 
      87       19925 :     aPath.Set(restPath, i_bPathIsAlwaysDir, i_sDelimiter);
      88             : 
      89       19925 :     if (NOT i_bPathIsAlwaysDir)
      90             :     {
      91             :         const char *
      92       19805 :             file = strrchr( restPath, *i_sDelimiter );
      93       19805 :         if (file == 0)
      94           4 :             file = restPath;
      95             :         else
      96       19801 :             file++;
      97       19805 :         sFile = file;
      98             :     }
      99             : }
     100             : 
     101             : void
     102        8068 : Path::SetFile( const String & i_sName )
     103             : {
     104        8068 :     sFile = i_sName;
     105        8068 : }
     106             : 
     107             : bool
     108       28113 : Path::IsValid() const
     109             : {
     110       28113 :     return RootDir().OwnDelimiter() != 0;
     111             : }
     112             : 
     113             : void
     114       28113 : Path::Get( bostream & o_rPath ) const
     115             : {
     116       28113 :     if (NOT IsValid())
     117       28113 :         return;
     118             : 
     119       28113 :     pRoot->Get( o_rPath );
     120       28113 :     aPath.Get( o_rPath, pRoot->OwnDelimiter() );
     121             : 
     122       28113 :     if ( sFile.length() > 0 )
     123       27634 :         o_rPath.write( sFile );
     124             : }
     125             : 
     126             : } // namespace ploc
     127           3 : } // namespace csv
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10