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