LibreOffice
LibreOffice 6.0 SDK C/C++ API Reference
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 #ifndef INCLUDED_SALHELPER_LINKHELPER_HXX
11 #define INCLUDED_SALHELPER_LINKHELPER_HXX
12 
13 #include <rtl/ustring.hxx>
14 #include <osl/file.hxx>
15 
16 namespace salhelper
17 {
19  {
20  public:
22 
23  LinkResolver(sal_uInt32 nMask)
24  : m_aStatus(nMask |
28  {
29  }
30 
39  int nDepth = 128)
40  {
41  //In an ideal world this wouldn't be inline, but I want to use this
42  //in jvmfwk hence salhelper, but salhelper is .map controlled and
43  //getting all the mangled names right is a misery, moving it over
44  //to visibility markup would drop per-symbol versioning
45  osl::FileBase::RC eReturn;
46 
47  osl::DirectoryItem item;
48  rtl::OUString sURL(rURL);
49  while ((eReturn = osl::DirectoryItem::get(sURL, item))
51  {
52  if (--nDepth == 0)
53  {
54  eReturn = osl::FileBase::E_MULTIHOP;
55  break;
56  }
57  eReturn = item.getFileStatus(m_aStatus);
58  if (eReturn != osl::File::E_None)
59  break;
60  if (m_aStatus.getFileType() != osl::FileStatus::Link)
61  {
62  eReturn = osl::FileBase::E_None;
63  break;
64  }
65  sURL = m_aStatus.getLinkTargetURL();
66  }
67 
68  return eReturn;
69  }
70  };
71 }
72 
73 #endif
74 
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: condition.hxx:29
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:366
The directory item class object provides access to file status information.
Definition: file.hxx:1398
osl::FileBase::RC fetchFileStatus(const rtl::OUString &rURL, int nDepth=128)
Resolve a file url if it&#39;s a symbolic link, to a maximum depth of nDepth and fill in m_aStatus with t...
Definition: linkhelper.hxx:38
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
LinkResolver(sal_uInt32 nMask)
Definition: linkhelper.hxx:23
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1533
on success
Definition: file.hxx:56
Definition: linkhelper.hxx:18
RC
Definition: file.hxx:55
osl::FileStatus m_aStatus
Definition: linkhelper.hxx:21
#define osl_FileStatus_Mask_Type
Definition: file.h:358
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:120
Type getFileType() const
Get the file type.
Definition: file.hxx:707
#define osl_FileStatus_Mask_FileURL
Definition: file.h:365
remote resource is not directly available
Definition: file.hxx:97
The FileStatus class.
Definition: file.hxx:636
static RC get(const ::rtl::OUString &ustrFileURL, DirectoryItem &rItem)
Retrieve a single directory item.
Definition: file.hxx:1491
Definition: file.hxx:659
::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:870