UDK 3.2.7 C/C++ API Reference
salhelper/linkhelper.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * Copyright (C) 2011 Red Hat, Inc., Caolán McNamara <caolanm@redhat.com>
00017  *  (initial developer)
00018  *
00019  * All Rights Reserved.
00020  *
00021  * For minor contributions see the git repository.
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
00025  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
00026  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
00027  * instead of those above.
00028  */
00029 
00030 #ifndef _SALHELPER_LINKHELPER_HXX
00031 #define _SALHELPER_LINKHELPER_HXX
00032 
00033 #include <rtl/ustring.hxx>
00034 #include <osl/file.hxx>
00035 
00036 namespace salhelper
00037 {
00038     class LinkResolver
00039     {
00040     public:
00041         osl::FileStatus m_aStatus;
00042 
00043         LinkResolver(sal_uInt32 nMask)
00044             : m_aStatus(nMask |
00045                         osl_FileStatus_Mask_FileURL |
00046                         osl_FileStatus_Mask_Type |
00047                         osl_FileStatus_Mask_LinkTargetURL)
00048         {
00049         }
00050 
00058         osl::FileBase::RC fetchFileStatus(const rtl::OUString &rURL,
00059             int nDepth = 128)
00060         {
00061             //In an ideal world this wouldn't be inline, but I want to use this
00062             //in jvmfwk hence salhelper, but salhelper is .map controlled and
00063             //getting all the mangled names right is a misery, moving it over
00064             //to visibility markup would drop per-symbol versioning
00065             osl::FileBase::RC eReturn;
00066 
00067             osl::DirectoryItem item;
00068             rtl::OUString sURL(rURL);
00069             while ((eReturn = osl::DirectoryItem::get(sURL, item))
00070                   == osl::File::E_None)
00071             {
00072                 if (--nDepth == 0)
00073                 {
00074                     eReturn = osl::FileBase::E_MULTIHOP;
00075                     break;
00076                 }
00077                 eReturn = item.getFileStatus(m_aStatus);
00078                 if (eReturn != osl::File::E_None)
00079                     break;
00080                 if (m_aStatus.getFileType() != osl::FileStatus::Link)
00081                 {
00082                     eReturn = osl::FileBase::E_None;
00083                     break;
00084                 }
00085                 sURL = m_aStatus.getLinkTargetURL();
00086             }
00087 
00088             return eReturn;
00089         }
00090     };
00091 }
00092 
00093 #endif
00094 
00095 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines