LibreOffice
LibreOffice 25.2 SDK C/C++ API Reference
 
Loading...
Searching...
No Matches
linkhelper.hxx
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
10/*
11 * This file is part of LibreOffice published API.
12 */
13
14#ifndef INCLUDED_SALHELPER_LINKHELPER_HXX
15#define INCLUDED_SALHELPER_LINKHELPER_HXX
16
17#include "rtl/ustring.hxx"
18#include "osl/file.hxx"
19
20namespace salhelper
21{
23 {
24 public:
26
34
43 int nDepth = 128)
44 {
45 //In an ideal world this wouldn't be inline, but I want to use this
46 //in jvmfwk hence salhelper, but salhelper is .map controlled and
47 //getting all the mangled names right is a misery, moving it over
48 //to visibility markup would drop per-symbol versioning
49 osl::FileBase::RC eReturn;
50
52 rtl::OUString sURL(rURL);
53 while ((eReturn = osl::DirectoryItem::get(sURL, item))
55 {
56 if (--nDepth == 0)
57 {
59 break;
60 }
61 eReturn = item.getFileStatus(m_aStatus);
62 if (eReturn != osl::File::E_None)
63 break;
64 if (m_aStatus.getFileType() != osl::FileStatus::Link)
65 {
66 eReturn = osl::FileBase::E_None;
67 break;
68 }
69 sURL = m_aStatus.getLinkTargetURL();
70 }
71
72 return eReturn;
73 }
74 };
75}
76
77#endif
78
79/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:611
#define osl_FileStatus_Mask_Type
Definition file.h:364
#define osl_FileStatus_Mask_FileURL
Definition file.h:371
#define osl_FileStatus_Mask_LinkTargetURL
Definition file.h:372
Definition condition.hxx:34
LinkResolver(sal_uInt32 nMask)
Definition linkhelper.hxx:27
osl::FileBase::RC fetchFileStatus(const rtl::OUString &rURL, int nDepth=128)
Resolve a file url if it's a symbolic link, to a maximum depth of nDepth and fill in m_aStatus with t...
Definition linkhelper.hxx:42
osl::FileStatus m_aStatus
Definition linkhelper.hxx:25
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:172
RC
Definition file.hxx:56
@ E_MULTIHOP
remote resource is not directly available
Definition file.hxx:98
@ E_None
on success
Definition file.hxx:57
The FileStatus class.
Definition file.hxx:638
@ Link
Definition file.hxx:660
The directory item class object provides access to file status information.
Definition file.hxx:1432
static RC get(const ::rtl::OUString &ustrFileURL, DirectoryItem &rItem)
Retrieve a single directory item.
Definition file.hxx:1524
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition file.hxx:1566