diff options
-rw-r--r-- | cpputools/source/registercomponent/registercomponent.cxx | 63 | ||||
-rw-r--r-- | cpputools/source/unoexe/unoexe.cxx | 51 | ||||
-rw-r--r-- | idlc/source/idlccompile.cxx | 117 | ||||
-rw-r--r-- | idlc/source/idlcmain.cxx | 36 | ||||
-rw-r--r-- | idlc/source/idlcproduce.cxx | 75 | ||||
-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 | ||||
-rw-r--r-- | registry/tools/checksingleton.cxx | 57 | ||||
-rw-r--r-- | registry/tools/regcompare.cxx | 57 | ||||
-rw-r--r-- | registry/tools/regmerge.cxx | 59 | ||||
-rw-r--r-- | registry/tools/regview.cxx | 60 |
15 files changed, 601 insertions, 156 deletions
diff --git a/cpputools/source/registercomponent/registercomponent.cxx b/cpputools/source/registercomponent/registercomponent.cxx index dd71290dd122..11f64a801f66 100644 --- a/cpputools/source/registercomponent/registercomponent.cxx +++ b/cpputools/source/registercomponent/registercomponent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: registercomponent.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jsc $ $Date: 2001-02-19 16:24:38 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:00:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,16 +64,63 @@ #include <vector> -#ifndef _OSL_THREAD_H_ -#include <osl/thread.h> -#endif - #include <cppuhelper/servicefactory.hxx> #include <com/sun/star/registry/XImplementationRegistration.hpp> #include <com/sun/star/registry/XSimpleRegistry.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <algorithm> + +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using namespace ::rtl; +using namespace ::osl; + +sal_Bool isFileUrl(const OUString& fileName) +{ + if (fileName.indexOf(OUString::createFromAscii("file://")) == 0 ) + return sal_True; + return sal_False; +} + +OUString convertToFileUrl(const OUString& fileName) +{ + if ( isFileUrl(fileName) ) + { + return fileName; + } + + OUString uUrlFileName; + 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, fileName, uUrlFileName) == FileBase::E_None ); + } else + { + OSL_VERIFY( FileBase::getFileURLFromSystemPath(fileName, uUrlFileName) == FileBase::E_None ); + } + + return uUrlFileName; +} + static void usingRegisterImpl() { fprintf(stderr, "\nusing: regcomp -register|revoke -r registryfile -c locationUrl [-br registryfile] [-l componentLoaderUrl]\n"); @@ -424,7 +471,7 @@ void _cdecl main( int argc, char * argv[] ) { if ( aOptions.sBootRegName.getLength() ) { - xSMgr = createRegistryServiceFactory( aOptions.sBootRegName ); + xSMgr = createRegistryServiceFactory( convertToFileUrl(aOptions.sBootRegName) ); } else { xSMgr = createServiceFactory(); @@ -468,7 +515,7 @@ void _cdecl main( int argc, char * argv[] ) { try { - xReg->open( aOptions.sRegName, sal_False, sal_True); + xReg->open( convertToFileUrl(aOptions.sRegName), sal_False, sal_True); if (!xReg->isValid()) { fprintf(stderr, "ERROR: open|create registry \"%s\" failed!\n", sRegName.getStr()); diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index 5b86e8569f75..7cfe761e55e6 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unoexe.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: dbo $ $Date: 2001-06-29 08:59:01 $ + * last change: $Author: jsc $ $Date: 2001-08-17 12:59:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,6 +96,22 @@ #include <com/sun/star/bridge/XBridgeFactory.hpp> #include <com/sun/star/bridge/XBridge.hpp> +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + using namespace std; using namespace rtl; using namespace osl; @@ -108,10 +124,37 @@ using namespace com::sun::star::connection; using namespace com::sun::star::bridge; using namespace com::sun::star::container; - namespace unoexe { +static sal_Bool isFileUrl(const OUString& fileName) +{ + if (fileName.indexOf(OUString::createFromAscii("file://")) == 0 ) + return sal_True; + return sal_False; +} + +static OUString convertToFileUrl(const OUString& fileName) +{ + if ( isFileUrl(fileName) ) + { + return fileName; + } + + OUString uUrlFileName; + 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, fileName, uUrlFileName) == FileBase::E_None ); + } else + { + OSL_VERIFY( FileBase::getFileURLFromSystemPath(fileName, uUrlFileName) == FileBase::E_None ); + } + + return uUrlFileName; +} + //-------------------------------------------------------------------------------------------------- static inline void out( const sal_Char * pText ) { @@ -329,7 +372,7 @@ static Reference< XSimpleRegistry > openRegistry( try { - xNewReg->open( rURL, bReadOnly, bCreate ); + xNewReg->open( convertToFileUrl(rURL), bReadOnly, bCreate ); if (xNewReg->isValid()) return xNewReg; else diff --git a/idlc/source/idlccompile.cxx b/idlc/source/idlccompile.cxx index 8eb59491093f..ea5bb3e90e3d 100644 --- a/idlc/source/idlccompile.cxx +++ b/idlc/source/idlccompile.cxx @@ -2,9 +2,9 @@ * * $RCSfile: idlccompile.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jsc $ $Date: 2001-06-11 11:45:54 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:03:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,12 @@ #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> #endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif #if defined(SAL_W32) || defined(SAL_OS2) #include <io.h> @@ -84,11 +90,12 @@ #if defined(MACOSX) || defined(FREEBSD) || defined(NETBSD) #include <sys/wait.h> #else -#include <wait.h> +#include <wait.h #endif #endif using namespace ::rtl; +using namespace ::osl; extern int yyparse(); extern FILE* yyin; @@ -101,6 +108,48 @@ static OUString TMP(RTL_CONSTASCII_USTRINGPARAM("TMP")); static OUString TEMP(RTL_CONSTASCII_USTRINGPARAM("TEMP")); static sal_Char tmpFilePattern[512]; +sal_Bool isFileUrl(const OString& fileName) +{ + if (fileName.indexOf("file://") == 0 ) + return sal_True; + return sal_False; +} + +OString convertToAbsoluteSystemPath(const OString& fileName) +{ + OUString uSysFileName; + OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); + if ( isFileUrl(fileName) ) + { + OSL_VERIFY(FileBase::getSystemPathFromFileURL(uFileName, uSysFileName) == FileBase::E_None); + } else + if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0) + { + OUString uWorkingDir, uUrlFileName; + OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None ); + OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName) == FileBase::E_None ); + OSL_VERIFY( FileBase::getSystemPathFromFileURL(uUrlFileName, uSysFileName) == FileBase::E_None ); + } else + { + return fileName; + } + + return OUStringToOString(uSysFileName, osl_getThreadTextEncoding()); +} + +OString convertToFileUrl(const OString& fileName) +{ + if ( !isFileUrl(fileName) ) + { + OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); + OUString uUrlFileName; + OSL_VERIFY(FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) == FileBase::E_None); + return OUStringToOString(uUrlFileName, osl_getThreadTextEncoding()); + } + + return fileName; +} + // prefix must be specified, postfix could be empty string OString makeTempName(const OString& prefix, const OString& postfix) { @@ -124,15 +173,15 @@ OString makeTempName(const OString& prefix, const OString& postfix) #if defined(SAL_W32) || defined(SAL_UNX) strcpy(tmpFilePattern, tmpPath); -#ifdef SAL_UNX - strcat(tmpFilePattern, "/"); -#else - strcat(tmpFilePattern, "\\"); -#endif + strcat(tmpFilePattern, PATH_SEPARATOR); strcat(tmpFilePattern, prefix.getStr()); strcat(tmpFilePattern, "XXXXXX"); +#ifdef SAL_UNX + (void) mkstemp(tmpFilePattern); +#else (void) mktemp(tmpFilePattern); +#endif if ( postfix.getLength() ) strcat(tmpFilePattern, postfix.getStr()); #endif @@ -144,37 +193,47 @@ OString makeTempName(const OString& prefix, const OString& postfix) return OString(tmpFilePattern); } -void copyFile(const OString& sourceFile, const OString& targetFile) +sal_Bool copyFile(const OString& sourceFile, const OString& targetFile) { - FILE* pSource = fopen(sourceFile.getStr(), "r"); + sal_Bool bRet = sal_True; + + FILE* pSource = fopen(sourceFile.getStr(), "rb"); if ( !pSource ) - { - fprintf(stderr, "%s: couldn't open file: %s\n", - idlc()->getOptions()->getProgramName().getStr(), sourceFile.getStr()); - exit(99); - } + return sal_False; - FILE* pTarget = fopen(targetFile.getStr(), "w"); + FILE* pTarget = fopen(targetFile.getStr(), "wb"); if ( !pTarget ) { - fprintf(stderr, "%s: couldn't create file: %s\n", - idlc()->getOptions()->getProgramName().getStr(), targetFile.getStr()); - exit(99); + fclose(pSource); + return sal_False; } + sal_uInt32 totalSize = 512; + sal_uInt32 readSize = 0; + sal_uInt32 writeSize = 0; sal_Char pBuffer[513]; - fgets(pBuffer, 512, pSource); while ( !feof(pSource) ) { - fprintf(pTarget, "%s", pBuffer); - fgets(pBuffer, 512, pSource); + if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0 && !ferror(pSource) ) + { + if ( (writeSize = fwrite(pBuffer, 1, readSize, pTarget)) != readSize || ferror(pTarget) ) + { + fclose(pSource); + fclose(pTarget); + return sal_False; + } + } } fclose(pSource); + if ( fflush(pTarget) ) + bRet = sal_False; fclose(pTarget); + + return bRet; } sal_Int32 SAL_CALL compileFile(const OString& fileName) @@ -183,7 +242,12 @@ sal_Int32 SAL_CALL compileFile(const OString& fileName) OString tmpFile = makeTempName(OString("idli_"), OString(".idl")); OString preprocFile = makeTempName(OString("idlf_"), OString(".idl")); - copyFile(fileName, tmpFile); + if ( !copyFile(fileName, tmpFile) ) + { + fprintf(stderr, "%s: couldn't copy file '%' to '%s'\n", + idlc()->getOptions()->getProgramName().getStr(), fileName.getStr(), tmpFile.getStr()); + exit(99); + } idlc()->setFileName(fileName); idlc()->setMainFileName(fileName); @@ -194,11 +258,8 @@ sal_Int32 SAL_CALL compileFile(const OString& fileName) Options* pOptions = idlc()->getOptions(); OString filePath; -#if defined(SAL_W32) || defined(SAL_OS2) - sal_uInt32 index = fileName.lastIndexOf('\\'); -#else - sal_uInt32 index = fileName.lastIndexOf('/'); -#endif + sal_uInt32 index = fileName.lastIndexOf(SEPARATOR); + if ( index > 0) { filePath = fileName.copy(0, index); diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx index 5ea846199338..00e32aa33f48 100644 --- a/idlc/source/idlcmain.cxx +++ b/idlc/source/idlcmain.cxx @@ -2,9 +2,9 @@ * * $RCSfile: idlcmain.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jsc $ $Date: 2001-07-27 09:47:09 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:03:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,12 +62,6 @@ #include <idlc/idlc.hxx> #endif -#ifdef SAL_UNX -sal_Char SEPARATOR = '/'; -#else -sal_Char SEPARATOR = '\\'; -#endif - using namespace ::rtl; void SAL_CALL main( int argc, char** argv ) @@ -94,26 +88,30 @@ void SAL_CALL main( int argc, char** argv ) sal_Int32 nErrors = 0; for ( sal_Int32 i=0; i < nFiles; i++ ) { + OString sysFileName( convertToAbsoluteSystemPath(files[i]) ); + fprintf(stdout, "%s: compile '%s' ... \n", options.getProgramName().getStr(), files[i].getStr()); - nErrors = compileFile(files[i]); + nErrors = compileFile(sysFileName); if ( nErrors ) { - OString outputName; if ( options.isValid("-O") ) { - outputName = options.getOption("-O"); - sal_Char c = outputName.getStr()[outputName.getLength()-1]; + OString sysOutputName = convertToAbsoluteSystemPath(options.getOption("-O")); + sal_Char c = sysOutputName.getStr()[sysOutputName.getLength()-1]; - if ( c != SEPARATOR ) - outputName += OString::valueOf(SEPARATOR); - } + if ( c != '/' ) + sysOutputName += OString::valueOf('/'); - OString strippedFileName(files[i].copy(files[i].lastIndexOf(SEPARATOR) + 1)); - outputName += strippedFileName.replaceAt(strippedFileName.getLength() -3 , 3, "urd"); - removeIfExists(outputName); + OString strippedFileName(sysFileName.copy(sysFileName.lastIndexOf(SEPARATOR) + 1)); + sysOutputName += strippedFileName.replaceAt(strippedFileName.getLength() -3 , 3, "urd"); + removeIfExists(sysOutputName); + } else + { + removeIfExists(sysFileName); + } } else - nErrors = produceFile(files[i]); + nErrors = produceFile(sysFileName); idlc()->reset(); if ( nErrors > 0 ) diff --git a/idlc/source/idlcproduce.cxx b/idlc/source/idlcproduce.cxx index ab6a7dfac54c..40af02bfb464 100644 --- a/idlc/source/idlcproduce.cxx +++ b/idlc/source/idlcproduce.cxx @@ -2,9 +2,9 @@ * * $RCSfile: idlcproduce.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: pl $ $Date: 2001-05-10 19:50:04 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:03:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,6 +67,15 @@ #ifndef _RTL_STRBUF_HXX_ #include <rtl/strbuf.hxx> #endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif #if defined(SAL_W32) || defined(SAL_OS2) #include <io.h> @@ -80,16 +89,36 @@ #include <errno.h> #endif -#ifdef SAL_UNX -extern sal_Char SEPARATOR; -#else -extern sal_Char SEPARATOR; -#endif - using namespace ::rtl; +using namespace ::osl; StringList* pCreatedDirectories = NULL; +static OUString getWorkingDir() +{ + OUString workingDir; + if ( osl_getProcessWorkingDir(&workingDir.pData) != osl_Process_E_None ) + return OUString(); + + return workingDir; +} + +static OString getTempDir() +{ + sal_Char* pTemp = NULL; + if ( !(pTemp = getenv("TEMP")) ) + { + if ( !(pTemp = getenv("TMP")) ) + return OString(); + } + + OString tempDir(pTemp); + if ( pTemp[strlen(pTemp)-1] != SEPARATOR ) + tempDir += OString::valueOf(SEPARATOR); + + return tempDir; +} + static sal_Bool checkOutputPath(const OString& completeName) { OStringBuffer buffer(completeName.getLength()); @@ -177,26 +206,20 @@ sal_Int32 SAL_CALL produceFile(const OString& fileName) OString regFileName; if ( pOptions->isValid("-O") ) { - regFileName = pOptions->getOption("-O"); + regFileName = convertToAbsoluteSystemPath(pOptions->getOption("-O")); sal_Char c = regFileName.getStr()[regFileName.getLength()-1]; if ( c != SEPARATOR ) regFileName += OString::valueOf(SEPARATOR); } - OString regTmpName(regFileName); OString strippedFileName(fileName.copy(fileName.lastIndexOf(SEPARATOR) + 1)); + OString tempName(strippedFileName.copy(0, strippedFileName.indexOf('.'))); + tempName += "_"; + OString regTmpName( makeTempName(tempName, "._idlc_")); regFileName += strippedFileName.replaceAt(strippedFileName.getLength() -3 , 3, "urd"); regTmpName += strippedFileName.replaceAt(strippedFileName.getLength() -3 , 3, "_idlc_"); - if ( !checkOutputPath(regTmpName) ) - { - fprintf(stderr, "%s: could not create path of registry file '%s'.\n", - pOptions->getProgramName().getStr(), regFileName.getStr()); - removeIfExists(regFileName); - return 1; - } - RegistryLoader regLoader; RegistryTypeWriterLoader writerLoader; @@ -212,7 +235,8 @@ sal_Int32 SAL_CALL produceFile(const OString& fileName) Registry regFile(regLoader); removeIfExists(regTmpName); - if ( regFile.create(OStringToOUString(regTmpName, RTL_TEXTENCODING_UTF8)) ) + OString urlRegTmpName = convertToFileUrl(regTmpName); + if ( regFile.create(OStringToOUString(urlRegTmpName, RTL_TEXTENCODING_UTF8)) ) { fprintf(stderr, "%s: could not create registry file '%s'\n", pOptions->getProgramName().getStr(), regTmpName.getStr()); @@ -264,15 +288,24 @@ sal_Int32 SAL_CALL produceFile(const OString& fileName) } removeIfExists(regFileName); - if ( rename(regTmpName.getStr(), regFileName.getStr()) != 0 ) + if ( !checkOutputPath(regFileName) ) { - fprintf(stderr, "%s: cannot rename temporary registry '%s' to '%s'\n", + fprintf(stderr, "%s: could not create path of registry file '%s'.\n", + pOptions->getProgramName().getStr(), regFileName.getStr()); + removeIfExists(regTmpName); + return 1; + } + + if ( !copyFile(regTmpName, regFileName) ) + { + fprintf(stderr, "%s: cannot copy temporary registry '%s' to '%s'\n", idlc()->getOptions()->getProgramName().getStr(), regTmpName.getStr(), regFileName.getStr()); removeIfExists(regTmpName); cleanPath(); return 1; } + removeIfExists(regTmpName); return 0; } diff --git a/rdbmaker/source/codemaker/global.cxx b/rdbmaker/source/codemaker/global.cxx index bec489b3102e..e539f6405c7e 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 88031401083f..ce524f7973a8 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 301740d9f671..01c46d6669a8 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 fc77a2d66a61..949624ac9eae 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 aebaa1546542..337e08642780 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 5f841eee2465..10d6e333d79d 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; diff --git a/registry/tools/checksingleton.cxx b/registry/tools/checksingleton.cxx index 15255bb5d4d6..9f2e39de5f54 100644 --- a/registry/tools/checksingleton.cxx +++ b/registry/tools/checksingleton.cxx @@ -2,9 +2,9 @@ * * $RCSfile: checksingleton.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jsc $ $Date: 2001-06-25 14:37:48 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:05:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,7 +77,56 @@ #include <rtl/alloc.h> #endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + using namespace ::rtl; +using namespace ::osl; + +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; +} #define U2S( s ) \ OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr() @@ -392,8 +441,8 @@ void _cdecl main( int argc, char * argv[] ) exit(1); } - OUString indexRegName( S2U(options.getIndexReg()) ); - OUString typeRegName( S2U(options.getTypeReg()) ); + OUString indexRegName( convertToFileUrl(options.getIndexReg()) ); + OUString typeRegName( convertToFileUrl(options.getTypeReg()) ); RegistryLoader regLoader; Registry indexReg(regLoader); diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx index aacecfd7bbc3..72f620772d23 100644 --- a/registry/tools/regcompare.cxx +++ b/registry/tools/regcompare.cxx @@ -2,9 +2,9 @@ * * $RCSfile: regcompare.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: pl $ $Date: 2001-05-10 10:47:10 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:05:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,7 +77,56 @@ #include <rtl/alloc.h> #endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + using namespace ::rtl; +using namespace ::osl; + +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; +} #define U2S( s ) \ OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr() @@ -1821,8 +1870,8 @@ void _cdecl main( int argc, char * argv[] ) exit(1); } - OUString regName1( S2U(options.getRegName1()) ); - OUString regName2( S2U(options.getRegName2()) ); + OUString regName1( convertToFileUrl(options.getRegName1()) ); + OUString regName2( convertToFileUrl(options.getRegName2()) ); RegistryLoader regLoader; Registry reg1(regLoader); diff --git a/registry/tools/regmerge.cxx b/registry/tools/regmerge.cxx index 73f530dafceb..ae533bf077d7 100644 --- a/registry/tools/regmerge.cxx +++ b/registry/tools/regmerge.cxx @@ -2,9 +2,9 @@ * * $RCSfile: regmerge.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:05:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,57 @@ #include <rtl/alloc.h> #endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using namespace ::rtl; +using namespace ::osl; + +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; +} + int realargc; char* realargv[2048]; @@ -154,7 +205,7 @@ int _cdecl main( int argc, char * argv[] ) exit(1); } - ::rtl::OUString regName( ::rtl::OUString::createFromAscii(realargv[1]) ); + ::rtl::OUString regName( convertToFileUrl(realargv[1]) ); if (reg_openRegistry(regName.pData, &hReg, REG_READWRITE)) { if (reg_createRegistry(regName.pData, &hReg)) @@ -172,7 +223,7 @@ int _cdecl main( int argc, char * argv[] ) RegError _ret = REG_NO_ERROR; for (int i = 3; i < realargc; i++) { - targetRegName = ::rtl::OUString::createFromAscii(realargv[i]); + targetRegName = convertToFileUrl(realargv[i]); if (_ret = reg_mergeKey(hRootKey, mergeKeyName.pData, targetRegName.pData, sal_False, sal_True)) { if (_ret == REG_MERGE_CONFLICT) diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx index d488630f6180..61c872b88c20 100644 --- a/registry/tools/regview.cxx +++ b/registry/tools/regview.cxx @@ -2,9 +2,9 @@ * * $RCSfile: regview.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:18:43 $ + * last change: $Author: jsc $ $Date: 2001-08-17 13:05:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,58 @@ #include <rtl/alloc.h> #endif +#ifndef _OSL_PROCESS_H_ +#include <osl/process.h> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using namespace ::rtl; +using namespace ::osl; + +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; +} + + #if (defined UNX) || (defined OS2) int main( int argc, char * argv[] ) #else @@ -86,7 +138,7 @@ int _cdecl main( int argc, char * argv[] ) exit(1); } - ::rtl::OUString regName( ::rtl::OUString::createFromAscii(argv[1]) ); + OUString regName( convertToFileUrl(argv[1]) ); if (reg_openRegistry(regName.pData, &hReg, REG_READONLY)) { fprintf(stderr, "open registry \"%s\" failed\n", argv[1]); @@ -97,7 +149,7 @@ int _cdecl main( int argc, char * argv[] ) { if (argc == 3) { - ::rtl::OUString keyName( ::rtl::OUString::createFromAscii(argv[2]) ); + OUString keyName( OUString::createFromAscii(argv[2]) ); if (!reg_openKey(hRootKey, keyName.pData, &hKey)) { if (reg_dumpRegistry(hKey)) |