diff options
author | Juergen Schmidt <jsc@openoffice.org> | 2001-08-17 12:09:50 +0000 |
---|---|---|
committer | Juergen Schmidt <jsc@openoffice.org> | 2001-08-17 12:09:50 +0000 |
commit | 5a16a948e6022190b2159848463ed48275e0e478 (patch) | |
tree | bbac09001fdc3371d5e5ccd7f29e892a35601ce6 /rdbmaker | |
parent | 8a89d4a001fc6c958d66b843db8fafff1989e9c0 (diff) |
#91088# convert registry path to URL
Diffstat (limited to 'rdbmaker')
-rw-r--r-- | rdbmaker/source/codemaker/global.cxx | 139 | ||||
-rw-r--r-- | rdbmaker/source/codemaker/typemanager.cxx | 10 | ||||
-rw-r--r-- | rdbmaker/source/rdbmaker/makefile.mk | 9 | ||||
-rw-r--r-- | rdbmaker/source/rdbmaker/rdbmaker.cxx | 8 | ||||
-rw-r--r-- | rdbmaker/source/rdbmaker/rdbtype.cxx | 6 | ||||
-rw-r--r-- | rdbmaker/source/rdbmaker/typeblop.cxx | 10 |
6 files changed, 122 insertions, 60 deletions
diff --git a/rdbmaker/source/codemaker/global.cxx b/rdbmaker/source/codemaker/global.cxx index 5c52f10e1..fad1c0102 100644 --- a/rdbmaker/source/codemaker/global.cxx +++ b/rdbmaker/source/codemaker/global.cxx @@ -2,9 +2,9 @@ * * $RCSfile: global.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: hjs $ $Date: 2001-07-18 18:02:39 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:09:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,13 @@ #include <rtl/ustring.hxx> #endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + #include <stdlib.h> #include <stdio.h> #if defined(SAL_W32) || defined(SAL_OS2) @@ -86,7 +93,14 @@ #include <codemaker/global.hxx> #endif -using namespace rtl; +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using namespace ::rtl; +using namespace ::osl; OString makeTempName(sal_Char* prefix) { @@ -224,11 +238,7 @@ OString createFileNameFromType( const OString& destination, if (mkdir((char*)nameBuffer.getStr()) == -1) #endif { -// #if __SUNPRO_CC >= 0x500 -// if( * ::___errno() == ENOENT ) -// #else if ( errno == ENOENT ) -// #endif return OString(); } @@ -311,6 +321,34 @@ const OString inGlobalSet(const OUString & rValue) return *(aGlobalMap.insert( sValue ).first); } +static sal_Bool isFileUrl(const OString& fileName) +{ + if (fileName.indexOf("file://") == 0 ) + return sal_True; + return sal_False; +} + +OUString convertToFileUrl(const OString& fileName) +{ + if ( isFileUrl(fileName) ) + { + return OStringToOUString(fileName, osl_getThreadTextEncoding()); + } + + OUString uUrlFileName; + OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); + if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + { + OUString uWorkingDir; + OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None ); + OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName) == FileBase::E_None ); + } else + { + OSL_VERIFY( FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) == FileBase::E_None ); + } + + return uUrlFileName; +} //************************************************************************* // FileStream @@ -319,60 +357,85 @@ FileStream::FileStream() { } -FileStream::FileStream(const OString& name, sal_Int32 nMode) - : ofstream(name, nMode) - , m_name(name) +FileStream::FileStream(const OString& name, FileAccessMode mode) + : m_pFile(NULL) { + if ( name.getLength() > 0 ) + { + m_name = name; + m_pFile = fopen(m_name, checkAccessMode(mode)); + } } FileStream::~FileStream() { - flush(); - close(); + if ( isValid() ) + { + fflush(m_pFile); + fclose(m_pFile); + } } sal_Bool FileStream::isValid() { -#ifndef __STL_NO_NEW_IOSTREAMS -#if STLPORT_VERSION < 400 - if(rdbuf()->fd() < 0) -#else - if( !is_open() ) -#endif -#else - if(fd() < 0) -#endif - { - return sal_False; - } + if ( m_pFile ) + return sal_True; - return sal_True; + return sal_False; } -void FileStream::openFile(const OString& name, sal_Int32 nMode) +void FileStream::open(const OString& name, FileAccessMode mode) { if ( name.getLength() > 0 ) + { m_name = name; - - if ( m_name.getLength() > 0 ) - open(m_name, nMode); + m_pFile = fopen(m_name, checkAccessMode(mode)); + } } -void FileStream::closeFile() +void FileStream::close() { - flush(); - close(); + if ( isValid() ) + { + fflush(m_pFile); + fclose(m_pFile); + m_pFile = NULL; + m_name = OString(); + } } sal_Int32 FileStream::getSize() { - flush(); - - FILE* f = fopen(m_name, "r"); + sal_Int32 pos = 0; sal_Int32 size = 0; - if (!fseek(f, 0, SEEK_END)) - size = ftell(f); - fclose(f); + if ( isValid() ) + { + fflush(m_pFile); + pos = ftell(m_pFile); + if (!fseek(m_pFile, 0, SEEK_END)) + size = ftell(m_pFile); + fseek(m_pFile, pos, SEEK_SET); + } return size; } +const sal_Char* FileStream::checkAccessMode(FileAccessMode mode) +{ + switch( mode ) + { + case FAM_READ: + return "r"; + case FAM_WRITE: + return "w"; + case FAM_APPEND: + return "a"; + case FAM_READWRITE_EXIST: + return "r+"; + case FAM_READWRITE: + return "w+"; + case FAM_READAPPEND: + return "a+"; + } + return "w+"; +} + diff --git a/rdbmaker/source/codemaker/typemanager.cxx b/rdbmaker/source/codemaker/typemanager.cxx index 21676318e..a984bd93b 100644 --- a/rdbmaker/source/codemaker/typemanager.cxx +++ b/rdbmaker/source/codemaker/typemanager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: typemanager.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:09:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -153,7 +153,7 @@ sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFile Registry tmpReg(loader); while (iter != regFiles.end()) { - if (!tmpReg.open( OStringToOUString(*iter, RTL_TEXTENCODING_UTF8), REG_READONLY)) + if (!tmpReg.open( convertToFileUrl(*iter), REG_READONLY)) m_pImpl->m_registries.push_back(new Registry(tmpReg)); else { @@ -168,7 +168,7 @@ sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFile Registry *pTmpReg = new Registry(loader); OString tmpName(makeTempName(NULL)); - if (!pTmpReg->create( OStringToOUString(tmpName, RTL_TEXTENCODING_UTF8) ) ) + if (!pTmpReg->create( convertToFileUrl(tmpName) ) ) { RegistryKey rootKey; RegError ret = REG_NO_ERROR; @@ -178,7 +178,7 @@ sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFile while (iter != regFiles.end()) { - if ( ret = pTmpReg->mergeKey(rootKey, aRoot, OUString::createFromAscii( *iter )) ) + if ( ret = pTmpReg->mergeKey(rootKey, aRoot, convertToFileUrl( *iter )) ) { if (ret != REG_MERGE_CONFLICT) { diff --git a/rdbmaker/source/rdbmaker/makefile.mk b/rdbmaker/source/rdbmaker/makefile.mk index 301740d9f..01c46d666 100644 --- a/rdbmaker/source/rdbmaker/makefile.mk +++ b/rdbmaker/source/rdbmaker/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.11 $ +# $Revision: 1.12 $ # -# last change: $Author: rt $ $Date: 2001-06-05 09:29:21 $ +# last change: $Author: jsc $ $Date: 2001-08-17 13:09:50 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -117,11 +117,6 @@ APP1STDLIBS=\ $(CPPULIB) \ $(CPPUHELPERLIB) -.IF "$(GUI)"=="WNT" -APP1STDLIBS+= \ - $(LIBCIMT) $(LIBCMT) -.ENDIF - APP1LIBS= \ $(LB)$/codemaker.lib diff --git a/rdbmaker/source/rdbmaker/rdbmaker.cxx b/rdbmaker/source/rdbmaker/rdbmaker.cxx index 35025aa7a..dd97d09f0 100644 --- a/rdbmaker/source/rdbmaker/rdbmaker.cxx +++ b/rdbmaker/source/rdbmaker/rdbmaker.cxx @@ -2,9 +2,9 @@ * * $RCSfile: rdbmaker.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: hro $ $Date: 2001-05-21 15:45:07 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:09:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -224,7 +224,7 @@ void cleanUp( sal_Bool bError) } if ( listFile.isValid() ) { - listFile.closeFile(); + listFile.close(); unlink(listFile.getName().getStr()); } @@ -420,7 +420,7 @@ int _cdecl main( int argc, char * argv[] ) if ( options.generateTypeList() ) { OString fileName = createFileName( options.getOption("-O") ); - listFile.openFile(fileName); + listFile.open(fileName); if ( !listFile.isValid() ) { diff --git a/rdbmaker/source/rdbmaker/rdbtype.cxx b/rdbmaker/source/rdbmaker/rdbtype.cxx index e7901fb7e..fdaee8c06 100644 --- a/rdbmaker/source/rdbmaker/rdbtype.cxx +++ b/rdbmaker/source/rdbmaker/rdbtype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: rdbtype.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:09:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -171,7 +171,7 @@ sal_Bool produceType(const OString& typeName, { if ( pOptions->generateTypeList() ) { - o << typeName.getStr() << endl; + o << typeName.getStr() << "\n"; } else { /* diff --git a/rdbmaker/source/rdbmaker/typeblop.cxx b/rdbmaker/source/rdbmaker/typeblop.cxx index b39b26add..6e72bb5c7 100644 --- a/rdbmaker/source/rdbmaker/typeblop.cxx +++ b/rdbmaker/source/rdbmaker/typeblop.cxx @@ -2,9 +2,9 @@ * * $RCSfile: typeblop.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dbo $ $Date: 2001-05-14 10:27:32 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:09:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,6 +101,10 @@ #include <com/sun/star/uno/XComponentContext.hpp> #endif +#ifndef _CODEMAKER_GLOBAL_HXX_ +#include <codemaker/global.hxx> +#endif + using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::reflection; @@ -296,7 +300,7 @@ sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName ) if (!pRegName) return sal_False; - Reference< XMultiServiceFactory > xSMgr( createRegistryServiceFactory( OUString::createFromAscii(pRegName) ) ); + Reference< XMultiServiceFactory > xSMgr( createRegistryServiceFactory( convertToFileUrl(pRegName) ) ); if ( !xSMgr.is() ) return sal_False; |