LibreOffice Module unotools (master) 1
localfilehelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/sdbc/XResultSet.hpp>
21#include <com/sun/star/ucb/XContentAccess.hpp>
22#include <com/sun/star/ucb/CommandAbortedException.hpp>
26#include <sal/log.hxx>
28#include <rtl/ustring.hxx>
29#include <ucbhelper/content.hxx>
30#include <vector>
31
32using namespace ::osl;
33using namespace ::com::sun::star::uno;
34using namespace ::com::sun::star::ucb;
35
36namespace utl
37{
38
39css::uno::Sequence < OUString > LocalFileHelper::GetFolderContents( const OUString& rFolder, bool bFolder )
40{
41 std::vector< OUString > vFiles;
42 try
43 {
45 rFolder, Reference< XCommandEnvironment >(),
47 Reference< css::sdbc::XResultSet > xResultSet;
48 css::uno::Sequence< OUString > aProps { "Url" };
49
50 try
51 {
52 ::ucbhelper::ResultSetInclude eInclude = bFolder ? ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS : ::ucbhelper::INCLUDE_DOCUMENTS_ONLY;
53 xResultSet = aCnt.createCursor( aProps, eInclude );
54 }
55 catch( css::ucb::CommandAbortedException& )
56 {
57 }
58 catch( Exception& )
59 {
60 }
61
62 if ( xResultSet.is() )
63 {
64 Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
65 try
66 {
67 while ( xResultSet->next() )
68 vFiles.push_back( xContentAccess->queryContentIdentifierString() );
69 }
70 catch( css::ucb::CommandAbortedException& )
71 {
72 }
73 catch( Exception& )
74 {
75 }
76 }
77 }
78 catch( Exception& )
79 {
80 }
81
83}
84
85void removeTree(OUString const & url) {
87 SAL_WARN_IF(bError, "desktop.app", "error removing directory " << url);
88}
89
90}
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool deleteDirRecursively(const OUString &rDirURL)
css::uno::Reference< css::sdbc::XResultSet > createCursor(const css::uno::Sequence< OUString > &rPropertyNames, ResultSetInclude eMode=INCLUDE_FOLDERS_AND_DOCUMENTS)
static css::uno::Sequence< OUString > GetFolderContents(const OUString &rFolder, bool bFolder)
#define SAL_WARN_IF(condition, area, stream)
@ Exception
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
void removeTree(OUString const &url)
recursively remove directory and all contents