summaryrefslogtreecommitdiff
path: root/cppuhelper/source/paths.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-01-15 16:28:30 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-01-16 11:39:02 +0100
commit3250fad6374ef276e198faabbb1d655adeeb28f0 (patch)
tree345130b5605d3f90b968cbd3366ad2f3f1957ddb /cppuhelper/source/paths.cxx
parentbd20b86ee762d4a14766a755d44efdeb50cef7e7 (diff)
Extract servicemanager and typedescriptionprovider from defaultbootstrap
Change-Id: I94fe7e68c5a49e591a625e9bf62108acac69428d
Diffstat (limited to 'cppuhelper/source/paths.cxx')
-rw-r--r--cppuhelper/source/paths.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx
index f6f9ed804296..c5ce22bdbe3b 100644
--- a/cppuhelper/source/paths.cxx
+++ b/cppuhelper/source/paths.cxx
@@ -19,9 +19,12 @@
#include "sal/config.h"
+#include <cassert>
+
#include "com/sun/star/uno/DeploymentException.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/XInterface.hpp"
+#include "osl/file.hxx"
#include "osl/module.hxx"
#include "osl/mutex.hxx"
#include "rtl/ustring.hxx"
@@ -66,4 +69,52 @@ rtl::OUString cppu::getUnoIniUri() {
return uri + "/" SAL_CONFIGFILE("uno");
}
+bool cppu::nextDirectoryItem(osl::Directory & directory, rtl::OUString * url) {
+ assert(url != 0);
+ for (;;) {
+ osl::DirectoryItem i;
+ switch (directory.getNextItem(i, SAL_MAX_UINT32)) {
+ case osl::FileBase::E_None:
+ break;
+ case osl::FileBase::E_NOENT:
+ return false;
+ default:
+ throw css::uno::DeploymentException(
+ "Cannot iterate directory",
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ osl::FileStatus stat(
+ osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
+ osl_FileStatus_Mask_FileURL);
+ if (i.getFileStatus(stat) != osl::FileBase::E_None) {
+ throw css::uno::DeploymentException(
+ "Cannot stat in directory",
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks
+ // Ignore backup files:
+ rtl::OUString name(stat.getFileName());
+ if (!(name.match(".") || name.endsWith("~"))) {
+ *url = stat.getFileURL();
+ return true;
+ }
+ }
+ }
+}
+
+void cppu::decodeRdbUri(rtl::OUString * uri, bool * optional, bool * directory)
+{
+ assert(uri != 0 && optional != 0 && directory != 0);
+ *optional = (*uri)[0] == '?';
+ if (*optional) {
+ *uri = uri->copy(1);
+ }
+ *directory = uri->getLength() >= 3 && (*uri)[0] == '<'
+ && (*uri)[uri->getLength() - 2] == '>'
+ && (*uri)[uri->getLength() - 1] == '*';
+ if (*directory) {
+ *uri = uri->copy(1, uri->getLength() - 3);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */