summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorCyrille Moureaux <cyrillem@openoffice.org>2002-06-17 13:31:44 +0000
committerCyrille Moureaux <cyrillem@openoffice.org>2002-06-17 13:31:44 +0000
commitd8de0a1bc640783b62ead8617e041264318bfaec (patch)
tree7f8586d32a2e10d62896ad0e3432c12aeefb0a70 /configmgr
parentfdfea67eaeaab20aaab8dd056352d07131249da5 (diff)
Added creation of directories
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/localbe/localoutputstream.cxx25
-rw-r--r--configmgr/source/localbe/localoutputstream.hxx8
2 files changed, 24 insertions, 9 deletions
diff --git a/configmgr/source/localbe/localoutputstream.cxx b/configmgr/source/localbe/localoutputstream.cxx
index 9975d71a9582..618750dc774a 100644
--- a/configmgr/source/localbe/localoutputstream.cxx
+++ b/configmgr/source/localbe/localoutputstream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: localoutputstream.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: cyrillem $ $Date: 2002-05-27 17:08:47 $
+ * last change: $Author: cyrillem $ $Date: 2002-06-17 14:31:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,7 +63,11 @@
#include "localoutputstream.hxx"
#endif // CONFIGMGR_LOCALBE_LOCALOUTPUTSTREAM_HXX_
-namespace configmgr {
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif // _RTL_USTRBUF_HXX_
+
+namespace configmgr { namespace localbe {
//==============================================================================
@@ -72,9 +76,20 @@ namespace configmgr {
LocalOutputStream::LocalOutputStream(const rtl::OUString& aFileUrl)
throw (io::IOException)
: mFileUrl(aFileUrl), mTemporaryFileUrl(mFileUrl), bIsClosed(sal_False) {
+ // First, ensure the directory where the file is supposed to be
+ // put exists.
mTemporaryFileUrl += rtl::OUString::createFromAscii(".tmp") ;
- mWriteFile = new osl::File(mTemporaryFileUrl) ;
+ rtl::OUString parentDirectory = FileHelper::getParentDir(aFileUrl) ;
+
+ if (!FileHelper::mkdirs(parentDirectory)) {
+ rtl::OUStringBuffer message ;
+
+ message.appendAscii("Impossible to create directory '") ;
+ message.append(parentDirectory).appendAscii("'") ;
+ throw io::IOException(message.makeStringAndClear(), *this) ;
+ }
FileHelper::removeFile(mTemporaryFileUrl) ;
+ mWriteFile = new osl::File(mTemporaryFileUrl) ;
osl::FileBase::RC errorCode = mWriteFile->open(OpenFlag_Write |
OpenFlag_Create) ;
@@ -102,4 +117,4 @@ void SAL_CALL LocalOutputStream::closeOutput(void)
}
//------------------------------------------------------------------------------
-} // configmgr
+} } // configmgr.localbe
diff --git a/configmgr/source/localbe/localoutputstream.hxx b/configmgr/source/localbe/localoutputstream.hxx
index 9d4118c0844b..177c5924576c 100644
--- a/configmgr/source/localbe/localoutputstream.hxx
+++ b/configmgr/source/localbe/localoutputstream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: localoutputstream.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2002-06-11 15:29:56 $
+ * last change: $Author: cyrillem $ $Date: 2002-06-17 14:31:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,7 +70,7 @@
#include "filehelper.hxx"
#endif // _CONFIGMGR_FILEHELPER_HXX_
-namespace configmgr {
+namespace configmgr { namespace localbe {
namespace css = com::sun::star ;
namespace uno = css::uno ;
@@ -133,6 +133,6 @@ class LocalOutputStream : public cppu::WeakImplHelper1<io::XOutputStream> {
osl::File *mWriteFile ;
} ;
-} // configmgr
+} } // configmgr.localbe
#endif // CONFIGMGR_LOCALBE_LOCALOUTPUTSTREAM_HXX_