159617ebcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
359617ebcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
459617ebcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
559617ebcSAndrew Rist  * distributed with this work for additional information
659617ebcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
759617ebcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
859617ebcSAndrew Rist  * "License"); you may not use this file except in compliance
959617ebcSAndrew Rist  * with the License.  You may obtain a copy of the License at
1059617ebcSAndrew Rist  *
1159617ebcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1259617ebcSAndrew Rist  *
1359617ebcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1459617ebcSAndrew Rist  * software distributed under the License is distributed on an
1559617ebcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1659617ebcSAndrew Rist  * KIND, either express or implied.  See the License for the
1759617ebcSAndrew Rist  * specific language governing permissions and limitations
1859617ebcSAndrew Rist  * under the License.
1959617ebcSAndrew Rist  *
2059617ebcSAndrew Rist  *************************************************************/
2159617ebcSAndrew Rist 
2259617ebcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <precomp.h>
25cdf0e10cSrcweir #include <cosv/persist.hxx>
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
28cdf0e10cSrcweir #include <cosv/streamstr.hxx>
29cdf0e10cSrcweir #include <cosv/ploc.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #ifdef WNT
33cdf0e10cSrcweir #include <io.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace csv
36cdf0e10cSrcweir {
37cdf0e10cSrcweir namespace ploc
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir bool
Exists() const41cdf0e10cSrcweir Persistent::Exists() const
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     return access( StrPath(), 00) == 0;
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir } // namespace ploc
47cdf0e10cSrcweir } // namespace csv
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #elif defined(UNX)
51cdf0e10cSrcweir #include <unistd.h>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir /*
54cdf0e10cSrcweir #ifndef __SUNPRO_CC
55cdf0e10cSrcweir #include <unistd.h>
56cdf0e10cSrcweir #else
57cdf0e10cSrcweir #define	F_OK	0	// Test for existence of File
58cdf0e10cSrcweir extern int access(const char *, int);
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir */
61cdf0e10cSrcweir 
62cdf0e10cSrcweir namespace csv
63cdf0e10cSrcweir {
64cdf0e10cSrcweir namespace ploc
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 
67cdf0e10cSrcweir bool
Exists() const68cdf0e10cSrcweir Persistent::Exists() const
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     return access( StrPath(), F_OK ) == 0;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir } // namespace ploc
75cdf0e10cSrcweir } // namespace csv
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #else
78cdf0e10cSrcweir #error  For using csv::ploc there has to be defined: WNT or UNX.
79cdf0e10cSrcweir #endif
80cdf0e10cSrcweir 
81cdf0e10cSrcweir namespace csv
82cdf0e10cSrcweir {
83cdf0e10cSrcweir namespace ploc
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 
86cdf0e10cSrcweir const char *
StrPath() const87cdf0e10cSrcweir Persistent::StrPath() const
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     if (sPath.empty() )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir #ifndef CSV_NO_MUTABLE
92cdf0e10cSrcweir         StreamStr & rsPath = sPath;
93cdf0e10cSrcweir #else
94cdf0e10cSrcweir         StreamStr & rsPath = const_cast< StreamStr& >(sPath);
95cdf0e10cSrcweir #endif
96cdf0e10cSrcweir         rsPath.seekp(0);
97cdf0e10cSrcweir         rsPath << MyPath();
98cdf0e10cSrcweir         if (MyPath().IsDirectory())
99cdf0e10cSrcweir             rsPath.pop_back(1);    // Remove closing delimiter.
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir     return sPath.c_str();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir } // namespace ploc
105cdf0e10cSrcweir } // namespace csv
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110