summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcpputools/source/regcomplazy/regcomplazy.cxx62
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx25
-rw-r--r--offapi/com/sun/star/configuration/ConfigurationRegistry.idl4
-rw-r--r--offapi/com/sun/star/text/RedlinePortion.idl4
-rw-r--r--offapi/com/sun/star/text/XFormField.idl36
-rw-r--r--offapi/type_reference/typelibrary_history.txt10
-rw-r--r--offapi/type_reference/types.rdbbin6717440 -> 7307264 bytes
-rw-r--r--sal/inc/osl/file.h8
-rw-r--r--sal/osl/unx/file.cxx23
-rw-r--r--sal/osl/w32/file_dirvol.cxx217
-rw-r--r--sal/osl/w32/file_url.cxx325
-rw-r--r--sal/osl/w32/file_url.h6
-rw-r--r--sal/osl/w32/module.cxx (renamed from sal/osl/w32/module.c)71
-rw-r--r--sal/osl/w32/path_helper.hxx40
-rw-r--r--sal/osl/w32/process.cxx (renamed from sal/osl/w32/process.c)88
-rw-r--r--sal/osl/w32/profile.cxx (renamed from sal/osl/w32/profile.c)298
-rw-r--r--sal/osl/w32/signal.cxx (renamed from sal/osl/w32/signal.c)67
-rw-r--r--sal/osl/w32/system.h12
-rw-r--r--sal/osl/w32/tempfile.cxx28
-rw-r--r--sal/rtl/source/ustring.c8
20 files changed, 793 insertions, 539 deletions
diff --git a/cpputools/source/regcomplazy/regcomplazy.cxx b/cpputools/source/regcomplazy/regcomplazy.cxx
index 367ac02510e5..13c09c8d1c94 100755
--- a/cpputools/source/regcomplazy/regcomplazy.cxx
+++ b/cpputools/source/regcomplazy/regcomplazy.cxx
@@ -46,16 +46,11 @@ using namespace ::rtl;
typedef ::std::vector< ::rtl::OString > OSVector;
-typedef ::std::pair< ::rtl::OString, OSVector > DataPair;
-
-typedef ::std::vector< DataPair > DataVector;
-
struct CompDescriptor {
OString sImplementationName;
OString sComponentName;
OString sLoaderName;
OSVector vSupportedServices;
- DataVector vData;
};
typedef ::std::vector< CompDescriptor > CDescrVector;
@@ -144,28 +139,6 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
OString sToken(sTmp);
if (sTmp.pData->buffer[sTmp.getLength()-1] == '\x0D')
sToken = sTmp.copy(0, sTmp.getLength()-1);
-
- if (sToken.indexOf("[Data]") >= 0) {
- do {
- OString sTmp2 = sDescr.getToken(0, '\x0A', nTokenIndex);
- OString sToken2(sTmp2);
- if (sTmp2.pData->buffer[sTmp2.getLength()-1] == '\x0D')
- sToken2 = sTmp2.copy(0, sTmp2.getLength()-1);
-
- if ((sToken2.getLength() > 0) && (sToken2.pData->buffer[0] != '[')) {
- OString dataKey(sToken2.copy(0, sToken2.indexOf('=')));
- OString sValues(sToken2.copy(sToken2.indexOf('=')+1));
- sal_Int32 nVIndex = 0;
- OSVector vValues;
- do {
- OString sValue = sValues.getToken(0, ';', nVIndex);
- vValues.push_back(sValue);
- } while (nVIndex >= 0 );
- descr.vData.push_back(DataPair(dataKey, vValues));
- } else
- break;
- } while (nTokenIndex >= 0 );
- }
if ( sToken.indexOf("[ComponentDescriptor]") >= 0) {
if (bFirst)
bFirst = false;
@@ -244,41 +217,6 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
subKey.setValue(OUString(), RG_VALUETYPE_STRING,
(sal_Char*)sCompName.getStr(), sCompName.getLength()+1);
- if ((*comp_iter).vData.size() > 0) {
- usKeyName = OUSTR("DATA");
- RegistryKey dataKey, valueKey;
- key.createKey(usKeyName, dataKey);
-
- DataVector::const_iterator data_iter = ((*comp_iter).vData).begin();
- do {
- OUString sDataKey(OSToOUS((*data_iter).first));
- dataKey.createKey(sDataKey, valueKey);
-
- OSVector::const_iterator value_iter = ((*data_iter).second).begin();
- int vlen = (*data_iter).second.size();
- sal_Char** pValueList = (sal_Char**)rtl_allocateZeroMemory(
- vlen * sizeof(sal_Char*));
- int i = 0;
- do {
- pValueList[i] = (sal_Char*)rtl_allocateZeroMemory(
- (*value_iter).getLength()+1 * sizeof(sal_Char));
- rtl_copyMemory(pValueList[i], (sal_Char*)(*value_iter).getStr(),
- (*value_iter).getLength()+1);
- i++;
- value_iter++;
- } while (value_iter != (*data_iter).second.end());
-
- valueKey.setStringListValue(OUString(), pValueList, vlen);
-
- // free memory
- for (i=0; i<vlen; i++)
- rtl_freeMemory(pValueList[i]);
- rtl_freeMemory(pValueList);
-
- data_iter++;
- } while (data_iter != (*comp_iter).vData.end());
- }
-
usKeyName = OUSTR("UNO/SERVICES");
key.createKey(usKeyName, subKey);
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index a911b75f85ab..bd49956c8baf 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -124,7 +124,7 @@ extern VendorSupportMapEntry gVendorMap[];
bool getSDKInfoFromRegistry(vector<OUString> & vecHome);
bool getJREInfoFromRegistry(vector<OUString>& vecJavaHome);
-rtl::OUString decodeOutput(const rtl::OString& s);
+bool decodeOutput(const rtl::OString& s, rtl::OUString* out);
@@ -452,7 +452,9 @@ bool getJavaProps(const OUString & exePath,
break;
JFW_TRACE2(OString("[Java framework] line:\" ")
+ aLine + OString(" \".\n"));
- OUString sLine = decodeOutput(aLine);
+ OUString sLine;
+ if (!decodeOutput(aLine, &sLine))
+ continue;
JFW_TRACE2(OString("[Java framework] line:\" ")
+ OString( CHAR_POINTER(sLine)) + OString(" \".\n"));
sLine = sLine.trim();
@@ -486,8 +488,9 @@ bool getJavaProps(const OUString & exePath,
readable strings. The strings are encoded as integer values separated
by spaces.
*/
-rtl::OUString decodeOutput(const rtl::OString& s)
+bool decodeOutput(const rtl::OString& s, rtl::OUString* out)
{
+ OSL_ASSERT(out != 0);
OUStringBuffer buff(512);
sal_Int32 nIndex = 0;
do
@@ -495,14 +498,19 @@ rtl::OUString decodeOutput(const rtl::OString& s)
OString aToken = s.getToken( 0, ' ', nIndex );
if (aToken.getLength())
{
+ for (sal_Int32 i = 0; i < aToken.getLength(); ++i)
+ {
+ if (aToken[i] < '0' || aToken[i] > '9')
+ return false;
+ }
sal_Unicode value = (sal_Unicode)(aToken.toInt32());
buff.append(value);
}
} while (nIndex >= 0);
- OUString sDecoded(buff.makeStringAndClear());
- JFW_TRACE2(sDecoded);
- return sDecoded;
+ *out = buff.makeStringAndClear();
+ JFW_TRACE2(*out);
+ return true;
}
@@ -793,8 +801,9 @@ OUString resolveDirPath(const OUString & path)
{
OUString ret;
OUString sResolved;
+ //getAbsoluteFileURL also resolves links
if (File::getAbsoluteFileURL(
- rtl::OUString(), path, sResolved) != File::E_None)
+ OUSTR("file:///"), path, sResolved) != File::E_None)
return OUString();
//check if this is a valid path and if it is a directory
@@ -824,7 +833,7 @@ OUString resolveFilePath(const OUString & path)
OUString sResolved;
if (File::getAbsoluteFileURL(
- rtl::OUString(), path, sResolved) != File::E_None)
+ OUSTR("file:///"), path, sResolved) != File::E_None)
return OUString();
//check if this is a valid path to a file or and if it is a link
diff --git a/offapi/com/sun/star/configuration/ConfigurationRegistry.idl b/offapi/com/sun/star/configuration/ConfigurationRegistry.idl
index c3b98b115a52..870af90e7986 100644
--- a/offapi/com/sun/star/configuration/ConfigurationRegistry.idl
+++ b/offapi/com/sun/star/configuration/ConfigurationRegistry.idl
@@ -43,6 +43,10 @@ module com { module sun { module star { module configuration {
/* provides access to a configuration tree as a registry.
+ <p>This service is deprecated,
+ <type scope="com.sun.star.configuration">ConfigurationProvider</type> should
+ be used instead.</p>
+
<p> Using the <type scope="com::sun::star::registry">XSimpleRegistry</type>
interface, the service can be bound to a subtree within the
configuration tree, as provided by an
diff --git a/offapi/com/sun/star/text/RedlinePortion.idl b/offapi/com/sun/star/text/RedlinePortion.idl
index be39882474c3..c399d976e04a 100644
--- a/offapi/com/sun/star/text/RedlinePortion.idl
+++ b/offapi/com/sun/star/text/RedlinePortion.idl
@@ -52,7 +52,7 @@ published service RedlinePortion
/** contains the name of the author of the change.*/
[readonly, property] string RedlineAuthor;
/** contains the date and time of the change.*/
- [readonly, property] com::sun::star::util::DateTime RedlineDataTime;
+ [readonly, property] com::sun::star::util::DateTime RedlineDateTime;
/** contains a comment for the change.*/
[readonly, property] string RedlineComment;
/** contains the type of the change
@@ -70,7 +70,7 @@ published service RedlinePortion
<p> The elements of the sequence are:</p>
<UL>
<LI><P>string RedlineAuthor; </P>
- <LI><P>com::sun::star::util::DateTime RedlineDataTime; </P>
+ <LI><P>com::sun::star::util::DateTime RedlineDateTime; </P>
<LI><P>string RedlineComment; </P>
<LI><P>string RedlineType; </P>
</UL>
diff --git a/offapi/com/sun/star/text/XFormField.idl b/offapi/com/sun/star/text/XFormField.idl
index f1f2d1bab9b9..53555728ba40 100644
--- a/offapi/com/sun/star/text/XFormField.idl
+++ b/offapi/com/sun/star/text/XFormField.idl
@@ -1,26 +1,20 @@
- #ifndef __com_sun_star_text_XFormField_idl__
- #define __com_sun_star_text_XFormField_idl__
+#ifndef __com_sun_star_text_XFormField_idl__
+#define __com_sun_star_text_XFormField_idl__
- #ifndef __com_sun_star_uno_XInterface_idl__
- #include <com/sun/star/uno/XInterface.idl>
- #endif
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/container/XNameContainer.idl>
- module com { module sun { module star { module text {
+module com { module sun { module star { module text {
-/** @deprecated
- */
- interface XFormField: com::sun::star::uno::XInterface
- {
- short getType();
- short getRes();
- string getDescription( );
+ /** @deprecated
+ */
+ interface XFormField : com::sun::star::uno::XInterface
+ {
+ string getFieldType();
+ void setFieldType([in] string fieldType);
+ com::sun::star::container::XNameContainer getParameters();
+ };
- void setType([in] short fieldType );
- void setRes([in] short res );
- void setDescription([in] string description );
+}; }; }; };
- };
-
- }; }; }; };
-
- #endif
+#endif
diff --git a/offapi/type_reference/typelibrary_history.txt b/offapi/type_reference/typelibrary_history.txt
index 70f0e1d0cb35..086397e8967e 100644
--- a/offapi/type_reference/typelibrary_history.txt
+++ b/offapi/type_reference/typelibrary_history.txt
@@ -141,10 +141,16 @@
to maybevoid and deprecate. They should be removed in a future version. The
implementation will never return them.
-25/02/09 (MST, JSC): TaskID=i96209
+02/25/09 (MST, JSC): TaskID=i96209
rename module css.text.FieldMaster to css.text.fieldmaster.
the implementation handles both variants.
-15/05/09 (MST, JSC): TaskID=i101965
+05/15/09 (MST, JSC): TaskID=i101965
fix read-only status of properties of css.text.TextPortion
+02/12/10 (JSC): TaskID=i107712, i107695
+ correct typo in com.sun.star.text.RedlinePortion. Property
+ RedLineDataTime have to be RedlineDateTime.
+ Update reference type library with the version of OOo 3.2. The new
+ reference type library is taken from the release source tree OOO320 m12.
+
diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb
index f9a30cdbbd53..22b8904052ff 100644
--- a/offapi/type_reference/types.rdb
+++ b/offapi/type_reference/types.rdb
Binary files differ
diff --git a/sal/inc/osl/file.h b/sal/inc/osl/file.h
index 1320a6f68ae5..29196469fa61 100644
--- a/sal/inc/osl/file.h
+++ b/sal/inc/osl/file.h
@@ -811,6 +811,14 @@ oslFileError SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64 *pSize )
*/
#define osl_File_MapFlag_RandomAccess ((sal_uInt32)(0x1))
+/** Map flag denoting that the mapped address space will be accessed by the
+ process soon (and it is advantageous for the operating system to already
+ start paging in the data).
+
+ @since UDK 3.2.12
+ */
+#define osl_File_MapFlag_WillNeed ((sal_uInt32)(0x2))
+
/** Map a shared file into memory.
@since UDK 3.2.10
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 216162e616d6..cc0c041bc328 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -1079,6 +1079,29 @@ SAL_CALL osl_mapFile (
}
}
}
+ if (uFlags & osl_File_MapFlag_WillNeed)
+ {
+ // On Linux, madvise(..., MADV_WILLNEED) appears to have the undesirable
+ // effect of not returning until the data has actually been paged in, so
+ // that its net effect would typically be to slow down the process
+ // (which could start processing at the beginning of the data while the
+ // OS simultaneously pages in the rest); on other platforms, it remains
+ // to be evaluated whether madvise or equivalent is available and
+ // actually useful:
+#if defined MACOSX
+ int e = posix_madvise(p, nLength, POSIX_MADV_WILLNEED);
+ if (e != 0)
+ {
+ OSL_TRACE(
+ "posix_madvise(..., POSIX_MADV_WILLNEED) failed with %d", e);
+ }
+#elif defined SOLARIS
+ if (madvise(static_cast< caddr_t >(p), nLength, MADV_WILLNEED) != 0)
+ {
+ OSL_TRACE("madvise(..., MADV_WILLNEED) failed with %d", errno);
+ }
+#endif
+ }
return osl_File_E_None;
}
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index d74f78fb30e2..734824d63e57 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -34,6 +34,7 @@
#include "file_url.h"
#include "file_error.h"
+
#include "path_helper.hxx"
#include "osl/diagnose.h"
@@ -291,7 +292,7 @@ struct DirectoryItem_Impl
WIN32_FIND_DATA FindData;
TCHAR cDriveString[MAX_PATH];
};
- TCHAR szFullPath[MAX_PATH];
+ rtl_uString* m_pFullPath;
BOOL bFullPathNormalized;
int nRefCount;
};
@@ -310,7 +311,7 @@ struct Directory_Impl
HANDLE hDirectory;
HANDLE hEnumDrives;
};
- TCHAR szDirectoryPath[MAX_PATH];
+ rtl_uString* m_pDirectoryPath;
};
//#####################################################
@@ -395,34 +396,48 @@ typedef struct tagDIRECTORY
} DIRECTORY, *PDIRECTORY, FAR *LPDIRECTORY;
//#####################################################
-static HANDLE WINAPI OpenDirectory(LPCTSTR lpszPath)
+static HANDLE WINAPI OpenDirectory( rtl_uString* pPath)
{
- LPDIRECTORY pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY));
+ LPDIRECTORY pDirectory = NULL;
- if (pDirectory)
+ if ( pPath )
{
- TCHAR szFileMask[MAX_PATH];
- int nLen;
+ sal_uInt32 nLen = rtl_uString_getLength( pPath );
+ if ( nLen )
+ {
+ TCHAR* pSuffix = 0;
+ sal_uInt32 nSuffLen = 0;
+
+ if ( pPath->buffer[nLen - 1] != L'\\' )
+ {
+ pSuffix = L"\\*.*";
+ nSuffLen = 4;
+ }
+ else
+ {
+ pSuffix = L"*.*";
+ nSuffLen = 3;
+ }
- _tcscpy( szFileMask, lpszPath );
- nLen = _tcslen( szFileMask );
+ TCHAR* szFileMask = reinterpret_cast< TCHAR* >( rtl_allocateMemory( sizeof( TCHAR ) * ( nLen + nSuffLen + 1 ) ) );
- if (nLen && szFileMask[nLen-1] != '\\')
- _tcscat(szFileMask, TEXT("\\*.*"));
- else
- _tcscat(szFileMask, TEXT("*.*"));
+ _tcscpy( szFileMask, reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pPath ) ) );
+ _tcscat( szFileMask, pSuffix );
- pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData);
+ pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY));
+ pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData);
- if (!IsValidHandle(pDirectory->hFind))
- {
- if ( GetLastError() != ERROR_NO_MORE_FILES )
+ if (!IsValidHandle(pDirectory->hFind))
{
- HeapFree(GetProcessHeap(), 0, pDirectory);
- pDirectory = NULL;
+ if ( GetLastError() != ERROR_NO_MORE_FILES )
+ {
+ HeapFree(GetProcessHeap(), 0, pDirectory);
+ pDirectory = NULL;
+ }
}
}
}
+
return (HANDLE)pDirectory;
}
@@ -499,15 +514,26 @@ static oslFileError osl_openLocalRoot(
Directory_Impl *pDirImpl;
pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl)));
- _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysPath)) );
+ ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
+ rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strSysPath );
/* Append backslash if neccessary */
/* @@@ToDo
use function ensure backslash
*/
- if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' )
- _tcscat( pDirImpl->szDirectoryPath, L"\\" );
+ sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath );
+ if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' )
+ {
+ rtl_uString* pCurDir = 0;
+ rtl_uString* pBackSlash = 0;
+
+ rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath );
+ rtl_uString_newFromStr( &pBackSlash, L"\\" );
+ rtl_uString_newConcat( &pDirImpl->m_pDirectoryPath, pCurDir, pBackSlash );
+ rtl_uString_release( pBackSlash );
+ rtl_uString_release( pCurDir );
+ }
pDirImpl->uType = DIRECTORYTYPE_LOCALROOT;
pDirImpl->hEnumDrives = OpenLogicalDrivesEnum();
@@ -523,7 +549,16 @@ static oslFileError osl_openLocalRoot(
else
{
if ( pDirImpl )
+ {
+ if ( pDirImpl->m_pDirectoryPath )
+ {
+ rtl_uString_release( pDirImpl->m_pDirectoryPath );
+ pDirImpl->m_pDirectoryPath = 0;
+ }
+
rtl_freeMemory(pDirImpl);
+ pDirImpl = 0;
+ }
error = oslTranslateFileError( GetLastError() );
}
@@ -544,23 +579,41 @@ static oslFileError SAL_CALL osl_openFileDirectory(
*pDirectory = NULL;
Directory_Impl *pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
- _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strDirectoryPath)) );
+ ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
+ rtl_uString_newFromString( &pDirImpl->m_pDirectoryPath, strDirectoryPath );
/* Append backslash if neccessary */
/* @@@ToDo
use function ensure backslash
*/
- if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' )
- _tcscat( pDirImpl->szDirectoryPath, L"\\" );
+ sal_uInt32 nLen = rtl_uString_getLength( pDirImpl->m_pDirectoryPath );
+ if ( nLen && pDirImpl->m_pDirectoryPath->buffer[nLen - 1] != L'\\' )
+ {
+ rtl_uString* pCurDir = 0;
+ rtl_uString* pBackSlash = 0;
+
+ rtl_uString_assign( &pCurDir, pDirImpl->m_pDirectoryPath );
+ rtl_uString_newFromStr( &pBackSlash, L"\\" );
+ rtl_uString_newConcat( &pDirImpl->m_pDirectoryPath, pCurDir, pBackSlash );
+ rtl_uString_release( pBackSlash );
+ rtl_uString_release( pCurDir );
+ }
+
pDirImpl->uType = DIRECTORYTYPE_FILESYSTEM;
- pDirImpl->hDirectory = OpenDirectory( pDirImpl->szDirectoryPath );
+ pDirImpl->hDirectory = OpenDirectory( pDirImpl->m_pDirectoryPath );
if ( !pDirImpl->hDirectory )
{
error = oslTranslateFileError( GetLastError() );
+ if ( pDirImpl->m_pDirectoryPath )
+ {
+ rtl_uString_release( pDirImpl->m_pDirectoryPath );
+ pDirImpl->m_pDirectoryPath = 0;
+ }
+
rtl_freeMemory(pDirImpl), pDirImpl = 0;
}
@@ -592,6 +645,7 @@ static oslFileError SAL_CALL osl_openNetworkServer(
Directory_Impl *pDirImpl;
pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
+ ZeroMemory( pDirImpl, sizeof(Directory_Impl) );
pDirImpl->uType = DIRECTORYTYPE_NETROOT;
pDirImpl->hDirectory = hEnum;
*pDirectory = (oslDirectory)pDirImpl;
@@ -609,7 +663,11 @@ static DWORD create_dir_with_callback(
// user specified callback function. On success
// the function returns ERROR_SUCCESS else a Win32 error code.
- if (CreateDirectory(reinterpret_cast<LPCTSTR>(dir_path->buffer), NULL))
+ BOOL bCreated = FALSE;
+
+ bCreated = CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( dir_path )), NULL );
+
+ if ( bCreated )
{
if (aDirectoryCreationCallbackFunc)
{
@@ -705,15 +763,18 @@ oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath)
if ( osl_File_E_None == error )
{
- if ( CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL ) )
- error = osl_File_E_None;
-/*@@@ToDo
- The else case is a hack because the ucb or the webtop had some
- problems with the error code that CreateDirectory returns in
- case the path is only a logical drive, should be removed!
-*/
- else
+ BOOL bCreated = FALSE;
+
+ bCreated = CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL );
+
+ if ( !bCreated )
{
+ /*@@@ToDo
+ The following case is a hack because the ucb or the webtop had some
+ problems with the error code that CreateDirectory returns in
+ case the path is only a logical drive, should be removed!
+ */
+
const sal_Unicode *pBuffer = rtl_uString_getStr( strSysPath );
sal_Int32 nLen = rtl_uString_getLength( strSysPath );
@@ -862,6 +923,12 @@ static oslFileError SAL_CALL osl_getNextDrive(
}
else
{
+ if ( pItemImpl->m_pFullPath )
+ {
+ rtl_uString_release( pItemImpl->m_pFullPath );
+ pItemImpl->m_pFullPath = 0;
+ }
+
rtl_freeMemory( pItemImpl );
return oslTranslateFileError( GetLastError() );
}
@@ -895,14 +962,24 @@ static oslFileError SAL_CALL osl_getNextFileItem(
{
pItemImpl->uType = DIRECTORYITEM_FILE;
pItemImpl->nRefCount = 1;
- _tcscpy( pItemImpl->szFullPath, pDirImpl->szDirectoryPath );
- _tcscat( pItemImpl->szFullPath, pItemImpl->FindData.cFileName );
+
+ rtl_uString* pTmpFileName = 0;
+ rtl_uString_newFromStr( &pTmpFileName, pItemImpl->FindData.cFileName );
+ rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName );
+ rtl_uString_release( pTmpFileName );
+
pItemImpl->bFullPathNormalized = FALSE;
*pItem = (oslDirectoryItem)pItemImpl;
return osl_File_E_None;
}
else
{
+ if ( pItemImpl->m_pFullPath )
+ {
+ rtl_uString_release( pItemImpl->m_pFullPath );
+ pItemImpl->m_pFullPath = 0;
+ }
+
rtl_freeMemory( pItemImpl );
return oslTranslateFileError( GetLastError() );
}
@@ -963,6 +1040,12 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory)
break;
}
+ if ( pDirImpl->m_pDirectoryPath )
+ {
+ rtl_uString_release( pDirImpl->m_pDirectoryPath );
+ pDirImpl->m_pDirectoryPath = 0;
+ }
+
rtl_freeMemory(pDirImpl);
}
return eError;
@@ -1024,8 +1107,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
pItemImpl->uType = DIRECTORYITEM_SERVER;
osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
-
- _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) );
+ rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath );
// Assign a title anyway
{
@@ -1088,7 +1170,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) );
- _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)) );
+ rtl_uString_newFromString( &pItemImpl->m_pFullPath, strSysFilePath );
// MT: This costs 600ms startup time on fast v60x!
// GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
@@ -1130,7 +1212,16 @@ oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
return osl_File_E_INVAL;
if ( ! --pItemImpl->nRefCount )
+ {
+ if ( pItemImpl->m_pFullPath )
+ {
+ rtl_uString_release( pItemImpl->m_pFullPath );
+ pItemImpl->m_pFullPath = 0;
+ }
+
rtl_freeMemory( pItemImpl );
+ }
+
return osl_File_E_None;
}
@@ -1344,18 +1435,22 @@ static oslFileError get_filesystem_attributes(
}
if (is_filesystem_attributes_request(field_mask))
{
- WCHAR vn[MAX_PATH];
- WCHAR fsn[MAX_PATH];
+ /* the following two parameters can not be longer than MAX_PATH+1 */
+ WCHAR vn[MAX_PATH+1];
+ WCHAR fsn[MAX_PATH+1];
+
DWORD serial;
DWORD mcl;
DWORD flags;
LPCTSTR pszPath = reinterpret_cast<LPCTSTR>(path.getStr());
- if (GetVolumeInformation(pszPath, vn, MAX_PATH, &serial, &mcl, &flags, fsn, MAX_PATH))
+ if (GetVolumeInformation(pszPath, vn, MAX_PATH+1, &serial, &mcl, &flags, fsn, MAX_PATH+1))
{
+ // Currently sal does not use this value, instead MAX_PATH is used
pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength;
pInfo->uMaxNameLength = mcl;
+ // Should the uMaxPathLength be set to 32767, "\\?\" prefix allowes it
pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength;
pInfo->uMaxPathLength = MAX_PATH;
@@ -1558,11 +1653,7 @@ static oslFileError SAL_CALL osl_getServerInfo(
if ( uFieldMask & osl_FileStatus_Mask_FileURL )
{
- rtl_uString *ustrSystemPath = NULL;
-
- rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
- osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
- rtl_uString_release( ustrSystemPath );
+ osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
}
return osl_File_E_None;
@@ -1591,7 +1682,7 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( uFieldMask & osl_FileStatus_Mask_Validate )
{
- HANDLE hFind = FindFirstFile( pItemImpl->szFullPath, &pItemImpl->FindData );
+ HANDLE hFind = FindFirstFile( reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pItemImpl->m_pFullPath ) ), &pItemImpl->FindData );
if ( hFind != INVALID_HANDLE_VALUE )
FindClose( hFind );
@@ -1651,28 +1742,30 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL )
{
- rtl_uString *ustrFullPath = NULL;
-
- rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
- osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrLinkTargetURL );
- rtl_uString_release( ustrFullPath );
+ osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrLinkTargetURL );
pStatus->uValidFields |= osl_FileStatus_Mask_LinkTargetURL;
}
if ( uFieldMask & osl_FileStatus_Mask_FileURL )
{
- rtl_uString *ustrFullPath = NULL;
-
-
if ( !pItemImpl->bFullPathNormalized )
{
- GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
- pItemImpl->bFullPathNormalized = TRUE;
+ sal_uInt32 nLen = rtl_uString_getLength( pItemImpl->m_pFullPath );
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ sal_uInt32 nNewLen = GetCaseCorrectPathName( reinterpret_cast<LPCTSTR>( rtl_uString_getStr( pItemImpl->m_pFullPath ) ),
+ aBuffer,
+ aBuffer.getBufSizeInSymbols(),
+ sal_True );
+
+ if ( nNewLen )
+ {
+ rtl_uString_newFromStr( &pItemImpl->m_pFullPath, aBuffer );
+ pItemImpl->bFullPathNormalized = TRUE;
+ }
}
- rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
- osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrFileURL );
- rtl_uString_release( ustrFullPath );
+
+ osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
}
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index f87f02b093d6..8e11be1d6a5c 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -38,6 +38,8 @@
#include "osl/file.h"
#include "osl/mutex.h"
+#include "path_helper.hxx"
+
#include <stdio.h>
#include <tchar.h>
@@ -49,6 +51,11 @@
#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
+#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\"
+#define WSTR_LONG_PATH_PREFIX L"\\\\?\\"
+#define WSTR_LONG_PATH_PREFIX_UNC L"\\\\?\\UNC\\"
+
+
//##################################################################
// FileURL functions
//##################################################################
@@ -65,7 +72,7 @@ static BOOL IsValidFilePathComponent(
BOOL fValid = TRUE; /* Assume success */
TCHAR cLast = 0;
- /* Path component length must not exceed MAX_PATH */
+ /* Path component length must not exceed MAX_PATH even if long path with "\\?\" prefix is used */
while ( !lpComponentEnd && lpCurrent && lpCurrent - lpComponent < MAX_PATH )
{
@@ -232,31 +239,56 @@ static BOOL IsValidFilePathComponent(
DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_uString **corrected)
{
LPCTSTR lpszPath = reinterpret_cast< LPCTSTR >(path->buffer);
- LPCTSTR lpComponent;
+ LPCTSTR lpComponent = lpszPath;
BOOL fValid = TRUE;
DWORD dwPathType = PATHTYPE_ERROR;
+ sal_Int32 nLength = rtl_uString_getLength( path );
if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE )
dwFlags |= VALIDATEPATH_ALLOW_ELLIPSE;
if ( !lpszPath )
- {
fValid = FALSE;
- lpComponent = lpszPath;
- }
- /* Test for UNC path notation */
- if ( 2 == _tcsspn( lpszPath, CHARSET_SEPARATOR ) )
+ DWORD dwCandidatPathType = PATHTYPE_ERROR;
+
+ if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, WSTR_LONG_PATH_PREFIX_UNC, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) )
+ {
+ /* This is long path in UNC notation */
+ lpComponent = lpszPath + ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX_UNC) - 1;
+ dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC | PATHTYPE_IS_LONGPATH;
+ }
+ else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, WSTR_LONG_PATH_PREFIX, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) )
{
- /* Place the pointer behind the leading to backslashes */
+ /* This is long path */
+ lpComponent = lpszPath + ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1;
+ if ( _istalpha( lpComponent[0] ) && ':' == lpComponent[1] )
+ {
+ lpComponent += 2;
+ dwCandidatPathType = PATHTYPE_ABSOLUTE_LOCAL | PATHTYPE_IS_LONGPATH;
+ }
+ }
+ else if ( 2 == _tcsspn( lpszPath, CHARSET_SEPARATOR ) )
+ {
+ /* The UNC path notation */
lpComponent = lpszPath + 2;
+ dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC;
+ }
+ else if ( _istalpha( lpszPath[0] ) && ':' == lpszPath[1] )
+ {
+ /* Local path verification. Must start with <drive>: */
+ lpComponent = lpszPath + 2;
+ dwCandidatPathType = PATHTYPE_ABSOLUTE_LOCAL;
+ }
+ if ( ( dwCandidatPathType & PATHTYPE_MASK_TYPE ) == PATHTYPE_ABSOLUTE_UNC )
+ {
fValid = IsValidFilePathComponent( lpComponent, &lpComponent, VALIDATEPATH_ALLOW_ELLIPSE );
/* So far we have a valid servername. Now let's see if we also have a network resource */
- dwPathType = PATHTYPE_ABSOLUTE_UNC;
+ dwPathType = dwCandidatPathType;
if ( fValid )
{
@@ -291,20 +323,14 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
}
}
}
-
- /* Local path verification. Must start with <drive>: */
- else if ( _istalpha( lpszPath[0] ) && ':' == lpszPath[1] )
+ else if ( ( dwCandidatPathType & PATHTYPE_MASK_TYPE ) == PATHTYPE_ABSOLUTE_LOCAL )
{
- /* Place pointer behind correct drive specification */
-
- lpComponent = lpszPath + 2;
-
if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) )
lpComponent++;
else if ( *lpComponent )
fValid = FALSE;
- dwPathType = PATHTYPE_ABSOLUTE_LOCAL;
+ dwPathType = dwCandidatPathType;
/* Now we are behind the backslash or it was a simple drive without backslash */
@@ -314,10 +340,9 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
dwPathType |= PATHTYPE_IS_VOLUME;
}
}
-
- /* Can be a relative path */
else if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE )
{
+ /* Can be a relative path */
lpComponent = lpszPath;
/* Relative path can start with a backslash */
@@ -331,10 +356,9 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
dwPathType = PATHTYPE_RELATIVE;
}
-
- /* Anything else is an error */
else
{
+ /* Anything else is an error */
fValid = FALSE;
lpComponent = lpszPath;
}
@@ -364,7 +388,8 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
}
}
- if ( fValid && _tcslen( lpszPath ) >= MAX_PATH )
+ /* The path can be longer than MAX_PATH only in case it has the longpath prefix */
+ if ( fValid && !( dwPathType & PATHTYPE_IS_LONGPATH ) && _tcslen( lpszPath ) >= MAX_PATH )
{
fValid = FALSE;
lpComponent = lpszPath + MAX_PATH;
@@ -376,38 +401,45 @@ DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_u
return fValid ? dwPathType : PATHTYPE_ERROR;
}
-//#############################################
//#####################################################
-//Undocumented in SHELL32.DLL ordinal 35
-static BOOL PathRemoveFileSpec(LPTSTR lpPath)
+static sal_Int32 PathRemoveFileSpec(LPTSTR lpPath, LPTSTR lpFileName, sal_Int32 nFileBufLen )
{
- BOOL fSuccess = FALSE; // Assume failure
- LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' );
- LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' );
- LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
+ sal_Int32 nRemoved = 0;
- if ( lpLastDelimiter )
+ if ( nFileBufLen )
{
- if ( 0 == *(lpLastDelimiter + 1) )
- {
- if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != ':' )
+ lpFileName[0] = 0;
+ LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' );
+ LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' );
+ LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
+
+ if ( lpLastDelimiter )
+ {
+ sal_Int32 nDelLen = _tcslen( lpLastDelimiter );
+ if ( 1 == nDelLen )
{
- *lpLastDelimiter = 0;
- fSuccess = TRUE;
+ if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != ':' )
+ {
+ *lpLastDelimiter = 0;
+ *lpFileName = 0;
+ nRemoved = nDelLen;
+ }
}
- }
- else
- {
- *(++lpLastDelimiter) = 0;
- fSuccess = TRUE;
- }
+ else if ( nDelLen && nDelLen - 1 < nFileBufLen )
+ {
+ _tcscpy( lpFileName, lpLastDelimiter + 1 );
+ *(++lpLastDelimiter) = 0;
+ nRemoved = nDelLen - 1;
+ }
+ }
}
- return fSuccess;
+
+ return nRemoved;
}
//#####################################################
// Undocumented in SHELL32.DLL ordinal 32
-static LPTSTR PathAddBackslash(LPTSTR lpPath)
+static LPTSTR PathAddBackslash(LPTSTR lpPath, sal_Int32 nBufLen)
{
LPTSTR lpEndPath = NULL;
@@ -415,7 +447,7 @@ static LPTSTR PathAddBackslash(LPTSTR lpPath)
{
int nLen = _tcslen(lpPath);
- if ( !nLen || lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && nLen < MAX_PATH - 1 )
+ if ( !nLen || lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && nLen < nBufLen - 1 )
{
lpEndPath = lpPath + nLen;
*lpEndPath++ = '\\';
@@ -428,37 +460,31 @@ static LPTSTR PathAddBackslash(LPTSTR lpPath)
//#####################################################
// Same as GetLongPathName but also 95/NT4
static DWORD GetCaseCorrectPathNameEx(
- LPCTSTR lpszShortPath, // file name
- LPTSTR lpszLongPath, // path buffer
+ LPTSTR lpszPath, // path buffer to convert
DWORD cchBuffer, // size of path buffer
- DWORD nSkipLevels
-)
+ DWORD nSkipLevels,
+ BOOL bCheckExistence )
{
- TCHAR szPath[MAX_PATH];
- BOOL fSuccess;
-
- cchBuffer = cchBuffer; /* avoid warnings */
-
- _tcscpy( szPath, lpszShortPath );
-
- fSuccess = PathRemoveFileSpec( szPath );
+ ::osl::LongPathBuffer< sal_Unicode > szFile( MAX_PATH + 1 );
+ sal_Int32 nRemoved = PathRemoveFileSpec( lpszPath, szFile, MAX_PATH + 1 );
+ sal_Int32 nLastStepRemoved = nRemoved;
+ while ( nLastStepRemoved && szFile[0] == 0 )
+ {
+ // remove separators
+ nLastStepRemoved = PathRemoveFileSpec( lpszPath, szFile, MAX_PATH + 1 );
+ nRemoved += nLastStepRemoved;
+ }
- if ( fSuccess )
+ if ( nRemoved )
{
- int nLen = _tcslen( szPath );
- LPCTSTR lpszFileSpec = lpszShortPath + nLen;
- BOOL bSkipThis;
+ BOOL bSkipThis = FALSE;
- if ( 0 == _tcscmp( lpszFileSpec, TEXT("..") ) )
+ if ( 0 == _tcscmp( szFile, TEXT("..") ) )
{
bSkipThis = TRUE;
nSkipLevels += 1;
}
- else if (
- 0 == _tcscmp( lpszFileSpec, TEXT(".") ) ||
- 0 == _tcscmp( lpszFileSpec, TEXT("\\") ) ||
- 0 == _tcscmp( lpszFileSpec, TEXT("/") )
- )
+ else if ( 0 == _tcscmp( szFile, TEXT(".") ) )
{
bSkipThis = TRUE;
}
@@ -470,24 +496,36 @@ static DWORD GetCaseCorrectPathNameEx(
else
bSkipThis = FALSE;
- GetCaseCorrectPathNameEx( szPath, szPath, MAX_PATH, nSkipLevels );
+ GetCaseCorrectPathNameEx( lpszPath, cchBuffer, nSkipLevels, bCheckExistence );
- PathAddBackslash( szPath );
+ PathAddBackslash( lpszPath, cchBuffer );
/* Analyze parent if not only a trailing backslash was cutted but a real file spec */
if ( !bSkipThis )
{
- WIN32_FIND_DATA aFindFileData;
- HANDLE hFind = FindFirstFile( lpszShortPath, &aFindFileData );
-
- if ( IsValidHandle(hFind) )
+ if ( bCheckExistence )
{
- _tcscat( szPath, aFindFileData.cFileName[0] ? aFindFileData.cFileName : aFindFileData.cAlternateFileName );
+ ::osl::LongPathBuffer< sal_Unicode > aShortPath( MAX_LONG_PATH );
+ _tcscpy( aShortPath, lpszPath );
+ _tcscat( aShortPath, szFile );
- FindClose( hFind );
+ WIN32_FIND_DATA aFindFileData;
+ HANDLE hFind = FindFirstFile( aShortPath, &aFindFileData );
+
+ if ( IsValidHandle(hFind) )
+ {
+ _tcscat( lpszPath, aFindFileData.cFileName[0] ? aFindFileData.cFileName : aFindFileData.cAlternateFileName );
+
+ FindClose( hFind );
+ }
+ else
+ lpszPath[0] = 0;
}
else
- return 0;
+ {
+ /* add the segment name back */
+ _tcscat( lpszPath, szFile );
+ }
}
}
else
@@ -496,14 +534,12 @@ static DWORD GetCaseCorrectPathNameEx(
or a network share. If still levels to skip are left, the path specification
tries to travel below the file system root */
if ( nSkipLevels )
- return 0;
-
- _tcsupr( szPath );
+ lpszPath[0] = 0;
+ else
+ _tcsupr( lpszPath );
}
- _tcscpy( lpszLongPath, szPath );
-
- return _tcslen( lpszLongPath );
+ return _tcslen( lpszPath );
}
//#####################################################
@@ -512,7 +548,8 @@ static DWORD GetCaseCorrectPathNameEx(
DWORD GetCaseCorrectPathName(
LPCTSTR lpszShortPath, // file name
LPTSTR lpszLongPath, // path buffer
- DWORD cchBuffer // size of path buffer
+ DWORD cchBuffer, // size of path buffer
+ BOOL bCheckExistence
)
{
/* Special handling for "\\.\" as system root */
@@ -528,12 +565,19 @@ DWORD GetCaseCorrectPathName(
return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1;
}
}
- else
+ else if ( lpszShortPath )
{
- return GetCaseCorrectPathNameEx( lpszShortPath, lpszLongPath, cchBuffer, 0 );
+ if ( _tcslen( lpszShortPath ) <= cchBuffer )
+ {
+ _tcscpy( lpszLongPath, lpszShortPath );
+ return GetCaseCorrectPathNameEx( lpszLongPath, cchBuffer, 0, bCheckExistence );
+ }
}
+
+ return 0;
}
+
//#############################################
static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL )
{
@@ -667,7 +711,6 @@ static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
}
//#############################################
-#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\"
oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative )
{
@@ -725,13 +768,60 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
if ( nDecodedLen == nSkip )
rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 );
else
- rtl_uString_newFromStr_WithLength( &strTempPath, pDecodedURL + nSkip, nDecodedLen - nSkip );
+ {
+ /* do not separate the directory and file case, so the maximal path lengs without prefix is MAX_PATH-12 */
+ if ( nDecodedLen - nSkip <= MAX_PATH - 12 )
+ {
+ rtl_uString_newFromStr_WithLength( &strTempPath, pDecodedURL + nSkip, nDecodedLen - nSkip );
+ }
+ else
+ {
+ ::osl::LongPathBuffer< sal_Unicode > aBuf( MAX_LONG_PATH );
+ sal_uInt32 nNewLen = GetCaseCorrectPathName( pDecodedURL + nSkip,
+ aBuf,
+ aBuf.getBufSizeInSymbols(),
+ sal_False );
+
+ if ( nNewLen <= MAX_PATH - 12
+ || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_SYSTEM_ROOT_PATH, ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1, ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 )
+ || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, WSTR_LONG_PATH_PREFIX, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1, ELEMENTS_OF_ARRAY(WSTR_LONG_PATH_PREFIX) - 1 ) )
+ {
+ rtl_uString_newFromStr_WithLength( &strTempPath, aBuf, nNewLen );
+ }
+ else if ( pDecodedURL[nSkip] == (sal_Unicode)'\\' && pDecodedURL[nSkip+1] == (sal_Unicode)'\\' )
+ {
+ /* it should be an UNC path, use the according prefix */
+ rtl_uString *strSuffix = NULL;
+ rtl_uString *strPrefix = NULL;
+ rtl_uString_newFromStr_WithLength( &strPrefix, WSTR_LONG_PATH_PREFIX_UNC, ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX_UNC ) - 1 );
+ rtl_uString_newFromStr_WithLength( &strSuffix, aBuf + 2, nNewLen - 2 );
+
+ rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix );
+
+ rtl_uString_release( strPrefix );
+ rtl_uString_release( strSuffix );
+ }
+ else
+ {
+ rtl_uString *strSuffix = NULL;
+ rtl_uString *strPrefix = NULL;
+ rtl_uString_newFromStr_WithLength( &strPrefix, WSTR_LONG_PATH_PREFIX, ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX ) - 1 );
+ rtl_uString_newFromStr_WithLength( &strSuffix, aBuf, nNewLen );
+
+ rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix );
+
+ rtl_uString_release( strPrefix );
+ rtl_uString_release( strSuffix );
+ }
+ }
+ }
if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
nError = osl_File_E_None;
}
else if ( bAllowRelative ) /* This maybe a relative file URL */
{
+ /* In future the relative path could be converted to absolute if it is too long */
rtl_uString_assign( &strTempPath, strDecodedURL );
if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
@@ -774,8 +864,51 @@ oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString**
{
rtl_uString *strTempPath = NULL;
- /* Replace backslashes */
- rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' );
+ if ( dwPathType & PATHTYPE_IS_LONGPATH )
+ {
+ rtl_uString *strBuffer = NULL;
+ sal_uInt32 nIgnore = 0;
+ sal_uInt32 nLength = 0;
+
+ /* the path has the longpath prefix, lets remove it */
+ switch ( dwPathType & PATHTYPE_MASK_TYPE )
+ {
+ case PATHTYPE_ABSOLUTE_UNC:
+ nIgnore = ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX_UNC ) - 1;
+ OSL_ENSURE( nIgnore == 8, "Unexpected long path UNC prefix!" );
+
+ /* generate the normal UNC path */
+ nLength = rtl_uString_getLength( strPath );
+ rtl_uString_newFromStr_WithLength( &strBuffer, strPath->buffer + nIgnore - 2, nLength - nIgnore + 2 );
+ strBuffer->buffer[0] = '\\';
+
+ rtl_uString_newReplace( &strTempPath, strBuffer, '\\', '/' );
+ rtl_uString_release( strBuffer );
+ break;
+
+ case PATHTYPE_ABSOLUTE_LOCAL:
+ nIgnore = ELEMENTS_OF_ARRAY( WSTR_LONG_PATH_PREFIX ) - 1;
+ OSL_ENSURE( nIgnore == 4, "Unexpected long path prefix!" );
+
+ /* generate the normal path */
+ nLength = rtl_uString_getLength( strPath );
+ rtl_uString_newFromStr_WithLength( &strBuffer, strPath->buffer + nIgnore, nLength - nIgnore );
+
+ rtl_uString_newReplace( &strTempPath, strBuffer, '\\', '/' );
+ rtl_uString_release( strBuffer );
+ break;
+
+ default:
+ OSL_ASSERT( "Unexpected long path format!" );
+ rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' );
+ break;
+ }
+ }
+ else
+ {
+ /* Replace backslashes */
+ rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' );
+ }
switch ( dwPathType & PATHTYPE_MASK_TYPE )
{
@@ -944,8 +1077,8 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr
if ( !eError )
{
- TCHAR szBuffer[MAX_PATH];
- TCHAR szCurrentDir[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ ::osl::LongPathBuffer< sal_Unicode > aCurrentDir( MAX_LONG_PATH );
LPTSTR lpFilePart = NULL;
DWORD dwResult;
@@ -960,28 +1093,28 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr
{
osl_acquireMutex( g_CurrentDirectoryMutex );
- GetCurrentDirectory( MAX_PATH, szCurrentDir );
- SetCurrentDirectory( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) );
+ GetCurrentDirectoryW( aCurrentDir.getBufSizeInSymbols(), aCurrentDir );
+ SetCurrentDirectoryW( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) );
}
- dwResult = GetFullPathName( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), MAX_PATH, szBuffer, &lpFilePart );
+ dwResult = GetFullPathNameW( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), aBuffer, &lpFilePart );
if ( ustrBaseSysPath )
{
- SetCurrentDirectory( szCurrentDir );
+ SetCurrentDirectoryW( aCurrentDir );
osl_releaseMutex( g_CurrentDirectoryMutex );
}
if ( dwResult )
{
- if ( dwResult >= MAX_PATH )
+ if ( dwResult >= aBuffer.getBufSizeInSymbols() )
eError = osl_File_E_INVAL;
else
{
rtl_uString *ustrAbsSysPath = NULL;
- rtl_uString_newFromStr( &ustrAbsSysPath, reinterpret_cast<const sal_Unicode*>(szBuffer) );
+ rtl_uString_newFromStr( &ustrAbsSysPath, aBuffer );
eError = osl_getFileURLFromSystemPath( ustrAbsSysPath, pustrAbsoluteURL );
diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h
index 55b7145ec5cf..d9137c8c2fcc 100644
--- a/sal/osl/w32/file_url.h
+++ b/sal/osl/w32/file_url.h
@@ -54,6 +54,7 @@ extern "C" {
#define PATHTYPE_MASK_TYPE 0xFF
#define PATHTYPE_IS_VOLUME 0x0100
#define PATHTYPE_IS_SERVER 0x0200
+#define PATHTYPE_IS_LONGPATH 0x0400
#define VALIDATEPATH_NORMAL 0x0000
#define VALIDATEPATH_ALLOW_WILDCARDS 0x0001
@@ -61,6 +62,8 @@ extern "C" {
#define VALIDATEPATH_ALLOW_RELATIVE 0x0004
#define VALIDATEPATH_ALLOW_UNC 0x0008
+#define MAX_LONG_PATH 32767
+
DWORD IsValidFilePath (
rtl_uString * path,
LPCTSTR * lppError,
@@ -71,7 +74,8 @@ DWORD IsValidFilePath (
DWORD GetCaseCorrectPathName (
LPCTSTR lpszShortPath, // file name
LPTSTR lpszLongPath, // path buffer
- DWORD cchBuffer // size of path buffer
+ DWORD cchBuffer, // size of path buffer
+ BOOL bCheckExistence
);
oslFileError _osl_getSystemPathFromFileURL (
diff --git a/sal/osl/w32/module.c b/sal/osl/w32/module.cxx
index 902bab0726b0..98ffd0bc09d4 100644
--- a/sal/osl/w32/module.c
+++ b/sal/osl/w32/module.cxx
@@ -1,39 +1,42 @@
/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
#include "system.h"
#include <tlhelp32.h>
+#include "file_url.h"
+#include "path_helper.hxx"
+
#include <osl/module.h>
#include <osl/diagnose.h>
#include <osl/thread.h>
#include <osl/file.h>
#include <rtl/logfile.h>
+
/*
under WIN32, we use the void* oslModule
as a WIN32 HANDLE (which is also a 32-bit value)
@@ -309,22 +312,22 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p
if ( lpfnSymInitialize && lpfnSymCleanup && lpfnSymGetModuleInfo )
{
IMAGEHLP_MODULE ModuleInfo;
- CHAR szModuleFileName[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aModuleFileName( MAX_LONG_PATH );
LPSTR lpSearchPath = NULL;
- if ( GetModuleFileNameA( NULL, szModuleFileName, sizeof(szModuleFileName) ) )
+ if ( GetModuleFileNameA( NULL, aModuleFileName, aModuleFileName.getBufSizeInSymbols() ) )
{
- char *pLastBkSlash = strrchr( szModuleFileName, '\\' );
+ char *pLastBkSlash = strrchr( aModuleFileName, '\\' );
if (
pLastBkSlash &&
- pLastBkSlash > szModuleFileName
+ pLastBkSlash > (sal_Char*)aModuleFileName
&& *(pLastBkSlash - 1) != ':'
&& *(pLastBkSlash - 1) != '\\'
)
{
*pLastBkSlash = 0;
- lpSearchPath = szModuleFileName;
+ lpSearchPath = aModuleFileName;
}
}
@@ -423,12 +426,12 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT( void *pv, rtl_uString **pu
if ( (BYTE *)pv >= (BYTE *)modinfo.lpBaseOfDll && (BYTE *)pv < (BYTE *)modinfo.lpBaseOfDll + modinfo.SizeOfImage )
{
- WCHAR szBuffer[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
rtl_uString *ustrSysPath = NULL;
- GetModuleFileNameW( lpModules[iModule], szBuffer, bufsizeof(szBuffer) );
+ GetModuleFileNameW( lpModules[iModule], aBuffer, aBuffer.getBufSizeInSymbols() );
- rtl_uString_newFromStr( &ustrSysPath, szBuffer );
+ rtl_uString_newFromStr( &ustrSysPath, aBuffer );
osl_getFileURLFromSystemPath( ustrSysPath, pustrURL );
rtl_uString_release( ustrSysPath );
diff --git a/sal/osl/w32/path_helper.hxx b/sal/osl/w32/path_helper.hxx
index 106f2a76f043..64b0ac573da3 100644
--- a/sal/osl/w32/path_helper.hxx
+++ b/sal/osl/w32/path_helper.hxx
@@ -34,6 +34,7 @@
#include "path_helper.h"
#include <rtl/ustring.hxx>
+#include <rtl/allocator.hxx>
namespace osl
{
@@ -70,6 +71,45 @@ inline bool systemPathIsLogicalDrivePattern(/*in*/ const rtl::OUString& path)
return osl_systemPathIsLogicalDrivePattern(path.pData);
}
+/*******************************************************************
+ LongPathBuffer
+ ******************************************************************/
+template< class T >
+class LongPathBuffer
+{
+ T* m_pBuffer;
+ sal_uInt32 m_nCharNum;
+
+ LongPathBuffer();
+ LongPathBuffer( const LongPathBuffer& );
+ LongPathBuffer& operator=( const LongPathBuffer& );
+
+public:
+ LongPathBuffer( sal_uInt32 nCharNum )
+ : m_pBuffer( reinterpret_cast<T*>( rtl_allocateMemory( nCharNum * sizeof( T ) ) ) )
+ , m_nCharNum( nCharNum )
+ {
+ OSL_ENSURE( m_pBuffer, "Can not allocate the buffer!" );
+ }
+
+ ~LongPathBuffer()
+ {
+ if ( m_pBuffer )
+ rtl_freeMemory( m_pBuffer );
+ m_pBuffer = 0;
+ }
+
+ sal_uInt32 getBufSizeInSymbols()
+ {
+ return m_nCharNum;
+ }
+
+ operator T* ()
+ {
+ return m_pBuffer;
+ }
+};
+
} // end namespace osl
#endif
diff --git a/sal/osl/w32/process.c b/sal/osl/w32/process.cxx
index 334ae7aef726..12eda6658033 100644
--- a/sal/osl/w32/process.c
+++ b/sal/osl/w32/process.cxx
@@ -1,29 +1,29 @@
/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
#define UNICODE
#include "system.h"
@@ -43,6 +43,8 @@
#include "procimpl.h"
#include "sockimpl.h"
+#include "file_url.h"
+#include "path_helper.hxx"
#include <rtl/ustrbuf.h>
#include <rtl/alloc.h>
@@ -72,7 +74,7 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident)
if (hProcess)
{
- pProcImpl = rtl_allocateMemory(sizeof(oslProcessImpl));
+ pProcImpl = reinterpret_cast< oslProcessImpl*>( rtl_allocateMemory(sizeof(oslProcessImpl)) );
pProcImpl->m_hProcess = hProcess;
pProcImpl->m_IdProcess = Ident;
}
@@ -216,19 +218,19 @@ oslProcessError SAL_CALL osl_joinProcessWithTimeout(oslProcess Process, const Ti
*
***************************************************************************/
-oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl (
+extern "C" oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl (
rtl_uString ** ppFileURL
) SAL_THROW_EXTERN_C()
{
oslProcessError result = osl_Process_E_NotFound;
- TCHAR buffer[MAX_PATH];
- DWORD buflen;
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ DWORD buflen = 0;
- if ((buflen = GetModuleFileNameW (0, buffer, MAX_PATH)) > 0)
+ if ((buflen = GetModuleFileNameW (0, aBuffer, aBuffer.getBufSizeInSymbols())) > 0)
{
rtl_uString * pAbsPath = 0;
- rtl_uString_newFromStr_WithLength (&(pAbsPath), buffer, buflen);
+ rtl_uString_newFromStr_WithLength (&(pAbsPath), aBuffer, buflen);
if (pAbsPath)
{
/* Convert from path to url. */
@@ -282,16 +284,16 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char ** argv)
if (ppArgs[0] != 0)
{
/* Ensure absolute path */
- DWORD dwResult;
- TCHAR szBuffer[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ DWORD dwResult = 0;
dwResult = SearchPath (
- 0, ppArgs[0]->buffer, L".exe", MAX_PATH, szBuffer, 0);
- if ((0 < dwResult) && (dwResult < MAX_PATH))
+ 0, ppArgs[0]->buffer, L".exe", aBuffer.getBufSizeInSymbols(), aBuffer, 0);
+ if ((0 < dwResult) && (dwResult < aBuffer.getBufSizeInSymbols()))
{
/* Replace argv[0] with it's absolute path */
rtl_uString_newFromStr_WithLength(
- &(ppArgs[0]), szBuffer, dwResult);
+ &(ppArgs[0]), aBuffer, dwResult);
}
}
if (ppArgs[0] != 0)
@@ -411,24 +413,24 @@ oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *ustrVar, rtl_uString **
* Current Working Directory.
***************************************************************************/
-extern oslMutex g_CurrentDirectoryMutex;
+extern "C" oslMutex g_CurrentDirectoryMutex;
oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir )
{
- TCHAR szBuffer[MAX_PATH];
- DWORD dwLen;
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ DWORD dwLen = 0;
osl_acquireMutex( g_CurrentDirectoryMutex );
- dwLen = GetCurrentDirectory( sizeof(szBuffer) / sizeof(TCHAR), szBuffer );
+ dwLen = GetCurrentDirectory( aBuffer.getBufSizeInSymbols(), aBuffer );
osl_releaseMutex( g_CurrentDirectoryMutex );
- if ( dwLen )
+ if ( dwLen && dwLen < aBuffer.getBufSizeInSymbols() )
{
oslFileError eError;
rtl_uString *ustrTemp = NULL;;
- rtl_uString_newFromStr_WithLength( &ustrTemp, szBuffer, dwLen );
+ rtl_uString_newFromStr_WithLength( &ustrTemp, aBuffer, dwLen );
eError = osl_getFileURLFromSystemPath( ustrTemp, pustrWorkingDir );
rtl_uString_release( ustrTemp );
@@ -446,7 +448,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir
* Process Locale.
***************************************************************************/
-extern void _imp_getProcessLocale( rtl_Locale ** ppLocale );
+extern "C" void _imp_getProcessLocale( rtl_Locale ** ppLocale );
static rtl_Locale * g_theProcessLocale = NULL;
diff --git a/sal/osl/w32/profile.c b/sal/osl/w32/profile.cxx
index 5a709cddc3f5..f30ac7ce3348 100644
--- a/sal/osl/w32/profile.c
+++ b/sal/osl/w32/profile.cxx
@@ -1,33 +1,35 @@
/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
#include "system.h"
+#include "file_url.h"
+#include "path_helper.hxx"
+
#include <osl/diagnose.h>
#include <osl/profile.h>
#include <osl/process.h>
@@ -499,10 +501,10 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
}
else
{
- CHAR szFileName[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, szFileName, MAX_PATH, NULL, NULL);
- GetPrivateProfileString(pszSection, pszEntry, pszDefault, pszString, MaxLen, szFileName);
+ WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ GetPrivateProfileString(pszSection, pszEntry, pszDefault, pszString, MaxLen, aFileName);
}
releaseProfile(pProfile);
@@ -680,10 +682,10 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
}
else
{
- CHAR szFileName[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, szFileName, MAX_PATH, NULL, NULL);
- WritePrivateProfileString(pszSection, pszEntry, pszString, szFileName);
+ WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WritePrivateProfileString(pszSection, pszEntry, pszString, aFileName);
}
bRet = releaseProfile(pProfile);
@@ -791,10 +793,10 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
}
else
{
- CHAR szFileName[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, szFileName, MAX_PATH, NULL, NULL);
- WritePrivateProfileString(pszSection, pszEntry, NULL, szFileName);
+ WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ WritePrivateProfileString(pszSection, pszEntry, NULL, aFileName);
}
bRet = releaseProfile(pProfile);
@@ -865,10 +867,10 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C
}
else
{
- CHAR szFileName[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, szFileName, MAX_PATH, NULL, NULL);
- n = GetPrivateProfileString(pszSection, NULL, NULL, pszBuffer, MaxLen, szFileName);
+ WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ n = GetPrivateProfileString(pszSection, NULL, NULL, pszBuffer, MaxLen, aFileName);
}
releaseProfile(pProfile);
@@ -884,9 +886,9 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C
sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName)
{
sal_Bool bFailed;
- sal_Unicode wcsFile[MAX_PATH];
- sal_Unicode wcsPath[MAX_PATH];
- sal_uInt32 nFileLen;
+ ::osl::LongPathBuffer< sal_Unicode > aFile( MAX_LONG_PATH );
+ ::osl::LongPathBuffer< sal_Unicode > aPath( MAX_LONG_PATH );
+ sal_uInt32 nFileLen = 0;
sal_uInt32 nPathLen = 0;
rtl_uString * strTmp = NULL;
@@ -895,19 +897,19 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
/* build file name */
if (strName && strName->length)
{
- if(strName->length >= MAX_PATH)
+ if( ::sal::static_int_cast< sal_uInt32 >( strName->length ) >= aFile.getBufSizeInSymbols() )
return sal_False;
- wcscpy(wcsFile, strName->buffer);
+ wcscpy( aFile, strName->buffer);
nFileLen = strName->length;
- if (rtl_ustr_indexOfChar( wcsFile, L'.' ) == -1)
+ if (rtl_ustr_indexOfChar( aFile, L'.' ) == -1)
{
- if (nFileLen + wcslen(STR_INI_EXTENSION) >= MAX_PATH)
+ if (nFileLen + wcslen(STR_INI_EXTENSION) >= aFile.getBufSizeInSymbols())
return sal_False;
/* add default extension */
- wcscpy(wcsFile + nFileLen, STR_INI_EXTENSION);
+ wcscpy( aFile + nFileLen, STR_INI_EXTENSION);
nFileLen += wcslen(STR_INI_EXTENSION);
}
}
@@ -934,22 +936,22 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if ((nPos = rtl_ustr_lastIndexOfChar( pProgName, L'.' )) != -1 )
nLen -= 4;
- if ((nFileLen = nLen - nOffset) >= MAX_PATH)
+ if ((nFileLen = nLen - nOffset) >= aFile.getBufSizeInSymbols())
return sal_False;
- wcsncpy(wcsFile, pProgName + nOffset, nFileLen);
+ wcsncpy(aFile, pProgName + nOffset, nFileLen);
- if (nFileLen + wcslen(STR_INI_EXTENSION) >= MAX_PATH)
+ if (nFileLen + wcslen(STR_INI_EXTENSION) >= aFile.getBufSizeInSymbols())
return sal_False;
/* add default extension */
- wcscpy(wcsFile + nFileLen, STR_INI_EXTENSION);
+ wcscpy(aFile + nFileLen, STR_INI_EXTENSION);
nFileLen += wcslen(STR_INI_EXTENSION);
rtl_uString_release( strProgName );
}
- if (wcsFile[0] == 0)
+ if (aFile[0] == 0)
return sal_False;
/* build directory path */
@@ -969,10 +971,10 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if (bFailed) return (sal_False);
- if (strHome->length >= MAX_PATH)
+ if ( ::sal::static_int_cast< sal_uInt32 >( strHome->length ) >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy( wcsPath, strHome->buffer);
+ wcscpy( aPath, strHome->buffer);
nPathLen = strHome->length;
if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METAHOME))
@@ -980,10 +982,10 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
pPath += RTL_CONSTASCII_LENGTH(STR_INI_METAHOME);
nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METAHOME);
- if (nLen + nPathLen >= MAX_PATH)
+ if (nLen + nPathLen >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy(wcsPath + nPathLen, pPath);
+ wcscpy(aPath + nPathLen, pPath);
nPathLen += nLen;
}
@@ -1001,10 +1003,10 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
if (bFailed) return (sal_False);
- if (strConfig->length >= MAX_PATH)
+ if ( ::sal::static_int_cast< sal_uInt32 >( strConfig->length ) >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy( wcsPath, strConfig->buffer);
+ wcscpy( aPath, strConfig->buffer);
nPathLen = strConfig->length;
if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METACFG))
@@ -1012,10 +1014,10 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
pPath += RTL_CONSTASCII_LENGTH(STR_INI_METACFG);
nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METACFG);
- if (nLen + nPathLen >= MAX_PATH)
+ if (nLen + nPathLen >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy(wcsPath + nPathLen, pPath);
+ wcscpy(aPath + nPathLen, pPath);
nPathLen += nLen;
}
@@ -1025,7 +1027,7 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METASYS), STR_INI_METASYS) == 0) &&
((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METASYS)] == '/')))
{
- if (((nPathLen = GetWindowsDirectoryW(wcsPath, MAX_PATH)) == 0) || (nPathLen >= MAX_PATH))
+ if (((nPathLen = GetWindowsDirectoryW(aPath, aPath.getBufSizeInSymbols())) == 0) || (nPathLen >= aPath.getBufSizeInSymbols()))
return (sal_False);
if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METASYS))
@@ -1033,10 +1035,10 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
pPath += RTL_CONSTASCII_LENGTH(STR_INI_METASYS);
nLen -= RTL_CONSTASCII_LENGTH(STR_INI_METASYS);
- if (nLen + nPathLen >= MAX_PATH)
+ if (nLen + nPathLen >= aPath.getBufSizeInSymbols())
return sal_False;
- wcscpy(wcsPath + nPathLen, pPath);
+ wcscpy(aPath + nPathLen, pPath);
nPathLen += nLen;
}
}
@@ -1045,16 +1047,16 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METAINS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAINS)] == '/') ||
(pPath[RTL_CONSTASCII_LENGTH(STR_INI_METAINS)] == '"') ) )
{
- if (! lookupProfile(pPath + RTL_CONSTASCII_LENGTH(STR_INI_METAINS), wcsFile, wcsPath))
+ if (! lookupProfile(pPath + RTL_CONSTASCII_LENGTH(STR_INI_METAINS), aFile, aPath))
return (sal_False);
- nPathLen = wcslen(wcsPath);
+ nPathLen = wcslen(aPath);
}
- else if(nLen < MAX_PATH)
+ else if( ::sal::static_int_cast< sal_uInt32 >( nLen ) < aPath.getBufSizeInSymbols())
{
- wcscpy(wcsPath, pPath);
- nPathLen = wcslen(wcsPath);
+ wcscpy(aPath, pPath);
+ nPathLen = wcslen(aPath);
}
else
return sal_False;
@@ -1068,28 +1070,28 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
osl_freeSecurityHandle(security);
if (bFailed) return (sal_False);
- if (strConfigDir->length >= MAX_PATH)
+ if ( ::sal::static_int_cast< sal_uInt32 >( strConfigDir->length ) >= aPath.getBufSizeInSymbols() )
return sal_False;
- wcscpy(wcsPath, strConfigDir->buffer);
+ wcscpy(aPath, strConfigDir->buffer);
nPathLen = strConfigDir->length;
}
- if (nPathLen && (wcsPath[nPathLen - 1] != L'/') && (wcsPath[nPathLen - 1] != L'\\'))
+ if (nPathLen && (aPath[nPathLen - 1] != L'/') && (aPath[nPathLen - 1] != L'\\'))
{
- wcsPath[nPathLen++] = L'\\';
- wcsPath[nPathLen] = 0;
+ aPath[nPathLen++] = L'\\';
+ aPath[nPathLen] = 0;
}
- if (nPathLen + nFileLen >= MAX_PATH)
+ if (nPathLen + nFileLen >= aPath.getBufSizeInSymbols())
return sal_False;
/* append file name */
- wcscpy(wcsPath + nPathLen, wcsFile);
+ wcscpy(aPath + nPathLen, aFile);
nPathLen += nFileLen;
/* copy filename */
- rtl_uString_newFromStr_WithLength(&strTmp, wcsPath, nPathLen);
+ rtl_uString_newFromStr_WithLength(&strTmp, aPath, nPathLen);
nError = osl_getFileURLFromSystemPath(strTmp, strProfileName);
rtl_uString_release(strTmp);
@@ -1137,10 +1139,10 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff
}
else
{
- CHAR szFileName[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aFileName( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, szFileName, MAX_PATH, NULL, NULL);
- n = GetPrivateProfileSectionNames(pszBuffer, MaxLen, szFileName);
+ WideCharToMultiByte(CP_ACP,0, pProfile->m_strFileName->buffer, -1, aFileName, aFileName.getBufSizeInSymbols(), NULL, NULL);
+ n = GetPrivateProfileSectionNames(pszBuffer, MaxLen, aFileName);
}
releaseProfile(pProfile);
@@ -1151,35 +1153,6 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*****************************************************************************/
/* Static Module Functions */
/*****************************************************************************/
@@ -1284,7 +1257,7 @@ static sal_Bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode)
static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption ProfileFlags )
{
- osl_TFile* pFile = calloc(1, sizeof(osl_TFile));
+ osl_TFile* pFile = reinterpret_cast< osl_TFile*>( calloc( 1, sizeof(osl_TFile) ) );
sal_Bool bWriteable = sal_False;
/* if ( ProfileFlags & ( osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE | osl_Profile_READWRITE ) )*/
@@ -2223,7 +2196,7 @@ static osl_TProfileImpl* acquireProfile(oslProfile Profile, sal_Bool bWriteable)
- if ((pProfile = osl_openProfile(NULL, PFlags)) != NULL )
+ if ( ( pProfile = (osl_TProfileImpl*)osl_openProfile( NULL, PFlags ) ) != NULL )
{
pProfile->m_Flags |= FLG_AUTOOPEN;
}
@@ -2330,7 +2303,8 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
sal_Char Buffer[4096] = "";
sal_Char Product[132] = "";
- WCHAR wcsPath[MAX_PATH] = L"";
+ ::osl::LongPathBuffer< sal_Unicode > aPath( MAX_LONG_PATH );
+ aPath[0] = 0;
DWORD dwPathLen = 0;
if (*strPath == L'"')
@@ -2364,7 +2338,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
rtl_uString * strSVFallback = NULL;
rtl_uString * strSVLocation = NULL;
rtl_uString * strSVName = NULL;
- sal_Char Dir[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aDir( MAX_LONG_PATH );
oslProfile hProfile;
rtl_uString_newFromAscii(&strSVFallback, SVERSION_FALLBACK);
@@ -2390,11 +2364,11 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
&& (stricmp(Product, pChr) < 0))
{
osl_readProfileString(
- hProfile, SVERSION_SECTION, pChr, Dir,
- sizeof(Dir), "");
+ hProfile, SVERSION_SECTION, pChr, aDir,
+ aDir.getBufSizeInSymbols(), "");
/* check for existence of path */
- if (access(Dir, 0) >= 0)
+ if (access(aDir, 0) >= 0)
strcpy(Product, pChr);
}
}
@@ -2425,11 +2399,11 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
&& (stricmp(Product, pChr) < 0))
{
osl_readProfileString(
- hProfile, SVERSION_SECTION, pChr, Dir,
- sizeof(Dir), "");
+ hProfile, SVERSION_SECTION, pChr, aDir,
+ aDir.getBufSizeInSymbols(), "");
/* check for existence of path */
- if (access(Dir, 0) >= 0)
+ if (access(aDir, 0) >= 0)
strcpy(Product, pChr);
}
}
@@ -2469,31 +2443,31 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
((nEnd = rtl_ustr_indexOfChar(pCommandArg + nStart + 1, L']')) != -1))
{
dwPathLen = nEnd;
- wcsncpy(wcsPath, pCommandArg + nStart + 1, dwPathLen );
- wcsPath[dwPathLen] = 0;
+ wcsncpy(aPath, pCommandArg + nStart + 1, dwPathLen );
+ aPath[dwPathLen] = 0;
/* build full path */
- if ((wcsPath[dwPathLen - 1] != L'/') && (wcsPath[dwPathLen - 1] != L'\\'))
+ if ((aPath[dwPathLen - 1] != L'/') && (aPath[dwPathLen - 1] != L'\\'))
{
- wcscpy(wcsPath + dwPathLen++, L"/");
+ wcscpy(aPath + dwPathLen++, L"/");
}
if (*strPath)
{
- wcscpy(wcsPath + dwPathLen, strPath);
+ wcscpy(aPath + dwPathLen, strPath);
dwPathLen += wcslen(strPath);
}
else
{
- CHAR szPath[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
int n;
- if ((n = WideCharToMultiByte(CP_ACP,0, wcsPath, -1, szPath, MAX_PATH, NULL, NULL)) > 0)
+ if ((n = WideCharToMultiByte(CP_ACP,0, aPath, -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL)) > 0)
{
- strcpy(szPath + n, SVERSION_USER);
- if (access(szPath, 0) >= 0)
+ strcpy(aTmpPath + n, SVERSION_USER);
+ if (access(aTmpPath, 0) >= 0)
{
- dwPathLen += MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, wcsPath + dwPathLen, MAX_PATH - dwPathLen );
+ dwPathLen += MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, aPath + dwPathLen, aPath.getBufSizeInSymbols() - dwPathLen );
}
}
}
@@ -2533,16 +2507,16 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
}
else
{
- wcsncpy(wcsPath, strExecutable->buffer, nPos );
- wcsPath[nPos] = 0;
+ wcsncpy(aPath, strExecutable->buffer, nPos );
+ aPath[nPos] = 0;
dwPathLen = nPos;
}
}
else
{
- wcsncpy(wcsPath, strExecutable->buffer, nPos );
+ wcsncpy(aPath, strExecutable->buffer, nPos );
dwPathLen = nPos;
- wcsPath[dwPathLen] = 0;
+ aPath[dwPathLen] = 0;
}
/* if we have no product identification use the executable file name */
@@ -2558,30 +2532,30 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
rtl_uString_release(strExecutable);
/* remember last subdir */
- nPos = rtl_ustr_lastIndexOfChar(wcsPath, L'\\');
+ nPos = rtl_ustr_lastIndexOfChar(aPath, L'\\');
- wcscpy(wcsPath + dwPathLen++, L"\\");
+ wcscpy(aPath + dwPathLen++, L"\\");
if (*strPath)
{
- wcscpy(wcsPath + dwPathLen, strPath);
+ wcscpy(aPath + dwPathLen, strPath);
dwPathLen += wcslen(strPath);
}
{
- CHAR szPath[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, wcsPath, -1, szPath, MAX_PATH, NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, aPath, -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL);
/* if file not exists, remove any specified subdirectories
like "bin" or "program" */
- if (((access(szPath, 0) < 0) && (nPos != -1)) || (*strPath == 0))
+ if (((access(aTmpPath, 0) < 0) && (nPos != -1)) || (*strPath == 0))
{
static sal_Char *SubDirs[] = SVERSION_DIRS;
int i = 0;
- pStr = szPath + nPos;
+ pStr = aTmpPath + nPos;
for (i = 0; i < (sizeof(SubDirs) / sizeof(SubDirs[0])); i++)
if (strnicmp(pStr + 1, SubDirs[i], strlen(SubDirs[i])) == 0)
@@ -2589,18 +2563,18 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
if ( *strPath == 0)
{
strcpy(pStr + 1,SVERSION_USER);
- if ( access(szPath, 0) < 0 )
+ if ( access(aTmpPath, 0) < 0 )
{
*(pStr+1)='\0';
}
else
{
- dwPathLen = nPos + MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, wcsPath + nPos + 1, MAX_PATH - (nPos + 1) );
+ dwPathLen = nPos + MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, aPath + nPos + 1, aPath.getBufSizeInSymbols() - (nPos + 1) );
}
}
else
{
- wcscpy(wcsPath + nPos + 1, strPath);
+ wcscpy(aPath + nPos + 1, strPath);
dwPathLen = nPos + 1 + wcslen(strPath);
}
@@ -2609,20 +2583,20 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
}
}
- if ((wcsPath[dwPathLen - 1] != L'/') && (wcsPath[dwPathLen - 1] != L'\\'))
+ if ((aPath[dwPathLen - 1] != L'/') && (aPath[dwPathLen - 1] != L'\\'))
{
- wcsPath[dwPathLen++] = L'\\';
- wcsPath[dwPathLen] = 0;
+ aPath[dwPathLen++] = L'\\';
+ aPath[dwPathLen] = 0;
}
- wcscpy(wcsPath + dwPathLen, strFile);
+ wcscpy(aPath + dwPathLen, strFile);
{
- CHAR szPath[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
- WideCharToMultiByte(CP_ACP,0, wcsPath, -1, szPath, MAX_PATH, NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0, aPath, -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), NULL, NULL);
- if ((access(szPath, 0) < 0) && (strlen(Product) > 0))
+ if ((access(aTmpPath, 0) < 0) && (strlen(Product) > 0))
{
rtl_uString * strSVFallback = NULL;
rtl_uString * strSVProfile = NULL;
@@ -2671,38 +2645,38 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
if (strlen(Buffer) > 0)
{
dwPathLen = MultiByteToWideChar(
- CP_ACP, 0, Buffer, -1, wcsPath, MAX_PATH );
+ CP_ACP, 0, Buffer, -1, aPath, aPath.getBufSizeInSymbols() );
dwPathLen -=1;
/* build full path */
- if ((wcsPath[dwPathLen - 1] != L'/')
- && (wcsPath[dwPathLen - 1] != L'\\'))
+ if ((aPath[dwPathLen - 1] != L'/')
+ && (aPath[dwPathLen - 1] != L'\\'))
{
- wcscpy(wcsPath + dwPathLen++, L"\\");
+ wcscpy(aPath + dwPathLen++, L"\\");
}
if (*strPath)
{
- wcscpy(wcsPath + dwPathLen, strPath);
+ wcscpy(aPath + dwPathLen, strPath);
dwPathLen += wcslen(strPath);
}
else
{
- CHAR szPath[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH );
int n;
if ((n = WideCharToMultiByte(
- CP_ACP,0, wcsPath, -1, szPath,
- MAX_PATH, NULL, NULL))
+ CP_ACP,0, aPath, -1, aTmpPath,
+ aTmpPath.getBufSizeInSymbols(), NULL, NULL))
> 0)
{
- strcpy(szPath + n, SVERSION_USER);
- if (access(szPath, 0) >= 0)
+ strcpy(aTmpPath + n, SVERSION_USER);
+ if (access(aTmpPath, 0) >= 0)
{
dwPathLen += MultiByteToWideChar(
CP_ACP, 0, SVERSION_USER, -1,
- wcsPath + dwPathLen,
- MAX_PATH - dwPathLen );
+ aPath + dwPathLen,
+ aPath.getBufSizeInSymbols() - dwPathLen );
}
}
}
@@ -2718,11 +2692,11 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
}
}
- wcsPath[dwPathLen] = 0;
+ aPath[dwPathLen] = 0;
}
/* copy filename */
- wcscpy(strProfile, wcsPath);
+ wcscpy(strProfile, aPath);
return sal_True;
}
diff --git a/sal/osl/w32/signal.c b/sal/osl/w32/signal.cxx
index 3e1f6d8105b7..f893f7520d40 100644
--- a/sal/osl/w32/signal.c
+++ b/sal/osl/w32/signal.cxx
@@ -1,34 +1,37 @@
/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
/* system headers */
#include "system.h"
#include <tchar.h>
+#include "file_url.h"
+#include "path_helper.hxx"
+
#include <osl/diagnose.h>
#include <osl/mutex.h>
#include <osl/signal.h>
@@ -112,7 +115,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
BOOL fSuccess = FALSE;
BOOL fAutoReport = FALSE;
TCHAR szBuffer[1024];
- TCHAR szPath[MAX_PATH];
+ ::osl::LongPathBuffer< sal_Char > aPath( MAX_LONG_PATH );
LPTSTR lpFilePart;
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
@@ -164,11 +167,11 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
value_len = quote - value;
}
- lpVariable = _alloca( variable_len + 1 );
+ lpVariable = reinterpret_cast< CHAR* >( _alloca( variable_len + 1 ) );
memcpy( lpVariable, variable, variable_len );
lpVariable[variable_len] = 0;
- lpValue = _alloca( value_len + 1);
+ lpValue = reinterpret_cast< CHAR* >( _alloca( value_len + 1) );
memcpy( lpValue, value, value_len );
lpValue[value_len] = 0;
@@ -177,7 +180,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
}
}
- if ( SearchPath( NULL, TEXT("crashrep.exe"), NULL, MAX_PATH, szPath, &lpFilePart ) )
+ if ( SearchPath( NULL, TEXT( "crashrep.exe" ), NULL, aPath.getBufSizeInSymbols(), aPath, &lpFilePart ) )
{
ZeroMemory( &StartupInfo, sizeof(StartupInfo) );
StartupInfo.cb = sizeof(StartupInfo.cb);
@@ -185,7 +188,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP )
sntprintf( szBuffer, elementsof(szBuffer),
_T("%s -p %u -excp 0x%p -t %u%s"),
- szPath,
+ aPath,
GetCurrentProcessId(),
lpEP,
GetCurrentThreadId(),
@@ -314,6 +317,8 @@ static long WINAPI SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
SetErrorMode(SEM_NOGPFAULTERRORBOX);
exit(255);
break;
+ default:
+ break;
}
return (EXCEPTION_CONTINUE_EXECUTION);
@@ -331,7 +336,7 @@ oslSignalHandler SAL_CALL osl_addSignalHandler(oslSignalHandlerFunction Handler,
if (! bInitSignal)
bInitSignal = InitSignal();
- pHandler = calloc(1, sizeof(oslSignalHandlerImpl));
+ pHandler = reinterpret_cast< oslSignalHandlerImpl* >( calloc( 1, sizeof(oslSignalHandlerImpl) ) );
if (pHandler != NULL)
{
diff --git a/sal/osl/w32/system.h b/sal/osl/w32/system.h
index cc3ebd47d574..1bd86994e6ce 100644
--- a/sal/osl/w32/system.h
+++ b/sal/osl/w32/system.h
@@ -105,10 +105,22 @@
#endif // #ifdef GCC
#ifdef _DLL_
+
+#ifdef __cplusplus
+ extern "C" DWORD g_dwPlatformId;
+#else
extern DWORD g_dwPlatformId;
+#endif // #ifdef __cplusplus
+
#define IS_NT (g_dwPlatformId == VER_PLATFORM_WIN32_NT)
#else
+
+#ifdef __cplusplus
+ extern "C" DWORD GetPlatformId(void);
+#else
extern DWORD GetPlatformId(void);
+#endif // #ifdef __cplusplus
+
#define IS_NT (GetPlatformId() == VER_PLATFORM_WIN32_NT)
#endif // #ifdef _DLL_
diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx
index f5b7f32fea8f..4bf136b6b0e0 100644
--- a/sal/osl/w32/tempfile.cxx
+++ b/sal/osl/w32/tempfile.cxx
@@ -34,6 +34,7 @@
#include "file_error.h"
#include "file_url.h"
+#include "path_helper.hxx"
#include "osl/diagnose.h"
@@ -212,7 +213,7 @@ oslFileError SAL_CALL osl_createTempFile(
if (osl_File_E_None != osl_error)
return osl_error;
- /* allocate enough space on the stack */
+ /* allocate enough space on the stack, the file name can not be longer than MAX_PATH */
STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) + MAX_PATH));
if (tmp_name)
@@ -238,25 +239,21 @@ oslFileError SAL_CALL osl_createTempFile(
//#############################################
oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir)
{
- WCHAR szBuffer[MAX_PATH];
- LPWSTR lpBuffer = szBuffer;
- DWORD nBufferLength = ELEMENTS_OF_ARRAY(szBuffer) - 1;
+ ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
+ LPWSTR lpBuffer = aBuffer;
+ DWORD nBufferLength = aBuffer.getBufSizeInSymbols() - 1;
DWORD nLength;
oslFileError error;
- do
+ nLength = GetTempPathW( aBuffer.getBufSizeInSymbols(), lpBuffer );
+
+ if ( nLength > nBufferLength )
{
- nLength = GetTempPathW( ELEMENTS_OF_ARRAY(szBuffer), lpBuffer );
- if ( nLength > nBufferLength )
- {
- nLength++;
- lpBuffer = reinterpret_cast<WCHAR*>(alloca( sizeof(WCHAR) * nLength ));
- nBufferLength = nLength - 1;
- }
- } while ( nLength > nBufferLength );
-
- if ( nLength )
+ // the provided path has invalid length
+ error = osl_File_E_NOENT;
+ }
+ else if ( nLength )
{
rtl_uString *ustrTempPath = NULL;
@@ -274,3 +271,4 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir)
return error;
}
+
diff --git a/sal/rtl/source/ustring.c b/sal/rtl/source/ustring.c
index 1d3e046cc830..b0bdd2d98e73 100644
--- a/sal/rtl/source/ustring.c
+++ b/sal/rtl/source/ustring.c
@@ -555,7 +555,12 @@ static void rtl_string2UString_status( rtl_uString** ppThis,
"rtl_string2UString_status() - Wrong TextEncoding" );
if ( !nLen )
+ {
rtl_uString_new( ppThis );
+ if (pInfo != NULL) {
+ *pInfo = 0;
+ }
+ }
else
{
if ( *ppThis )
@@ -586,6 +591,9 @@ static void rtl_string2UString_status( rtl_uString** ppThis,
nLen--;
}
while ( nLen );
+ if (pInfo != NULL) {
+ *pInfo = 0;
+ }
}
else
{