update credits
[LibreOffice.git] / cosv / source / storage / ploc.cxx
blob7dd6d0e997dd35114d2c04e6f577ae268f6aff02
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #define CSV_USE_CSV_ASSERTIONS
21 #include <cosv/csv_env.hxx>
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>
30 // NOT FULLY DECLARED SERVICES
31 #include <cosv/bstream.hxx>
36 namespace csv
38 namespace ploc
42 Path::Path( const char * i_sPath,
43 bool i_bPathIsAlwaysDir,
44 const char * i_sDelimiter )
45 : pRoot(0)
46 // aPath,
47 // sFile
49 Set(i_sPath, i_bPathIsAlwaysDir, i_sDelimiter );
52 Path::Path( const Path & i_rPath )
53 : pRoot(i_rPath.pRoot->CreateCopy()),
54 aPath(i_rPath.aPath),
55 sFile(i_rPath.sFile)
59 Path::~Path()
63 Path &
64 Path::operator=( const Path & i_rPath )
66 pRoot = i_rPath.pRoot->CreateCopy();
67 aPath = i_rPath.aPath;
68 sFile = i_rPath.sFile;
69 return *this;
73 void
74 Path::Set( const char * i_sPath,
75 bool i_bPathIsAlwaysDir,
76 const char * i_sDelimiter )
78 if ( *i_sDelimiter != '\\' AND *i_sDelimiter != '/' )
79 return;
81 const char *
82 restPath = 0;
83 pRoot = Root::Create_( restPath, i_sPath, i_sDelimiter );
84 if (restPath == 0)
85 return;
87 aPath.Set(restPath, i_bPathIsAlwaysDir, i_sDelimiter);
89 if (NOT i_bPathIsAlwaysDir)
91 const char *
92 file = strrchr( restPath, *i_sDelimiter );
93 if (file == 0)
94 file = restPath;
95 else
96 file++;
97 sFile = file;
101 void
102 Path::SetFile( const String & i_sName )
104 sFile = i_sName;
107 bool
108 Path::IsValid() const
110 return RootDir().OwnDelimiter() != 0;
113 void
114 Path::Get( bostream & o_rPath ) const
116 if (NOT IsValid())
117 return;
119 pRoot->Get( o_rPath );
120 aPath.Get( o_rPath, pRoot->OwnDelimiter() );
122 if ( sFile.length() > 0 )
123 o_rPath.write( sFile );
126 } // namespace ploc
127 } // namespace csv
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */