update credits
[LibreOffice.git] / svl / source / misc / fstathelper.cxx
blob498d57bb91c74f279ddbe1fe2914c0deebbc7bca
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 #include <tools/date.hxx>
21 #include <tools/time.hxx>
22 #include <tools/string.hxx>
23 #include <ucbhelper/content.hxx>
24 #include <com/sun/star/util/DateTime.hpp>
25 #include <comphelper/processfactory.hxx>
26 #include <svl/fstathelper.hxx>
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::ucb;
31 using namespace ::rtl;
33 sal_Bool FStatHelper::GetModifiedDateTimeOfFile( const OUString& rURL,
34 Date* pDate, Time* pTime )
36 sal_Bool bRet = sal_False;
37 try
39 ::ucbhelper::Content aTestContent( rURL,
40 uno::Reference< XCommandEnvironment > (),
41 comphelper::getProcessComponentContext());
42 uno::Any aAny = aTestContent.getPropertyValue(
43 OUString("DateModified") );
44 if( aAny.hasValue() )
46 bRet = sal_True;
47 const util::DateTime* pDT = (util::DateTime*)aAny.getValue();
48 if( pDate )
49 *pDate = Date( pDT->Day, pDT->Month, pDT->Year );
50 if( pTime )
51 *pTime = Time( pDT->Hours, pDT->Minutes,
52 pDT->Seconds, pDT->NanoSeconds );
55 catch(...)
59 return bRet;
62 sal_Bool FStatHelper::IsDocument( const OUString& rURL )
64 sal_Bool bExist = sal_False;
65 try
67 ::ucbhelper::Content aTestContent( rURL,
68 uno::Reference< XCommandEnvironment > (),
69 comphelper::getProcessComponentContext());
70 bExist = aTestContent.isDocument();
72 catch(...)
75 return bExist;
78 sal_Bool FStatHelper::IsFolder( const OUString& rURL )
80 sal_Bool bExist = sal_False;
81 try
83 ::ucbhelper::Content aTestContent( rURL,
84 uno::Reference< XCommandEnvironment > (),
85 comphelper::getProcessComponentContext());
86 bExist = aTestContent.isFolder();
88 catch(...)
91 return bExist;
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */