xref: /AOO41X/main/svl/source/misc/fstathelper.cxx (revision 40df464ee80f942fd2baf5effc726656f4be12a0)
1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*40df464eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*40df464eSAndrew Rist  * distributed with this work for additional information
6*40df464eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*40df464eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist  * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*40df464eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*40df464eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist  * software distributed under the License is distributed on an
15*40df464eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*40df464eSAndrew Rist  * specific language governing permissions and limitations
18*40df464eSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*40df464eSAndrew Rist  *************************************************************/
21*40df464eSAndrew Rist 
22*40df464eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir #include <tools/date.hxx>
27cdf0e10cSrcweir #include <tools/time.hxx>
28cdf0e10cSrcweir #include <tools/string.hxx>
29cdf0e10cSrcweir #include <ucbhelper/content.hxx>
30cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
31cdf0e10cSrcweir #include <svl/fstathelper.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir using namespace ::com::sun::star::uno;
35cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
36cdf0e10cSrcweir using namespace ::rtl;
37cdf0e10cSrcweir 
GetModifiedDateTimeOfFile(const UniString & rURL,Date * pDate,Time * pTime)38cdf0e10cSrcweir sal_Bool FStatHelper::GetModifiedDateTimeOfFile( const UniString& rURL,
39cdf0e10cSrcweir 										Date* pDate, Time* pTime )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
42cdf0e10cSrcweir 	try
43cdf0e10cSrcweir 	{
44cdf0e10cSrcweir 		::ucbhelper::Content aTestContent( rURL,
45cdf0e10cSrcweir 								uno::Reference< XCommandEnvironment > ());
46cdf0e10cSrcweir 		uno::Any aAny = aTestContent.getPropertyValue(
47cdf0e10cSrcweir 			OUString::createFromAscii(  "DateModified" ) );
48cdf0e10cSrcweir 		if( aAny.hasValue() )
49cdf0e10cSrcweir 		{
50cdf0e10cSrcweir 			bRet = sal_True;
51cdf0e10cSrcweir 			const util::DateTime* pDT = (util::DateTime*)aAny.getValue();
52cdf0e10cSrcweir 			if( pDate )
53cdf0e10cSrcweir 				*pDate = Date( pDT->Day, pDT->Month, pDT->Year );
54cdf0e10cSrcweir 			if( pTime )
55cdf0e10cSrcweir 				*pTime = Time( pDT->Hours, pDT->Minutes,
56cdf0e10cSrcweir 							   pDT->Seconds, pDT->HundredthSeconds );
57cdf0e10cSrcweir 		}
58cdf0e10cSrcweir 	}
59cdf0e10cSrcweir 	catch(...)
60cdf0e10cSrcweir 	{
61cdf0e10cSrcweir 	}
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	return bRet;
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
IsDocument(const UniString & rURL)66cdf0e10cSrcweir sal_Bool FStatHelper::IsDocument( const UniString& rURL )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	sal_Bool bExist = sal_False;
69cdf0e10cSrcweir 	try
70cdf0e10cSrcweir 	{
71cdf0e10cSrcweir 		::ucbhelper::Content aTestContent( rURL,
72cdf0e10cSrcweir 								uno::Reference< XCommandEnvironment > ());
73cdf0e10cSrcweir 		bExist = aTestContent.isDocument();
74cdf0e10cSrcweir 	}
75cdf0e10cSrcweir 	catch(...)
76cdf0e10cSrcweir 	{
77cdf0e10cSrcweir 	}
78cdf0e10cSrcweir 	return bExist;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
IsFolder(const UniString & rURL)81cdf0e10cSrcweir sal_Bool FStatHelper::IsFolder( const UniString& rURL )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	sal_Bool bExist = sal_False;
84cdf0e10cSrcweir 	try
85cdf0e10cSrcweir 	{
86cdf0e10cSrcweir 		::ucbhelper::Content aTestContent( rURL,
87cdf0e10cSrcweir 								uno::Reference< XCommandEnvironment > ());
88cdf0e10cSrcweir 		bExist = aTestContent.isFolder();
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 	catch(...)
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir 	}
93cdf0e10cSrcweir 	return bExist;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96