1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0022484: UNICODE characters support

Initial UNICODE (UFT-8) characters support for OCCT file operations

Fix for compilation errors and fix for StepFile (avoid objects in pure c code)

Fixes for set unicode symbols to OCAF and visualization
This commit is contained in:
pdn 2014-10-02 15:39:25 +04:00 committed by bugmaster
parent d3dfddaebc
commit d9ff84e8ea
34 changed files with 617 additions and 510 deletions

View File

@ -97,6 +97,17 @@ is
PropagateDocumentVersion(me: mutable; theVersion : Integer from Standard)
is virtual protected;
CheckDocumentVersion(me: mutable;
theFileVersion : Integer from Standard;
theCurVersion : Integer from Standard)
returns Boolean from Standard
is virtual protected;
---Purpose: Check a file version(in which file was written) with a current version.
-- Redefining this method is a chance for application to read files
-- written by newer applications.
-- The default implementation: if the version of the file is greater than the
-- current or lesser than 2, then return false, else true
WriteMessage(me: mutable; theMessage : ExtendedString from TCollection)
is protected;
---Purpose: write theMessage to the MessageDriver of the

View File

@ -103,7 +103,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read
return;
}
TCollection_AsciiString aFileName (theFileName,'?');
TCollection_AsciiString aFileName (theFileName);
// 1. Read the information section
Handle(Storage_HeaderData) aHeaderData;
@ -124,12 +124,12 @@ void BinLDrivers_DocumentRetrievalDriver::Read
Standard_Integer aFileVer = aHeaderData->StorageVersion().IntegerValue();
Standard_Integer aCurrVer = BinLDrivers::StorageVersion().IntegerValue();
// maintain one-way compatibility starting from version 2+
if (aFileVer < 2 || aFileVer > aCurrVer) {
if (!CheckDocumentVersion(aFileVer, aCurrVer)) {
myReaderStatus = PCDM_RS_NoVersion;
// file was written with another version
WriteMessage (aMethStr + "error: wrong file version: " +
aHeaderData->StorageVersion() + " while current is " +
BinLDrivers::StorageVersion());
myReaderStatus = PCDM_RS_NoVersion;
return;
}
@ -179,8 +179,8 @@ void BinLDrivers_DocumentRetrievalDriver::Read
}
// Open the file stream
#ifdef WNT
ifstream anIS (aFileName.ToCString(), ios::in | ios::binary);
#ifdef _WIN32
ifstream anIS ((const wchar_t*) theFileName.ToExtString(), ios::in | ios::binary);
#else
ifstream anIS (aFileName.ToCString());
#endif
@ -511,3 +511,19 @@ void BinLDrivers_DocumentRetrievalDriver::PropagateDocumentVersion(const Standar
{
BinMDataStd::SetDocumentVersion(theDocVersion);
}
//=======================================================================
//function : CheckDocumentVersion
//purpose :
//=======================================================================
Standard_Boolean BinLDrivers_DocumentRetrievalDriver::CheckDocumentVersion(
const Standard_Integer theFileVersion,
const Standard_Integer theCurVersion)
{
if (theFileVersion < 2 || theFileVersion > theCurVersion) {
// file was written with another version
return Standard_False;
}
return Standard_True;
}

View File

@ -86,7 +86,7 @@ void BinLDrivers_DocumentStorageDriver::Write
}
else {
// Open the file
TCollection_AsciiString aFileName (theFileName,'?');
TCollection_AsciiString aFileName (theFileName);
// First pass: collect empty labels, assign IDs to the types
if (myDrivers.IsNull())
@ -103,7 +103,9 @@ void BinLDrivers_DocumentStorageDriver::Write
return;
}
#if !defined(IRIX) // 10.10.2005
#if defined(_WIN32)
ofstream anOS ((const wchar_t*) theFileName.ToExtString(), ios::in | ios::binary | ios::ate);
#elif !defined(IRIX) // 10.10.2005
ofstream anOS (aFileName.ToCString(), ios::in | ios::binary | ios::ate);
#else
ofstream anOS (aFileName.ToCString(), ios::ate);

View File

@ -177,7 +177,7 @@ static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di,
if (!DDF::GetDF(arg[1],DF)) return 1;
TDF_Label L;
DDF::AddLabel(DF, arg[2], L);
TDataStd_Comment::Set(L,arg[3]);
TDataStd_Comment::Set(L,TCollection_ExtendedString(arg[3],Standard_True));
return 0;
}
di << "DDataStd_SetComment : Error" << "\n";
@ -270,7 +270,7 @@ static Standard_Integer DDataStd_GetComment (Draw_Interpretor& di,
Handle(TDataStd_Comment) A;
if (!DDF::Find(DF,arg[2],TDataStd_Comment::GetID(),A)) return 1;
TCollection_AsciiString s(A->Get(),'?');
di << s.ToCString();
di << A->Get().ToExtString();
return 0;
}
di << "DDataStd_GetComment : Error" << "\n";

View File

@ -49,48 +49,6 @@
#define TCL_USES_UTF8
#endif
//
// Auxiliary tool to convert strings in command arguments from UTF-8
// (Tcl internal encoding since Tcl 8.1) to system local encoding,
// normally extended Ascii as expected by OCC commands
//
class TclUTFToLocalStringSentry {
public:
#ifdef TCL_USES_UTF8
TclUTFToLocalStringSentry (int argc, const char **argv) :
nb(0),
TclArgv(new Tcl_DString[argc]),
Argv(new char*[argc])
{
for (; nb < argc; nb++ ) {
Tcl_UtfToExternalDString ( NULL, argv[nb], -1, &TclArgv[nb] );
Argv[nb] = Tcl_DStringValue ( &TclArgv[nb] );
}
}
~TclUTFToLocalStringSentry ()
{
delete[] Argv;
while ( nb-- >0 ) Tcl_DStringFree ( &TclArgv[nb] );
delete[] TclArgv;
}
#else
TclUTFToLocalStringSentry (int, const char **argv) :
nb(0),
TclArgv(NULL),
Argv((char**)argv)
{}
#endif
const char **GetArgv () const { return (const char **)Argv; }
private:
int nb;
Tcl_DString *TclArgv;
char **Argv;
};
// logging helpers
namespace {
void dumpArgs (Standard_OStream& os, int argc, const char *argv[])
@ -217,10 +175,9 @@ static Standard_Integer CommandCmd
// get exception if control-break has been pressed
OSD::ControlBreak();
// OCC63: Convert strings from UTF-8 to local encoding, normally expected by OCC commands
TclUTFToLocalStringSentry anArgs ( argc, (const char**)argv );
// OCC680: Transfer UTF-8 directly to OCC commands without locale usage
Standard_Integer fres = aCallback->Invoke ( di, argc, anArgs.GetArgv() );
Standard_Integer fres = aCallback->Invoke ( di, argc, argv /*anArgs.GetArgv()*/ );
if (fres != 0)
code = TCL_ERROR;
}

View File

@ -81,6 +81,18 @@ Storage_Error FSD_BinaryFile::Open(const TCollection_AsciiString& aName,const St
SetName(aName);
if (OpenMode() == Storage_VSNone) {
#ifdef _WIN32
TCollection_ExtendedString aWName(aName);
if (aMode == Storage_VSRead) {
myStream = _wfopen((const wchar_t*)aWName.ToExtString(),L"rb");
}
else if (aMode == Storage_VSWrite) {
myStream = _wfopen((const wchar_t*)aWName.ToExtString(),L"wb");
}
else if (aMode == Storage_VSReadWrite) {
myStream = _wfopen((const wchar_t*)aWName.ToExtString(),L"w+b");
}
#else
if (aMode == Storage_VSRead) {
myStream = fopen(aName.ToCString(),"rb");
}
@ -90,6 +102,7 @@ Storage_Error FSD_BinaryFile::Open(const TCollection_AsciiString& aName,const St
else if (aMode == Storage_VSReadWrite) {
myStream = fopen(aName.ToCString(),"w+b");
}
#endif
if (myStream == 0L) {
result = Storage_VSOpenError;

View File

@ -87,7 +87,18 @@ Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName,const Stora
if (OpenMode() == Storage_VSNone) {
#if !defined(IRIX) && !defined(DECOSF1)
#if defined(_WNT32)
TCollection_ExtendedString aWName(aName);
if (aMode == Storage_VSRead) {
myStream.open((const wchar_t*)aWName.ToExtString(),ios::in|ios::binary); // ios::nocreate is not portable
}
else if (aMode == Storage_VSWrite) {
myStream.open((const wchar_t*)aWName.ToExtString(),ios::out|ios::binary);
}
else if (aMode == Storage_VSReadWrite) {
myStream.open((const wchar_t*)aWName.ToExtString(),ios::in|ios::out|ios::binary);
}
#elif !defined(IRIX) && !defined(DECOSF1)
if (aMode == Storage_VSRead) {
myStream.open(aName.ToCString(),ios::in|ios::binary); // ios::nocreate is not portable
}

View File

@ -72,6 +72,18 @@ Storage_Error FSD_File::Open(const TCollection_AsciiString& aName,const Storage_
SetName(aName);
if (OpenMode() == Storage_VSNone) {
#ifdef _WIN32
TCollection_ExtendedString aWName(aName);
if (aMode == Storage_VSRead) {
myStream.open( (const wchar_t*) aWName.ToExtString(),ios::in); // ios::nocreate is not portable
}
else if (aMode == Storage_VSWrite) {
myStream.open( (const wchar_t*) aWName.ToExtString(),ios::out);
}
else if (aMode == Storage_VSReadWrite) {
myStream.open( (const wchar_t*) aWName.ToExtString(),ios::in|ios::out);
#else
if (aMode == Storage_VSRead) {
myStream.open(aName.ToCString(),ios::in); // ios::nocreate is not portable
}
@ -80,6 +92,7 @@ Storage_Error FSD_File::Open(const TCollection_AsciiString& aName,const Storage_
}
else if (aMode == Storage_VSReadWrite) {
myStream.open(aName.ToCString(),ios::in|ios::out);
#endif
}
if (myStream.fail()) {

View File

@ -23,6 +23,7 @@
#include <LDOM_XmlReader.hxx>
#include <LDOM_BasicText.hxx>
#include <LDOM_CharReference.hxx>
#include <TCollection_ExtendedString.hxx>
#include <fcntl.h>
#ifdef WNT
@ -134,7 +135,12 @@ Standard_Boolean LDOMParser::parse (const char * const aFileName)
myError.Clear ();
// Open the file
#ifdef _WIN32
TCollection_ExtendedString aFileNameW(aFileName, Standard_True);
int aFile = _wopen ((const wchar_t*) aFileNameW.ToExtString(), O_RDONLY);
#else
int aFile = open (aFileName, O_RDONLY);
#endif
if (aFile < 0) {
myError = "Fatal XML error: Cannot open XML file";
return Standard_True;

View File

@ -166,7 +166,7 @@ Message_Msg& Message_Msg::Arg (const Standard_CString theString)
// print string according to format
char * sStringBuffer = new char [Max ((Standard_Integer)strlen(theString)+1, 1024)];
Sprintf (sStringBuffer, aFormat.ToCString(), theString);
TCollection_ExtendedString aStr ( sStringBuffer );
TCollection_ExtendedString aStr ( sStringBuffer, Standard_True );
delete [] sStringBuffer;
sStringBuffer = 0;

View File

@ -214,7 +214,13 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName)
if (theFileName == NULL || * theFileName == '\0') return Standard_False;
// Open the file
#ifdef _WIN32
// file name is treated as UTF-8 string
TCollection_ExtendedString aFileNameW(theFileName, Standard_True);
FILE *anMsgFile = _wfopen ((const wchar_t*)aFileNameW.ToExtString(), L"rb");
#else
FILE *anMsgFile = fopen (theFileName, "rb");
#endif
if (!anMsgFile) return Standard_False;
// Read the file into memory

View File

@ -85,6 +85,7 @@ TCollection_AsciiString aString (name);
#include <OSD_Directory.hxx>
#include <OSD_Protection.hxx>
#include <Standard_ProgramError.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_WNT_1.hxx>
@ -122,8 +123,8 @@ void OSD_Directory :: Build (const OSD_Protection& Protect ) {
Standard_ProgramError :: Raise (
TEXT( "OSD_Directory :: Build (): incorrect call - no directory name" )
);
if ( Exists () || CreateDirectory ( dirName.ToCString (), NULL ) )
TCollection_ExtendedString dirNameW(dirName);
if ( Exists () || CreateDirectoryW ( (const wchar_t*) dirNameW.ToExtString (), NULL ) )
SetProtection ( Protect );

View File

@ -179,8 +179,9 @@ Standard_Integer OSD_DirectoryIterator::Error()const{
#include <windows.h>
#include <OSD_DirectoryIterator.ixx>
#include <TCollection_ExtendedString.hxx>
#define _FD ( ( PWIN32_FIND_DATA )myData )
#define _FD ( ( PWIN32_FIND_DATAW )myData )
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
@ -194,7 +195,7 @@ OSD_DirectoryIterator :: OSD_DirectoryIterator (
where.SystemName ( myPlace );
if ( myPlace.Length () == 0 ) myPlace = TEXT( "." );
if ( myPlace.Length () == 0 ) myPlace = ".";
myMask = Mask;
myData = NULL;
@ -215,13 +216,15 @@ Standard_Boolean OSD_DirectoryIterator :: More () {
if ( myHandle == INVALID_HANDLE_VALUE ) {
TCollection_AsciiString wc = myPlace + TEXT( "/" ) + myMask;
TCollection_AsciiString wc = myPlace + "/" + myMask;
myData = HeapAlloc (
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, sizeof ( WIN32_FIND_DATA )
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, sizeof ( WIN32_FIND_DATAW )
);
myHandle = FindFirstFile (wc.ToCString (), (PWIN32_FIND_DATA)myData);
// make wchar_t string from UTF-8
TCollection_ExtendedString wcW(wc);
myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
if ( myHandle == INVALID_HANDLE_VALUE )
@ -255,7 +258,7 @@ void OSD_DirectoryIterator :: Next () {
do {
if ( !FindNextFile ( ( HANDLE )myHandle, _FD ) ) {
if ( !FindNextFileW ( ( HANDLE )myHandle, _FD ) ) {
myFlag = Standard_False;
@ -273,7 +276,10 @@ void OSD_DirectoryIterator :: Next () {
OSD_Directory OSD_DirectoryIterator :: Values () {
TheIterator.SetPath ( OSD_Path ( _FD -> cFileName ) );
// make UTF-8 string
TCollection_AsciiString aFileName
(TCollection_ExtendedString( (Standard_ExtString) _FD -> cFileName) );
TheIterator.SetPath ( OSD_Path ( aFileName ) );
return TheIterator;

View File

@ -444,6 +444,7 @@ void OSD_Error::Perror() {
#define STRICT
#include <OSD_Error.hxx>
#include <OSD_ErrorList.hxx>
#include <TCollection_ExtendedString.hxx>
#include <windows.h>
@ -578,83 +579,84 @@ void OSD_Error :: Perror () {
if ( fPrefix ) {
lstrcpy ( buff, TEXT( "Error ( " ) );
lstrcpy ( buff, "Error ( " );
switch ( myCode ) {
case OSD_WDirectoryIterator:
ptr = TEXT( "OSD_DirectoryIterator" );
ptr = "OSD_DirectoryIterator";
break;
case OSD_WDirectory:
ptr = TEXT( "OSD_Directory" );
ptr = "OSD_Directory";
break;
case OSD_WFileIterator:
ptr = TEXT( "OSD_FileIterator" );
ptr = "OSD_FileIterator";
break;
case OSD_WFile:
ptr = TEXT( "OSD_File" );
ptr = "OSD_File";
break;
case OSD_WFileNode:
ptr = TEXT( "OSD_FileNode" );
ptr = "OSD_FileNode";
break;
case OSD_WHost:
ptr = TEXT( "OSD_Host" );
ptr = "OSD_Host";
break;
case OSD_WProcess:
ptr = TEXT( "OSD_Environment" );
ptr = "OSD_Environment";
break;
case OSD_WEnvironmentIterator:
ptr = TEXT( "OSD_EnvironmentIterator" );
ptr = "OSD_EnvironmentIterator";
break;
case OSD_WEnvironment:
ptr = TEXT( "OSD_Environment" );
ptr = "OSD_Environment";
break;
case OSD_WDisk:
ptr = TEXT( "OSD_Disk" );
ptr = "OSD_Disk";
break;
default:
ptr = TEXT( "Unknown" );
ptr = "Unknown";
} // end switch
lstrcat ( buff, ptr );
lstrcat ( buff, TEXT( " )" ) );
lstrcat ( buff, " )" );
( *errorStream ) << buff;
} // end if ( fPrefix . . . )
( *errorStream ) << TEXT( ": " ) << myMessage.ToCString () << endl << flush;
TCollection_ExtendedString aMessageW(myMessage);
( *errorStream ) << L": " << (const wchar_t*)aMessageW.ToExtString () << endl << flush;
} // end OSD_Error :: Perror

View File

@ -828,6 +828,7 @@ Standard_Boolean OSD_File::IsExecutable()
#include <stdio.h>
#include <io.h>
#include <Standard_PCharacter.hxx>
#include <TCollection_ExtendedString.hxx>
#ifndef _INC_TCHAR
# include <tchar.h>
@ -851,11 +852,11 @@ Standard_Boolean OSD_File::IsExecutable()
#define OPEN_APPEND 2
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, char* = NULL );
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, wchar_t* = NULL );
BOOL __fastcall _osd_wnt_sd_to_protection (
PSECURITY_DESCRIPTOR, OSD_Protection&, BOOL
);
BOOL __fastcall _osd_print (const Standard_PCharacter, Standard_CString );
BOOL __fastcall _osd_print (const Standard_PCharacter, const wchar_t* );
static void __fastcall _test_raise ( HANDLE, Standard_CString );
static DWORDLONG __fastcall _get_line ( Standard_PCharacter&, DWORD );
@ -917,14 +918,14 @@ void OSD_File :: Build (
if (myFileHandle != INVALID_HANDLE_VALUE)
RAISE( TEXT( "OSD_File :: Build (): incorrect call - file already opened" ) );
RAISE( "OSD_File :: Build (): incorrect call - file already opened" );
myMode = Mode;
myPath.SystemName ( fName );
if ( fName.IsEmpty () )
RAISE( TEXT( "OSD_File :: Build (): incorrent call - no filename given" ) );
RAISE( "OSD_File :: Build (): incorrent call - no filename given" );
myFileHandle = _open_file ( fName.ToCString (), Mode, OPEN_NEW );
@ -955,14 +956,14 @@ void OSD_File :: Open (const OSD_OpenMode Mode, const OSD_Protection& /*Protect*
if (myFileHandle != INVALID_HANDLE_VALUE)
RAISE( TEXT( "OSD_File :: Open (): incorrect call - file already opened" ) );
RAISE( "OSD_File :: Open (): incorrect call - file already opened" );
myMode = Mode;
myPath.SystemName ( fName );
if ( fName.IsEmpty () )
RAISE( TEXT( "OSD_File :: Open (): incorrent call - no filename given" ) );
RAISE( "OSD_File :: Open (): incorrent call - no filename given" );
myFileHandle = _open_file ( fName.ToCString (), Mode, OPEN_OLD );
@ -989,14 +990,14 @@ void OSD_File :: Append (
if (myFileHandle != INVALID_HANDLE_VALUE)
RAISE( TEXT( "OSD_File :: Append (): incorrect call - file already opened" ) );
RAISE( "OSD_File :: Append (): incorrect call - file already opened" );
myMode = Mode;
myPath.SystemName ( fName );
if ( fName.IsEmpty () )
RAISE( TEXT( "OSD_File :: Append (): incorrent call - no filename given" ) );
RAISE( "OSD_File :: Append (): incorrent call - no filename given" );
myFileHandle = _open_file ( fName.ToCString (), Mode, OPEN_APPEND, &fNew );
@ -1039,7 +1040,7 @@ void OSD_File :: Read (
Standard_Integer NbyteRead;
Standard_Address buff;
TEST_RAISE( TEXT( "Read" ) );
TEST_RAISE( "Read" );
buff = ( Standard_Address )new Standard_Character[ Nbyte + 1 ];
@ -1085,11 +1086,11 @@ void OSD_File :: ReadLine (
Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
}
TEST_RAISE( TEXT( "ReadLine" ) );
TEST_RAISE( "ReadLine" );
if ( myIO & FLAG_PIPE && !( myIO & FLAG_READ_PIPE ) )
RAISE( TEXT( "OSD_File :: ReadLine (): attempt to read from write only pipe" ) );
RAISE( "OSD_File :: ReadLine (): attempt to read from write only pipe" );
// +----> leave space for end-of-string
// | plus <CR><LF> sequence
@ -1220,7 +1221,7 @@ void OSD_File :: ReadLine (
} else
RAISE( TEXT( "OSD_File :: ReadLine (): incorrect call - file is a directory" ) );
RAISE( "OSD_File :: ReadLine (): incorrect call - file is a directory" );
if ( !Failed () && !IsAtEnd () )
@ -1245,11 +1246,11 @@ void OSD_File :: Read (
Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
}
TEST_RAISE( TEXT( "Read" ) );
TEST_RAISE( "Read" );
if ( myIO & FLAG_PIPE && !( myIO & FLAG_READ_PIPE ) )
RAISE( TEXT( "OSD_File :: Read (): attempt to read from write only pipe" ) );
RAISE( "OSD_File :: Read (): attempt to read from write only pipe" );
if (!ReadFile (myFileHandle, Buffer, (DWORD)Nbyte, &dwBytesRead, NULL)) {
@ -1288,11 +1289,11 @@ void OSD_File :: Write (
DWORD dwBytesWritten;
TEST_RAISE( TEXT( "Write" ) );
TEST_RAISE( "Write" );
if ( myIO & FLAG_PIPE && myIO & FLAG_READ_PIPE )
RAISE( TEXT( "OSD_File :: Write (): attempt to write to read only pipe" ) );
RAISE( "OSD_File :: Write (): attempt to write to read only pipe" );
if (!WriteFile (myFileHandle, Buffer, (DWORD)Nbyte, &dwBytesWritten, NULL) ||
dwBytesWritten != (DWORD)Nbyte)
@ -1307,7 +1308,7 @@ void OSD_File :: Seek (
DWORD dwMoveMethod = 0;
TEST_RAISE( TEXT( "Seek" ) );
TEST_RAISE( "Seek" );
if ( myIO & FLAG_FILE || myIO & FLAG_DIRECTORY ) {
@ -1333,7 +1334,7 @@ void OSD_File :: Seek (
default:
RAISE( TEXT( "OSD_File :: Seek (): invalid parameter" ) );
RAISE( "OSD_File :: Seek (): invalid parameter" );
} // end switch
@ -1353,7 +1354,7 @@ void OSD_File :: Seek (
void OSD_File :: Close () {
TEST_RAISE( TEXT( "Close" ) );
TEST_RAISE( "Close" );
CloseHandle (myFileHandle);
@ -1368,7 +1369,7 @@ void OSD_File :: Close () {
Standard_Boolean OSD_File :: IsAtEnd () {
TEST_RAISE( TEXT( "IsAtEnd" ) );
TEST_RAISE( "IsAtEnd" );
if (myIO & FLAG_EOF)
return Standard_True ;
@ -1389,7 +1390,7 @@ OSD_KindFile OSD_File :: KindOfFile () const {
if ( fName.IsEmpty () )
RAISE( TEXT( "OSD_File :: KindOfFile (): incorrent call - no filename given" ) );
RAISE( "OSD_File :: KindOfFile (): incorrent call - no filename given" );
flags = _get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE);
@ -1483,10 +1484,10 @@ OSD_File OSD_File :: BuildTemporary () {
OSD_WNT_KEY regKey[ 2 ] = {
{ HKEY_LOCAL_MACHINE,
TEXT( "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" )
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
},
{ HKEY_USERS,
TEXT( ".DEFAULT\\Environment" )
".DEFAULT\\Environment"
}
};
@ -1502,7 +1503,7 @@ OSD_File OSD_File :: BuildTemporary () {
DWORD dwSize = 0;
if ( RegQueryValueEx (
hKey, TEXT( "TEMP" ), NULL, &dwType, NULL, &dwSize
hKey, "TEMP", NULL, &dwType, NULL, &dwSize
) == ERROR_SUCCESS
) {
@ -1511,7 +1512,7 @@ OSD_File OSD_File :: BuildTemporary () {
dwSize + sizeof ( TCHAR )
);
RegQueryValueEx ( hKey, TEXT( "TEMP" ), NULL, &dwType, ( LPBYTE )kVal, &dwSize );
RegQueryValueEx ( hKey, "TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize );
if ( dwType == REG_EXPAND_SZ )
@ -1534,7 +1535,7 @@ OSD_File OSD_File :: BuildTemporary () {
} // end for
if ( !fOK ) lstrcpy ( tmpPath, TEXT( "./" ) );
if ( !fOK ) lstrcpy ( tmpPath, "./" );
GetTempFileName ( tmpPath, "CSF", 0, tmpPath );
@ -1560,7 +1561,7 @@ void OSD_File :: SetLock ( const OSD_LockType Lock ) {
DWORD dwFlags;
OVERLAPPED ovlp;
TEST_RAISE( TEXT( "SetLock" ) );
TEST_RAISE( "SetLock" );
ZeroMemory ( &ovlp, sizeof ( OVERLAPPED ) );
@ -1607,7 +1608,7 @@ leave: ; // added for VisualAge
void OSD_File :: UnLock () {
TEST_RAISE( TEXT( "Unlock" ) );
TEST_RAISE( "Unlock" );
if ( ImperativeFlag ) {
@ -1631,7 +1632,7 @@ OSD_LockType OSD_File :: GetLock () {
Standard_Boolean OSD_File :: IsLocked () {
TEST_RAISE( TEXT( "IsLocked" ) );
TEST_RAISE( "IsLocked" );
return ImperativeFlag;
@ -1646,7 +1647,7 @@ Standard_Size OSD_File :: Size () {
Standard_Integer retVal;
TEST_RAISE( TEXT( "Size" ) );
TEST_RAISE( "Size" );
LARGE_INTEGER aSize;
aSize.QuadPart = 0;
@ -1668,14 +1669,16 @@ void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
if (myFileHandle != INVALID_HANDLE_VALUE)
RAISE( TEXT( "OSD_File :: Print (): incorrect call - file opened" ) );
RAISE( "OSD_File :: Print (): incorrect call - file opened" );
TCollection_AsciiString pName, fName;
WhichPrinter.Name ( pName );
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
if ( !_osd_print ( (Standard_PCharacter)pName.ToCString (), fName.ToCString () ) )
if ( !_osd_print ( (Standard_PCharacter)pName.ToCString (),
(const wchar_t*)fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFile );
@ -1698,7 +1701,7 @@ Standard_Boolean OSD_File :: IsOpen () const {
#endif
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd (
const OSD_Protection& prot, BOOL fDir, char* fName
const OSD_Protection& prot, BOOL fDir, wchar_t* fName
) {
int i, j;
@ -1968,9 +1971,9 @@ static void __fastcall _test_raise ( HANDLE hFile, Standard_CString str ) {
if (hFile == INVALID_HANDLE_VALUE) {
_tcscpy ( buff, TEXT( "OSD_File :: " ) );
_tcscat ( buff, str );
_tcscat ( buff, TEXT( " (): wrong access" ) );
strcpy ( buff, "OSD_File :: " );
strcat ( buff, str );
strcat ( buff, " (): wrong access" );
Standard_ProgramError :: Raise ( buff );
@ -1991,7 +1994,7 @@ static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuf
while ( *ptr != 0 ) {
if ( *ptr == TEXT( '\n' ) ) {
if ( *ptr == '\n' ) {
ptr++ ; // jump newline char.
*ptr = 0 ;
@ -2004,7 +2007,7 @@ static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuf
#endif
return retVal;
} else if ( *ptr == TEXT( '\r' ) && ptr[ 1 ] == TEXT( '\n' ) ) {
} else if ( *ptr == '\r' && ptr[ 1 ] == '\n' ) {
*(ptr++) = '\n' ; // Substitue carriage return by newline.
*ptr = 0 ;
@ -2017,7 +2020,7 @@ static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuf
#endif
return retVal;
} else if ( *ptr == TEXT( '\r' ) && ptr[ 1 ] == 0 ) {
} else if ( *ptr == '\r' && ptr[ 1 ] == 0 ) {
*ptr = '\n' ; // Substitue carriage return by newline
#ifdef VAC
@ -2200,7 +2203,7 @@ static DWORD __fastcall _get_access_mask ( OSD_SingleProtection prt ) {
default:
RAISE( TEXT( "_get_access_mask (): incorrect parameter" ) );
RAISE( "_get_access_mask (): incorrect parameter" );
} // end switch
@ -2312,7 +2315,7 @@ static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ) {
default:
RAISE( TEXT( "_get_dir_access_mask (): incorrect parameter" ) );
RAISE( "_get_dir_access_mask (): incorrect parameter" );
} // end switch
@ -2352,14 +2355,16 @@ static HANDLE __fastcall _open_file (
default:
RAISE( TEXT( "_open_file (): incorrect parameter" ) );
RAISE( "_open_file (): incorrect parameter" );
} // end switch
dwCreationDistribution = ( dwOptions != OPEN_NEW ) ? OPEN_EXISTING : CREATE_ALWAYS;
retVal = CreateFile (
fName, dwDesiredAccess,
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName, Standard_True);
retVal = CreateFileW (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
);
@ -2372,8 +2377,8 @@ static HANDLE __fastcall _open_file (
dwCreationDistribution = CREATE_ALWAYS;
retVal = CreateFile (
fName, dwDesiredAccess,
retVal = CreateFileW (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
);
@ -2406,15 +2411,18 @@ Standard_Integer __fastcall _get_file_type (
break;
case FILE_TYPE_DISK:
if ( ( dwType = GetFileAttributes ( fName ) ) != 0xFFFFFFFF )
{
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName, Standard_True);
dwType = GetFileAttributesW ( (const wchar_t*) fNameW.ToExtString() );
if ( dwType != 0xFFFFFFFF )
retVal = dwType & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
else
retVal = 0x80000000;
}
break;
case FILE_TYPE_CHAR:
@ -2755,7 +2763,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
#define __leave return fOK
#endif
BOOL __fastcall _osd_print (const Standard_PCharacter pName, Standard_CString fName ) {
BOOL __fastcall _osd_print (const Standard_PCharacter pName, const wchar_t* fName ) {
BOOL fOK, fJob;
HANDLE hPrinter = NULL;
@ -2773,15 +2781,15 @@ BOOL __fastcall _osd_print (const Standard_PCharacter pName, Standard_CString fN
} // end if
if ( !AddJob (
if ( !AddJobW (
hPrinter, 1, jobInfo, MAX_PATH + sizeof ( DWORD ), &dwNeeded
)
) __leave;
fJob = TRUE;
if ( !CopyFile (
fName, ( ( ADDJOB_INFO_1* )jobInfo ) -> Path, FALSE
if ( !CopyFileW (
fName, (LPWSTR) ( ( ADDJOB_INFO_1* )jobInfo ) -> Path, FALSE
)
) __leave;

View File

@ -255,8 +255,9 @@ Standard_Integer OSD_FileIterator::Error()const{
#include <windows.h>
#include <OSD_FileIterator.ixx>
#include <TCollection_ExtendedString.hxx>
#define _FD ( ( PWIN32_FIND_DATA )myData )
#define _FD ( ( PWIN32_FIND_DATAW )myData )
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
@ -270,7 +271,7 @@ OSD_FileIterator :: OSD_FileIterator (
where.SystemName ( myPlace );
if ( myPlace.Length () == 0 ) myPlace = TEXT( "." );
if ( myPlace.Length () == 0 ) myPlace = ".";
myMask = Mask;
myData = NULL;
@ -291,13 +292,15 @@ Standard_Boolean OSD_FileIterator :: More () {
if ( myHandle == INVALID_HANDLE_VALUE ) {
TCollection_AsciiString wc = myPlace + TEXT( "/" ) + myMask;
TCollection_AsciiString wc = myPlace + "/" + myMask;
myData = HeapAlloc (
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, sizeof ( WIN32_FIND_DATA )
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, sizeof ( WIN32_FIND_DATAW )
);
myHandle = FindFirstFile (wc.ToCString (), (PWIN32_FIND_DATA)myData);
// make wchar_t string from UTF-8
TCollection_ExtendedString wcW(wc);
myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
if ( myHandle == INVALID_HANDLE_VALUE )
@ -331,7 +334,7 @@ void OSD_FileIterator :: Next () {
do {
if ( !FindNextFile ( ( HANDLE )myHandle, _FD ) ) {
if ( !FindNextFileW ( ( HANDLE )myHandle, _FD ) ) {
myFlag = Standard_False;
@ -349,7 +352,10 @@ void OSD_FileIterator :: Next () {
OSD_File OSD_FileIterator :: Values () {
TheIterator.SetPath ( OSD_Path ( _FD -> cFileName ) );
// make UTF-8 string
TCollection_AsciiString aFileName
(TCollection_ExtendedString( (Standard_ExtString) _FD -> cFileName) );
TheIterator.SetPath ( OSD_Path ( aFileName ) );
return TheIterator;

View File

@ -411,6 +411,7 @@ Standard_Integer OSD_FileNode::Error()const{
#include <OSD_Protection.hxx>
#include <Quantity_Date.hxx>
#include <Standard_ProgramError.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_WNT_1.hxx>
@ -421,7 +422,7 @@ Standard_Integer OSD_FileNode::Error()const{
#define TEST_RAISE( arg ) _test_raise ( fName, ( arg ) )
#define RAISE( arg ) Standard_ProgramError :: Raise ( ( arg ) )
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, char* = NULL );
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, wchar_t* = NULL );
BOOL __fastcall _osd_wnt_sd_to_protection (
PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL
);
@ -429,7 +430,7 @@ Standard_Integer __fastcall _get_file_type ( Standard_CString, HANDLE );
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
static BOOL __fastcall _get_file_time ( Standard_CString, LPSYSTEMTIME, BOOL );
static BOOL __fastcall _get_file_time ( Standard_ExtString, LPSYSTEMTIME, BOOL );
static void __fastcall _test_raise ( TCollection_AsciiString, Standard_CString );
//=======================================================================
@ -486,9 +487,11 @@ Standard_Boolean OSD_FileNode::Exists () {
myPath.SystemName ( fName );
if ( fName.IsEmpty () ) return Standard_False;
TEST_RAISE( TEXT( "Exists" ) );
TEST_RAISE( "Exists" );
if ( GetFileAttributes ( fName.ToCString () ) == 0xFFFFFFFF ) {
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName);
if ( GetFileAttributesW ( (const wchar_t*) fNameW.ToExtString () ) == 0xFFFFFFFF ) {
if ( GetLastError () != ERROR_FILE_NOT_FOUND )
@ -512,14 +515,15 @@ void OSD_FileNode::Remove () {
TCollection_AsciiString fName;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "Remove" ) );
TEST_RAISE( "Remove" );
switch (_get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE)) {
case FLAG_FILE:
if ( !DeleteFile ( fName.ToCString () ) )
if ( !DeleteFileW ( (const wchar_t*) fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
@ -531,7 +535,7 @@ void OSD_FileNode::Remove () {
// LD : Suppression de l'appel a DeleteDirectory pour
// ne pas detruire un repertoire no vide.
if ( !RemoveDirectory ( fName.ToCString () ) )
if ( !RemoveDirectoryW ( (const wchar_t*) fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
@ -557,16 +561,19 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
TCollection_AsciiString fNameDst;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "Move" ) );
TEST_RAISE( "Move" );
NewPath.SystemName ( fNameDst );
TCollection_ExtendedString fNameDstW(fNameDst);
switch (_get_file_type (fName.ToCString (), INVALID_HANDLE_VALUE)) {
case FLAG_FILE:
if (!MoveFileEx (fName.ToCString (), fNameDst.ToCString (),
if (!MoveFileExW ((const wchar_t*)fNameW.ToExtString (),
(const wchar_t*)fNameDstW.ToExtString (),
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED
)
)
@ -578,7 +585,7 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
case FLAG_DIRECTORY:
if ( !MoveDirectory (
fName.ToCString (), fNameDst.ToCString ()
(const wchar_t*) fNameW.ToExtString (), (const wchar_t*) fNameDstW.ToExtString ()
)
)
@ -607,16 +614,19 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
TCollection_AsciiString fNameDst;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "Copy" ) );
TEST_RAISE( "Copy" );
ToPath.SystemName ( fNameDst );
TCollection_ExtendedString fNameDstW(fNameDst);
switch (_get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE)) {
case FLAG_FILE:
if (!CopyFile (fName.ToCString (), fNameDst.ToCString (), FALSE ))
if (!CopyFileW ((const wchar_t*)fNameW.ToExtString (),
(const wchar_t*)fNameDstW.ToExtString (), FALSE ))
_osd_wnt_set_error (myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString ());
break;
@ -624,7 +634,7 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
case FLAG_DIRECTORY:
if ( !CopyDirectory (
fName.ToCString (), fNameDst.ToCString ()
(const wchar_t*)fNameW.ToExtString (), (const wchar_t*)fNameDstW.ToExtString ()
)
)
@ -655,11 +665,12 @@ OSD_Protection OSD_FileNode::Protection () {
PSECURITY_DESCRIPTOR pSD;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "Protection" ) );
TEST_RAISE( "Protection" );
if ( ( pSD = GetFileSecurityEx (
fName.ToCString (), DACL_SECURITY_INFORMATION |
(const wchar_t*) fNameW.ToExtString (), DACL_SECURITY_INFORMATION |
OWNER_SECURITY_INFORMATION
)
) == NULL ||
@ -689,18 +700,19 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
PSECURITY_DESCRIPTOR pSD;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "SetProtection" ) );
TEST_RAISE( "SetProtection" );
pSD = _osd_wnt_protection_to_sd (
Prot,
_get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE) ==
FLAG_DIRECTORY,
(char *)fName.ToCString ()
(wchar_t *)fNameW.ToExtString ()
);
if ( pSD == NULL || !SetFileSecurity (
fName.ToCString (), DACL_SECURITY_INFORMATION, pSD
if ( pSD == NULL || !SetFileSecurityW (
(const wchar_t*) fNameW.ToExtString (), DACL_SECURITY_INFORMATION, pSD
)
)
@ -725,11 +737,12 @@ Quantity_Date OSD_FileNode::AccessMoment () {
TCollection_AsciiString fName;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "AccessMoment" ) );
TEST_RAISE( "AccessMoment" );
// if ( _get_file_time ( fName.ToCString (), &stAccessMoment, TRUE ) )
if ( _get_file_time ( fName.ToCString (), &stAccessSystemMoment, TRUE ) )
if ( _get_file_time ( fNameW.ToExtString (), &stAccessSystemMoment, TRUE ) )
//POP
{
SYSTEMTIME * aSysTime = &stAccessMoment;
@ -765,11 +778,12 @@ Quantity_Date OSD_FileNode::CreationMoment () {
TCollection_AsciiString fName;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "CreationMoment" ) );
TEST_RAISE( "CreationMoment" );
// if ( _get_file_time ( fName.ToCString (), &stCreationMoment, FALSE ) )
if ( _get_file_time ( fName.ToCString (), &stCreationSystemMoment, TRUE ) )
if ( _get_file_time ( fNameW.ToExtString (), &stCreationSystemMoment, TRUE ) )
//POP
{
SYSTEMTIME * aSysTime = &stCreationMoment;
@ -806,11 +820,12 @@ Standard_Integer OSD_FileNode::UserId () {
PSECURITY_DESCRIPTOR pSD;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "UserId" ) );
TEST_RAISE( "UserId" );
if ( ( pSD = GetFileSecurityEx (
fName.ToCString (),
(const wchar_t*) fNameW.ToExtString (),
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION
)
) != NULL &&
@ -844,11 +859,12 @@ Standard_Integer OSD_FileNode::GroupId () {
PSECURITY_DESCRIPTOR pSD;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
TEST_RAISE( TEXT( "GroupId" ) );
TEST_RAISE( "GroupId" );
if ( ( pSD = GetFileSecurityEx (
fName.ToCString (),
(const wchar_t*) fNameW.ToExtString (),
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION
)
) != NULL
@ -944,7 +960,7 @@ void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) {
#endif
static BOOL __fastcall _get_file_time (
Standard_CString fName, LPSYSTEMTIME lpSysTime, BOOL fAccess
Standard_ExtString fName, LPSYSTEMTIME lpSysTime, BOOL fAccess
) {
BOOL retVal = FALSE;
@ -955,9 +971,8 @@ static BOOL __fastcall _get_file_time (
__try {
if ( ( hFile = CreateFile (
fName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
)
if ( ( hFile = CreateFileW ((const wchar_t*) fName, 0, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
) == INVALID_HANDLE_VALUE
) __leave;
@ -999,9 +1014,9 @@ static void __fastcall _test_raise ( TCollection_AsciiString fName, Standard_CSt
if ( fName.IsEmpty () ) {
_tcscpy ( buff, TEXT( "OSD_FileNode :: " ) );
_tcscat ( buff, str );
_tcscat ( buff, TEXT( " (): wrong access" ) );
strcpy ( buff, "OSD_FileNode :: " );
strcat ( buff, str );
strcat ( buff, " (): wrong access" );
Standard_ProgramError :: Raise ( buff );

View File

@ -1016,7 +1016,6 @@ void OSD_Path::SetExtension(const TCollection_AsciiString& aName){
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#define TEST_RAISE( type, arg ) _test_raise ( ( type ), ( arg ) )
@ -1049,7 +1048,7 @@ OSD_Path :: OSD_Path (
memset(__ext, 0,_MAX_EXT);
Standard_Character chr;
TEST_RAISE( aSysType, TEXT( "OSD_Path" ) );
TEST_RAISE( aSysType, "OSD_Path" );
_splitpath ( aDependentName.ToCString (), __drive, __dir, __fname, __ext );
@ -1061,20 +1060,20 @@ OSD_Path :: OSD_Path (
{
TCollection_AsciiString dir = __dir;
len = dir.UsefullLength ();
len = dir.Length ();
}
for ( i = j = 0; i < len; ++i, ++j ) {
chr = __dir[i];
if ( chr == TEXT( '\\' ) || chr == TEXT( '/' ) )
if ( chr == '\\' || chr == '/' )
__trek[j] = TEXT( '|' );
__trek[j] = '|';
else if ( chr == TEXT( '.' )&& (i+1) < len && __dir[i+1] == TEXT( '.' ) ) {
else if ( chr == '.'&& (i+1) < len && __dir[i+1] == '.' ) {
__trek[j] = TEXT( '^' );
__trek[j] = '^';
++i;
} else
@ -1146,9 +1145,9 @@ void OSD_Path :: SetValues (
myName = aName;
myExtension = anExtension;
if ( myExtension.UsefullLength () && myExtension.Value ( 1 ) != TEXT( '.' ) )
if ( myExtension.Length () && myExtension.Value ( 1 ) != '.' )
myExtension.Insert ( 1, TEXT( '.' ) );
myExtension.Insert ( 1, '.' );
_remove_dup ( myTrek );
@ -1166,19 +1165,19 @@ void OSD_Path :: SystemName (
memset(trek,0,_MAX_PATH);
TEST_RAISE( aType, TEXT( "SystemName" ) );
TEST_RAISE( aType, "SystemName" );
for ( i = j = 1; i <= myTrek.UsefullLength () && j <= _MAX_PATH; ++i, ++j ) {
for ( i = j = 1; i <= myTrek.Length () && j <= _MAX_PATH; ++i, ++j ) {
chr = myTrek.Value ( i );
if ( chr == TEXT( '|' ) ) {
if ( chr == '|' ) {
trek[j-1] = TEXT( '/' );
trek[j-1] = '/';
} else if ( chr == TEXT( '^' ) && j <= _MAX_PATH - 1 ) {
} else if ( chr == '^' && j <= _MAX_PATH - 1 ) {
strcpy(&(trek[(j++) - 1]),TEXT( ".." ));
strcpy(&(trek[(j++) - 1]),"..");
} else
@ -1188,11 +1187,11 @@ void OSD_Path :: SystemName (
fullPath = myDisk + TCollection_AsciiString(trek);
if ( trek[0] ) fullPath += TEXT( "/" );
if ( trek[0] ) fullPath += "/";
fullPath += ( myName + myExtension );
if ( fullPath.UsefullLength () > 0 )
if ( fullPath.Length () > 0 )
FullName = fullPath;
@ -1207,7 +1206,7 @@ Standard_Boolean OSD_Path :: IsValid (
const OSD_SysType aSysType
) const {
TEST_RAISE( aSysType, TEXT( "IsValid" ) );
TEST_RAISE( aSysType, "IsValid" );
return Standard_True;
@ -1215,7 +1214,7 @@ Standard_Boolean OSD_Path :: IsValid (
void OSD_Path :: UpTrek () {
Standard_Integer pos = myTrek.SearchFromEnd ( TEXT( "|" ) );
Standard_Integer pos = myTrek.SearchFromEnd ( "|" );
if ( pos == -1 )
@ -1223,7 +1222,7 @@ void OSD_Path :: UpTrek () {
else if ( pos > 1 ) {
while ( myTrek.Value ( pos ) == TEXT( '|' ) && pos != 1 ) --pos;
while ( myTrek.Value ( pos ) == '|' && pos != 1 ) --pos;
} // end if
@ -1233,14 +1232,14 @@ void OSD_Path :: UpTrek () {
void OSD_Path :: DownTrek ( const TCollection_AsciiString& aName ) {
Standard_Integer pos = myTrek.UsefullLength ();
Standard_Integer pos = myTrek.Length ();
if ( aName.Value ( 1 ) != TEXT( '|' ) &&
if ( aName.Value ( 1 ) != '|' &&
pos &&
myTrek.Value ( pos ) != TEXT( '|' )
myTrek.Value ( pos ) != '|'
)
myTrek += TEXT( "|" );
myTrek += "|";
myTrek += aName;
@ -1253,13 +1252,13 @@ Standard_Integer OSD_Path :: TrekLength () const {
Standard_Integer i = 1;
Standard_Integer retVal = 0;
if ( myTrek.IsEmpty () || myTrek.UsefullLength () == 1 && myTrek.Value ( 1 ) == TEXT( '|' ) )
if ( myTrek.IsEmpty () || myTrek.Length () == 1 && myTrek.Value ( 1 ) == '|' )
return retVal;
for (;;) {
if ( myTrek.Token ( TEXT( "|" ), i++ ).IsEmpty () )
if ( myTrek.Token ( "|", i++ ).IsEmpty () )
break;
@ -1280,28 +1279,28 @@ void OSD_Path :: RemoveATrek ( const Standard_Integer thewhere ) {
return;
if ( myTrek.Value ( 1 ) != TEXT( '|' ) ) {
if ( myTrek.Value ( 1 ) != '|' ) {
flag = Standard_True;
myTrek.Insert ( 1, TEXT( '|' ) );
myTrek.Insert ( 1, '|' );
} // end if
i = myTrek.Location (
thewhere, TEXT( '|' ),
1, myTrek.UsefullLength ()
thewhere, '|',
1, myTrek.Length ()
);
if ( i ) {
j = myTrek.Location (
thewhere + 1, TEXT( '|' ),
1, myTrek.UsefullLength ()
thewhere + 1, '|',
1, myTrek.Length ()
);
if ( j == 0 )
j = myTrek.UsefullLength () + 1;
j = myTrek.Length () + 1;
myTrek.Remove ( i, j - i );
@ -1319,38 +1318,38 @@ void OSD_Path :: RemoveATrek ( const TCollection_AsciiString& aName ) {
Standard_Boolean flag = Standard_False;
TCollection_AsciiString tmp;
if ( myTrek.Value ( 1 ) != TEXT( '|' ) ) {
if ( myTrek.Value ( 1 ) != '|' ) {
flag = Standard_True;
myTrek.Insert ( 1, TEXT( '|' ) );
myTrek.Insert ( 1, '|' );
} // end if
myTrek += TEXT( '|' );
myTrek += '|';
tmp = aName;
if ( tmp.Value ( 1 ) != TEXT( '|' ) )
if ( tmp.Value ( 1 ) != '|' )
tmp.Insert ( 1, TEXT( '|' ) );
tmp.Insert ( 1, '|' );
if ( tmp.Value ( tmp.UsefullLength () ) != TEXT( '|' ) )
if ( tmp.Value ( tmp.Length () ) != '|' )
tmp += TEXT( '|' );
tmp += '|';
i = myTrek.Search ( tmp );
if ( i != -1 )
myTrek.Remove ( i + 1, tmp.UsefullLength () - 1 );
myTrek.Remove ( i + 1, tmp.Length () - 1 );
if ( flag )
myTrek.Remove ( 1 );
if ( myTrek.Value ( myTrek.UsefullLength () ) == TEXT( '|' ) )
if ( myTrek.Value ( myTrek.Length () ) == '|' )
myTrek.Trunc ( myTrek.UsefullLength () - 1 );
myTrek.Trunc ( myTrek.Length () - 1 );
} // end OSD_Path :: RemoveATrek ( 2 )
@ -1361,11 +1360,11 @@ TCollection_AsciiString OSD_Path :: TrekValue (
TCollection_AsciiString retVal;
TCollection_AsciiString trek = myTrek;
if ( trek.Value ( 1 ) != TEXT( '|' ) )
if ( trek.Value ( 1 ) != '|' )
trek.Insert ( 1, TEXT( '|' ) );
trek.Insert ( 1, '|' );
retVal = trek.Token ( TEXT( "|" ), thewhere );
retVal = trek.Token ( "|", thewhere );
return retVal;
@ -1380,25 +1379,25 @@ void OSD_Path :: InsertATrek (
TCollection_AsciiString tmp = aName;
Standard_Boolean flag = Standard_False;
if ( myTrek.Value ( 1 ) != TEXT( '|' ) ) {
if ( myTrek.Value ( 1 ) != '|' ) {
flag = Standard_True;
myTrek.Insert ( 1, TEXT( '|' ) );
myTrek.Insert ( 1, '|' );
} // end if
myTrek += TEXT( '|' );
myTrek += '|';
pos = myTrek.Location (
thewhere, TEXT( '|' ),
1, myTrek.UsefullLength ()
thewhere, '|',
1, myTrek.Length ()
);
if ( pos ) {
if ( tmp.Value ( tmp.UsefullLength () ) != TEXT( '|' ) )
if ( tmp.Value ( tmp.Length () ) != '|' )
tmp += TEXT( '|' );
tmp += '|';
myTrek.Insert ( pos + 1, tmp );
@ -1408,9 +1407,9 @@ void OSD_Path :: InsertATrek (
myTrek.Remove ( 1 );
if ( myTrek.Value ( myTrek.UsefullLength () ) == TEXT( '|' ) )
if ( myTrek.Value ( myTrek.Length () ) == '|' )
myTrek.Trunc ( myTrek.UsefullLength () - 1 );
myTrek.Trunc ( myTrek.Length () - 1 );
_remove_dup ( myTrek );
@ -1512,9 +1511,9 @@ static void __fastcall _test_raise ( OSD_SysType type, Standard_CString str ) {
if ( type != OSD_Default && type != OSD_WindowsNT ) {
_tcscpy ( buff, TEXT( "OSD_Path :: " ) );
_tcscat ( buff, str );
_tcscat ( buff, TEXT( " (): unknown system type" ) );
strcpy ( buff, "OSD_Path :: " );
strcat ( buff, str );
strcat ( buff, " (): unknown system type" );
Standard_ProgramError :: Raise ( buff );
@ -1524,19 +1523,19 @@ static void __fastcall _test_raise ( OSD_SysType type, Standard_CString str ) {
static void __fastcall _remove_dup ( TCollection_AsciiString& str ) {
Standard_Integer pos = 1, orgLen, len = str.UsefullLength ();
Standard_Integer pos = 1, orgLen, len = str.Length ();
orgLen = len;
while ( pos <= len ) {
if ( str.Value ( pos ) == TEXT( '|' ) && pos != len &&
str.Value ( pos + 1 ) == TEXT( '|' ) && pos != 1
if ( str.Value ( pos ) == '|' && pos != len &&
str.Value ( pos + 1 ) == '|' && pos != 1
) {
++pos;
while ( pos <= len && str.Value ( pos ) == TEXT( '|' ) ) str.Remove ( pos ), --len;
while ( pos <= len && str.Value ( pos ) == '|' ) str.Remove ( pos ), --len;
} else
@ -1544,18 +1543,18 @@ static void __fastcall _remove_dup ( TCollection_AsciiString& str ) {
} // end while
if ( orgLen > 1 && len > 0 && str.Value ( len ) == TEXT( '|' ) ) str.Remove ( len );
if ( orgLen > 1 && len > 0 && str.Value ( len ) == '|' ) str.Remove ( len );
pos = 1;
orgLen = len = str.UsefullLength ();
orgLen = len = str.Length ();
while ( pos <= len ) {
if ( str.Value ( pos ) == TEXT( '^' ) && pos != len && str.Value ( pos + 1 ) == TEXT( '^' ) ) {
if ( str.Value ( pos ) == '^' && pos != len && str.Value ( pos + 1 ) == '^' ) {
++pos;
while ( pos <= len && str.Value ( pos ) == TEXT( '^' ) ) str.Remove ( pos ), --len;
while ( pos <= len && str.Value ( pos ) == '^' ) str.Remove ( pos ), --len;
} else
@ -1563,7 +1562,7 @@ static void __fastcall _remove_dup ( TCollection_AsciiString& str ) {
} // end while
// if ( orgLen > 1 && len > 0 && str.Value ( len ) == TEXT( '^' ) ) str.Remove ( len );
// if ( orgLen > 1 && len > 0 && str.Value ( len ) == '^' ) str.Remove ( len );
} // end _remove_dup

View File

@ -192,6 +192,8 @@ Standard_Integer OSD_Process::Error()const{
#include <OSD_Path.hxx>
#include <Quantity_Date.hxx>
#include <Standard_PExtCharacter.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_WNT_1.hxx>
#include <LMCONS.H> /// pour UNLEN ( see MSDN about GetUserName() )
@ -246,7 +248,7 @@ void OSD_Process :: Spawn ( const TCollection_AsciiString& cmd ,
void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
Name = TEXT( "WIN32 console" );
Name = "WIN32 console";
} // end OSD_Process :: TerminalType
@ -361,10 +363,14 @@ OSD_Path OSD_Process :: CurrentDirectory () {
OSD_Path anCurrentDirectory;
DWORD dwSize = PATHLEN + 1;
Standard_PCharacter pBuff = new char[dwSize];
Standard_WideChar* pBuff = new wchar_t[dwSize];
if ( GetCurrentDirectory(dwSize, pBuff) > 0 )
anCurrentDirectory = OSD_Path ( pBuff );
if ( GetCurrentDirectoryW(dwSize, (wchar_t*)pBuff) > 0 )
{
// conversion to UTF-8 is performed inside
TCollection_AsciiString aPath(TCollection_ExtendedString((Standard_ExtString)pBuff));
anCurrentDirectory = OSD_Path ( aPath );
}
else
_osd_wnt_set_error ( myError, OSD_WProcess );
@ -374,17 +380,12 @@ OSD_Path OSD_Process :: CurrentDirectory () {
void OSD_Process :: SetCurrentDirectory ( const OSD_Path& where ) {
#ifdef UNICODE
# define SetCurrentDirectory SetCurrentDirectoryW
#else
# define SetCurrentDirectory SetCurrentDirectoryA
#endif // UNICODE
TCollection_AsciiString path;
where.SystemName ( path );
TCollection_ExtendedString pathW(path);
if ( !::SetCurrentDirectory ( path.ToCString () ) )
if ( !::SetCurrentDirectoryW ( (const wchar_t*) pathW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WProcess );

View File

@ -23,7 +23,7 @@
/***/
#include <OSD_WNT_1.hxx>
#include <tchar.h>
#include <wchar.h>
#include <stdlib.h>
/***/
static void Init ( void );
@ -448,7 +448,7 @@ PSID NullSid ( void ) {
#define __leave return retVal
#endif
PSECURITY_DESCRIPTOR GetFileSecurityEx ( LPCTSTR fileName, SECURITY_INFORMATION si ) {
PSECURITY_DESCRIPTOR GetFileSecurityEx ( LPCWSTR fileName, SECURITY_INFORMATION si ) {
DWORD errVal;
DWORD dwSize;
@ -463,7 +463,7 @@ PSECURITY_DESCRIPTOR GetFileSecurityEx ( LPCTSTR fileName, SECURITY_INFORMATION
dwSize = dwSizeNeeded;
errVal = ERROR_SUCCESS;
if ( !GetFileSecurity (
if ( !GetFileSecurityW (
fileName, si,
retVal, dwSize, &dwSizeNeeded
)
@ -540,7 +540,7 @@ void FreeFileSecurity ( PSECURITY_DESCRIPTOR pSD ) {
#define __leave return retVal
#endif
BOOL LookupAccountSidEx ( PSID pSID, LPTSTR* name, LPTSTR* domain ) {
BOOL LookupAccountSidEx ( PSID pSID, LPWSTR* name, LPWSTR* domain ) {
DWORD errVal;
DWORD dwSizeName = 0;
@ -554,15 +554,15 @@ BOOL LookupAccountSidEx ( PSID pSID, LPTSTR* name, LPTSTR* domain ) {
errVal = ERROR_SUCCESS;
if ( !LookupAccountSid (
if ( !LookupAccountSidW (
NULL, pSID, *name, &dwSizeName, *domain, &dwSizeDomain, &eUse
)
) {
if ( ( errVal = GetLastError () ) != ERROR_INSUFFICIENT_BUFFER ) __leave;
if ( ( *name = ( LPTSTR )HeapAlloc ( hHeap, 0, dwSizeName ) ) == NULL ||
( *domain = ( LPTSTR )HeapAlloc ( hHeap, 0, dwSizeDomain ) ) == NULL
if ( ( *name = ( LPWSTR )HeapAlloc ( hHeap, 0, dwSizeName ) ) == NULL ||
( *domain = ( LPWSTR )HeapAlloc ( hHeap, 0, dwSizeDomain ) ) == NULL
) __leave;
} /* end if */
@ -605,7 +605,7 @@ leave: ; // added for VisualAge
/* 'LookupAccountSidEx' function */
/******************************************************************************/
/***/
void FreeAccountNames ( LPTSTR lpszName, LPTSTR lpszDomain ) {
void FreeAccountNames ( LPWSTR lpszName, LPWSTR lpszDomain ) {
HeapFree ( hHeap, 0, ( PVOID )lpszDomain );
HeapFree ( hHeap, 0, ( PVOID )lpszName );
@ -887,7 +887,7 @@ void FreeAce ( PVOID pACE ) {
} /* end FreeAce */
#define WILD_CARD TEXT( "/*.*" )
#define WILD_CARD L"/*.*"
#define WILD_CARD_LEN ( sizeof ( WILD_CARD ) )
/***/
@ -897,14 +897,14 @@ void FreeAce ( PVOID pACE ) {
/* Returns : TRUE on success, FALSE otherwise */
/******************************************************************************/
/***/
BOOL MoveDirectory ( LPCTSTR oldDir, LPCTSTR newDir ) {
BOOL MoveDirectory ( LPCWSTR oldDir, LPCWSTR newDir ) {
PWIN32_FIND_DATA pFD;
LPTSTR pName;
LPTSTR pFullNameSrc;
LPTSTR pFullNameDst;
LPTSTR driveSrc, driveDst;
LPTSTR pathSrc, pathDst;
PWIN32_FIND_DATAW pFD;
LPWSTR pName;
LPWSTR pFullNameSrc;
LPWSTR pFullNameDst;
LPWSTR driveSrc, driveDst;
LPWSTR pathSrc, pathDst;
HANDLE hFindFile;
BOOL fFind;
BOOL retVal = FALSE;
@ -919,20 +919,20 @@ BOOL MoveDirectory ( LPCTSTR oldDir, LPCTSTR newDir ) {
fFind = FALSE;
driveSrc = driveDst = pathSrc = pathDst = NULL;
if ( ( driveSrc = ( LPTSTR )HeapAlloc ( hHeap, 0, _MAX_DRIVE ) ) != NULL &&
( driveDst = ( LPTSTR )HeapAlloc ( hHeap, 0, _MAX_DRIVE ) ) != NULL &&
( pathSrc = ( LPTSTR )HeapAlloc ( hHeap, 0, _MAX_DIR ) ) != NULL &&
( pathDst = ( LPTSTR )HeapAlloc ( hHeap, 0, _MAX_DIR ) ) != NULL
if ( ( driveSrc = ( LPWSTR )HeapAlloc ( hHeap, 0, _MAX_DRIVE * sizeof(WCHAR) ) ) != NULL &&
( driveDst = ( LPWSTR )HeapAlloc ( hHeap, 0, _MAX_DRIVE * sizeof(WCHAR) ) ) != NULL &&
( pathSrc = ( LPWSTR )HeapAlloc ( hHeap, 0, _MAX_DIR * sizeof(WCHAR) ) ) != NULL &&
( pathDst = ( LPWSTR )HeapAlloc ( hHeap, 0, _MAX_DIR * sizeof(WCHAR) ) ) != NULL
) {
_tsplitpath ( oldDir, driveSrc, pathSrc, NULL, NULL );
_tsplitpath ( newDir, driveDst, pathDst, NULL, NULL );
_wsplitpath ( oldDir, driveSrc, pathSrc, NULL, NULL );
_wsplitpath ( newDir, driveDst, pathDst, NULL, NULL );
if ( _tcscmp ( driveSrc, driveDst ) == 0 &&
_tcscmp ( pathSrc, pathDst ) == 0
if ( wcscmp ( driveSrc, driveDst ) == 0 &&
wcscmp ( pathSrc, pathDst ) == 0
) {
retry:
retVal = MoveFileEx (
retVal = MoveFileExW (
oldDir, newDir, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED
);
fFind = TRUE;
@ -987,55 +987,55 @@ retry:
hFindFile = INVALID_HANDLE_VALUE;
retVal = FALSE;
retVal = CreateDirectory ( newDir, NULL );
retVal = CreateDirectoryW ( newDir, NULL );
if ( retVal || ( !retVal && GetLastError () == ERROR_ALREADY_EXISTS ) ) {
if ( ( pFD = ( PWIN32_FIND_DATA )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATA )
if ( ( pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATAW )
)
) != NULL &&
( pName = ( LPTSTR )HeapAlloc (
hHeap, 0, lstrlen ( oldDir ) + WILD_CARD_LEN +
sizeof ( TEXT( '\x00' ) )
( pName = ( LPWSTR )HeapAlloc (
hHeap, 0, lstrlenW ( oldDir ) + WILD_CARD_LEN +
sizeof ( L'\x00' )
)
) != NULL
) {
lstrcpy ( pName, oldDir );
lstrcat ( pName, WILD_CARD );
lstrcpyW ( pName, oldDir );
lstrcatW ( pName, WILD_CARD );
retVal = TRUE;
fFind = ( hFindFile = FindFirstFile ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
fFind = ( hFindFile = FindFirstFileW ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
while ( fFind ) {
if ( pFD -> cFileName[ 0 ] != TEXT( '.' ) ||
pFD -> cFileName[ 0 ] != TEXT( '.' ) &&
pFD -> cFileName[ 1 ] != TEXT( '.' )
if ( pFD -> cFileName[ 0 ] != L'.' ||
pFD -> cFileName[ 0 ] != L'.' &&
pFD -> cFileName[ 1 ] != L'.'
) {
if ( ( pFullNameSrc = ( LPTSTR )HeapAlloc (
if ( ( pFullNameSrc = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlen ( oldDir ) + lstrlen ( pFD -> cFileName ) +
sizeof ( TEXT( '/' ) ) + sizeof ( TEXT( '\x00' ) )
lstrlenW ( oldDir ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL ||
( pFullNameDst = ( LPTSTR )HeapAlloc (
( pFullNameDst = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlen ( newDir ) + lstrlen ( pFD -> cFileName ) +
sizeof ( TEXT( '/' ) ) + sizeof ( TEXT( '\x00' ) )
lstrlenW ( newDir ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL
) break;
lstrcpy ( pFullNameSrc, oldDir );
lstrcat ( pFullNameSrc, TEXT( "/" ) );
lstrcat ( pFullNameSrc, pFD -> cFileName );
lstrcpyW ( pFullNameSrc, oldDir );
lstrcatW ( pFullNameSrc, L"/" );
lstrcatW ( pFullNameSrc, pFD -> cFileName );
lstrcpy ( pFullNameDst, newDir );
lstrcat ( pFullNameDst, TEXT( "/" ) );
lstrcat ( pFullNameDst, pFD -> cFileName );
lstrcpyW ( pFullNameDst, newDir );
lstrcatW ( pFullNameDst, L"/" );
lstrcatW ( pFullNameDst, pFD -> cFileName );
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
@ -1044,7 +1044,7 @@ retry:
} else {
retry_1:
retVal = MoveFileEx (pFullNameSrc, pFullNameDst,
retVal = MoveFileExW (pFullNameSrc, pFullNameDst,
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
if (! retVal) {
@ -1082,7 +1082,7 @@ retry_1:
} /* end if */
fFind = FindNextFile ( hFindFile, pFD );
fFind = FindNextFileW ( hFindFile, pFD );
} /* end while */
@ -1099,7 +1099,7 @@ retry_1:
if ( retVal ) {
retry_2:
retVal = RemoveDirectory ( oldDir );
retVal = RemoveDirectoryW ( oldDir );
if ( !retVal ) {
@ -1134,66 +1134,66 @@ retry_2:
/* Returns : TRUE on success, FALSE otherwise */
/******************************************************************************/
/***/
BOOL CopyDirectory ( LPCTSTR dirSrc, LPCTSTR dirDst ) {
BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
PWIN32_FIND_DATA pFD = NULL;
LPTSTR pName = NULL;
LPTSTR pFullNameSrc = NULL;
LPTSTR pFullNameDst = NULL;
PWIN32_FIND_DATAW pFD = NULL;
LPWSTR pName = NULL;
LPWSTR pFullNameSrc = NULL;
LPWSTR pFullNameDst = NULL;
HANDLE hFindFile = INVALID_HANDLE_VALUE;
BOOL fFind;
BOOL retVal = FALSE;
DIR_RESPONSE response;
retVal = CreateDirectory ( dirDst, NULL );
retVal = CreateDirectoryW ( dirDst, NULL );
if ( retVal || ( !retVal && GetLastError () == ERROR_ALREADY_EXISTS ) ) {
if ( ( pFD = ( PWIN32_FIND_DATA )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATA )
if ( ( pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATAW )
)
) != NULL &&
( pName = ( LPTSTR )HeapAlloc (
hHeap, 0, lstrlen ( dirSrc ) + WILD_CARD_LEN +
sizeof ( TEXT( '\x00' ) )
( pName = ( LPWSTR )HeapAlloc (
hHeap, 0, lstrlenW ( dirSrc ) + WILD_CARD_LEN +
sizeof ( L'\x00' )
)
) != NULL
) {
lstrcpy ( pName, dirSrc );
lstrcat ( pName, WILD_CARD );
lstrcpyW ( pName, dirSrc );
lstrcatW ( pName, WILD_CARD );
retVal = TRUE;
fFind = ( hFindFile = FindFirstFile ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
fFind = ( hFindFile = FindFirstFileW ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
while ( fFind ) {
if ( pFD -> cFileName[ 0 ] != TEXT( '.' ) ||
pFD -> cFileName[ 0 ] != TEXT( '.' ) &&
pFD -> cFileName[ 1 ] != TEXT( '.' )
if ( pFD -> cFileName[ 0 ] != L'.' ||
pFD -> cFileName[ 0 ] != L'.' &&
pFD -> cFileName[ 1 ] != L'.'
) {
if ( ( pFullNameSrc = ( LPTSTR )HeapAlloc (
if ( ( pFullNameSrc = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlen ( dirSrc ) + lstrlen ( pFD -> cFileName ) +
sizeof ( TEXT( '/' ) ) + sizeof ( TEXT( '\x00' ) )
lstrlenW ( dirSrc ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL ||
( pFullNameDst = ( LPTSTR )HeapAlloc (
( pFullNameDst = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlen ( dirDst ) + lstrlen ( pFD -> cFileName ) +
sizeof ( TEXT( '/' ) ) + sizeof ( TEXT( '\x00' ) )
lstrlenW ( dirDst ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL
) break;
lstrcpy ( pFullNameSrc, dirSrc );
lstrcat ( pFullNameSrc, TEXT( "/" ) );
lstrcat ( pFullNameSrc, pFD -> cFileName );
lstrcpyW ( pFullNameSrc, dirSrc );
lstrcatW ( pFullNameSrc, L"/" );
lstrcatW ( pFullNameSrc, pFD -> cFileName );
lstrcpy ( pFullNameDst, dirDst );
lstrcat ( pFullNameDst, TEXT( "/" ) );
lstrcat ( pFullNameDst, pFD -> cFileName );
lstrcpyW ( pFullNameDst, dirDst );
lstrcatW ( pFullNameDst, L"/" );
lstrcatW ( pFullNameDst, pFD -> cFileName );
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
@ -1202,7 +1202,7 @@ BOOL CopyDirectory ( LPCTSTR dirSrc, LPCTSTR dirDst ) {
} else {
retry:
retVal = CopyFile ( pFullNameSrc, pFullNameDst, FALSE );
retVal = CopyFileW ( pFullNameSrc, pFullNameDst, FALSE );
if ( ! retVal ) {
if ( _response_dir_proc != NULL ) {
@ -1239,7 +1239,7 @@ retry:
} /* end if */
fFind = FindNextFile ( hFindFile, pFD );
fFind = FindNextFileW ( hFindFile, pFD );
} /* end while */

View File

@ -23,10 +23,6 @@
# include <windows.h>
# endif /* _INC_WINDOWS */
# ifndef _INC_TCHAR
# include <tchar.h>
# endif /* _INC_TCHAR */
# ifndef OSDAPI
# if !defined(HAVE_NO_DLL)
# ifdef __OSD_DLL
@ -78,8 +74,8 @@ typedef struct _group_sid {
typedef struct _MB_DESC {
MB_ITEMTYPE itemType;
_TINT itemId;
_TCHAR* buttonLabel;
int itemId;
char* buttonLabel;
} MB_DESC, *LPMB_DESC;
@ -92,11 +88,11 @@ typedef struct _file_ace {
} FILE_ACE, *PFILE_ACE;
typedef void ( *MOVE_DIR_PROC ) ( LPCTSTR, LPCTSTR );
typedef void ( *COPY_DIR_PROC ) ( LPCTSTR, LPCTSTR );
typedef void ( *DELETE_DIR_PROC ) ( LPCTSTR );
typedef void ( *MOVE_DIR_PROC ) ( LPCWSTR, LPCWSTR );
typedef void ( *COPY_DIR_PROC ) ( LPCWSTR, LPCWSTR );
typedef void ( *DELETE_DIR_PROC ) ( LPCWSTR );
typedef DIR_RESPONSE ( *RESPONSE_DIR_PROC ) ( LPCTSTR );
typedef DIR_RESPONSE ( *RESPONSE_DIR_PROC ) ( LPCWSTR );
#define GET_SID( pACE ) ( ( PSID )( ( ( PBYTE )pACE ) + \
sizeof ( ACE_HEADER ) + \
@ -115,11 +111,11 @@ void OSDAPI FreeSD ( PSECURITY_DESCRIPTOR );
LPVOID OSDAPI GetTokenInformationEx ( HANDLE, TOKEN_INFORMATION_CLASS );
void OSDAPI FreeTokenInformation ( LPVOID );
PSECURITY_DESCRIPTOR OSDAPI GetFileSecurityEx ( LPCTSTR, SECURITY_INFORMATION );
PSECURITY_DESCRIPTOR OSDAPI GetFileSecurityEx ( LPCWSTR, SECURITY_INFORMATION );
void OSDAPI FreeFileSecurity ( PSECURITY_DESCRIPTOR );
BOOL OSDAPI LookupAccountSidEx ( PSID, LPTSTR*, LPTSTR* );
void OSDAPI FreeAccountNames ( LPTSTR, LPTSTR );
BOOL OSDAPI LookupAccountSidEx ( PSID, LPWSTR*, LPWSTR* );
void OSDAPI FreeAccountNames ( LPWSTR, LPWSTR );
PSID OSDAPI GetSecurityDescriptorOwnerEx ( PSECURITY_DESCRIPTOR );
PSID OSDAPI GetSecurityDescriptorGroupEx ( PSECURITY_DESCRIPTOR );
@ -150,8 +146,8 @@ void OSDAPI FreeGroupSid ( PGROUP_SID );
PVOID OSDAPI AllocAccessAllowedAce ( DWORD, BYTE, PSID );
void OSDAPI FreeAce ( PVOID );
BOOL OSDAPI MoveDirectory ( LPCTSTR, LPCTSTR );
BOOL OSDAPI CopyDirectory ( LPCTSTR, LPCTSTR );
BOOL OSDAPI MoveDirectory ( LPCWSTR, LPCWSTR );
BOOL OSDAPI CopyDirectory ( LPCWSTR, LPCWSTR );
void OSDAPI SetMoveDirectoryProc ( MOVE_DIR_PROC );
void OSDAPI SetCopyDirectoryProc ( COPY_DIR_PROC );

View File

@ -62,7 +62,7 @@ static Standard_Boolean fCtrlBrk;
// used to forbid simultaneous execution of setting / executing handlers
static Standard_Mutex THE_SIGNAL_MUTEX;
static LONG __fastcall _osd_raise ( DWORD, LPTSTR );
static LONG __fastcall _osd_raise ( DWORD, LPSTR );
static BOOL WINAPI _osd_ctrl_break_handler ( DWORD );
static LONG _osd_debug ( void );
@ -82,7 +82,7 @@ static LONG CallHandler (DWORD dwExceptionCode,
#if !defined(__CYGWIN32__) && !defined(__MINGW32__)
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
static TCHAR buffer[ 2048 ];
static char buffer[ 2048 ];
int flterr = 0;
buffer[0] = '\0' ;
@ -92,108 +92,108 @@ static LONG CallHandler (DWORD dwExceptionCode,
case EXCEPTION_FLT_DENORMAL_OPERAND:
// cout << "CallHandler : EXCEPTION_FLT_DENORMAL_OPERAND:" << endl ;
lstrcpy ( buffer, TEXT( "FLT DENORMAL OPERAND" ) );
lstrcpyA ( buffer, "FLT DENORMAL OPERAND" );
flterr = 1 ;
break ;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
// cout << "CallHandler : EXCEPTION_FLT_DIVIDE_BY_ZERO:" << endl ;
lstrcpy ( buffer, TEXT( "FLT DIVIDE BY ZERO" ) );
lstrcpyA ( buffer, "FLT DIVIDE BY ZERO" );
flterr = 1 ;
break ;
case EXCEPTION_FLT_INEXACT_RESULT:
// cout << "CallHandler : EXCEPTION_FLT_INEXACT_RESULT:" << endl ;
lstrcpy ( buffer, TEXT( "FLT INEXACT RESULT" ) );
lstrcpyA ( buffer, "FLT INEXACT RESULT" );
flterr = 1 ;
break ;
case EXCEPTION_FLT_INVALID_OPERATION:
// cout << "CallHandler : EXCEPTION_FLT_INVALID_OPERATION:" << endl ;
lstrcpy ( buffer, TEXT( "FLT INVALID OPERATION" ) );
lstrcpyA ( buffer, "FLT INVALID OPERATION" );
flterr = 1 ;
break ;
case EXCEPTION_FLT_OVERFLOW:
// cout << "CallHandler : EXCEPTION_FLT_OVERFLOW:" << endl ;
lstrcpy ( buffer, TEXT( "FLT OVERFLOW" ) );
lstrcpyA ( buffer, "FLT OVERFLOW" );
flterr = 1 ;
break ;
case EXCEPTION_FLT_STACK_CHECK:
// cout << "CallHandler : EXCEPTION_FLT_STACK_CHECK:" << endl ;
lstrcpy ( buffer, TEXT( "FLT STACK CHECK" ) );
lstrcpyA ( buffer, "FLT STACK CHECK" );
flterr = 1 ;
break ;
case EXCEPTION_FLT_UNDERFLOW:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpy ( buffer, TEXT( "FLT UNDERFLOW" ) );
lstrcpyA ( buffer, "FLT UNDERFLOW" );
flterr = 1 ;
break ;
case STATUS_FLOAT_MULTIPLE_TRAPS:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpy ( buffer, TEXT( "FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)" ) );
lstrcpyA ( buffer, "FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)" );
flterr = 1 ;
break ;
case STATUS_FLOAT_MULTIPLE_FAULTS:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpy ( buffer, TEXT( "FLT MULTIPLE FAULTS" ) );
lstrcpyA ( buffer, "FLT MULTIPLE FAULTS" );
flterr = 1 ;
break ;
case STATUS_NO_MEMORY:
// cout << "CallHandler : STATUS_NO_MEMORY:" << endl ;
OSD_Exception_STATUS_NO_MEMORY ::
Raise ( TEXT( "MEMORY ALLOCATION ERROR ( no room in the process heap )" ) );
Raise ( "MEMORY ALLOCATION ERROR ( no room in the process heap )" );
case EXCEPTION_ACCESS_VIOLATION:
// cout << "CallHandler : EXCEPTION_ACCESS_VIOLATION:" << endl ;
wsprintf ( buffer, TEXT( "%s%s%s0x%.8p%s%s%s" ), TEXT( "ACCESS VIOLATION" ),
fMsgBox ? "\n" : " ", TEXT( "at address " ),
wsprintf ( buffer, "%s%s%s0x%.8p%s%s%s", "ACCESS VIOLATION",
fMsgBox ? "\n" : " ", "at address ",
ExceptionInformation1 ,
TEXT( " during '" ),
ExceptionInformation0 ? TEXT( "WRITE" ) : TEXT( "READ" ),
TEXT( "' operation" ));
" during '",
ExceptionInformation0 ? "WRITE" : "READ",
"' operation");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
// cout << "CallHandler : EXCEPTION_ARRAY_BOUNDS_EXCEEDED:" << endl ;
lstrcpy ( buffer, TEXT( "ARRAY BOUNDS EXCEEDED" ) );
lstrcpyA ( buffer, "ARRAY BOUNDS EXCEEDED" );
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
// cout << "CallHandler : EXCEPTION_DATATYPE_MISALIGNMENT:" << endl ;
lstrcpy ( buffer, TEXT( "DATATYPE MISALIGNMENT" ) );
lstrcpyA ( buffer, "DATATYPE MISALIGNMENT" );
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
// cout << "CallHandler : EXCEPTION_ILLEGAL_INSTRUCTION:" << endl ;
lstrcpy ( buffer, TEXT( "ILLEGAL INSTRUCTION" ) );
lstrcpyA ( buffer, "ILLEGAL INSTRUCTION" );
break;
case EXCEPTION_IN_PAGE_ERROR:
// cout << "CallHandler : EXCEPTION_IN_PAGE_ERROR:" << endl ;
lstrcpy ( buffer, TEXT( "IN_PAGE ERROR" ) );
lstrcpyA ( buffer, "IN_PAGE ERROR" );
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
// cout << "CallHandler : EXCEPTION_INT_DIVIDE_BY_ZERO:" << endl ;
lstrcpy ( buffer, TEXT( "INTEGER DIVISION BY ZERO" ) );
lstrcpyA ( buffer, "INTEGER DIVISION BY ZERO" );
break;
case EXCEPTION_INT_OVERFLOW:
// cout << "CallHandler : EXCEPTION_INT_OVERFLOW:" << endl ;
lstrcpy ( buffer, TEXT( "INTEGER OVERFLOW" ) );
lstrcpyA ( buffer, "INTEGER OVERFLOW" );
break;
case EXCEPTION_INVALID_DISPOSITION:
// cout << "CallHandler : EXCEPTION_INVALID_DISPOSITION:" << endl ;
lstrcpy ( buffer, TEXT( "INVALID DISPOSITION" ) );
lstrcpyA ( buffer, "INVALID DISPOSITION" );
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
// cout << "CallHandler : EXCEPTION_NONCONTINUABLE_EXCEPTION:" << endl ;
lstrcpy ( buffer, TEXT( "NONCONTINUABLE EXCEPTION" ) );
lstrcpyA ( buffer, "NONCONTINUABLE EXCEPTION" );
break;
case EXCEPTION_PRIV_INSTRUCTION:
// cout << "CallHandler : EXCEPTION_PRIV_INSTRUCTION:" << endl ;
lstrcpy ( buffer, TEXT( "PRIVELEGED INSTRUCTION ENCOUNTERED" ) );
lstrcpyA ( buffer, "PRIVELEGED INSTRUCTION ENCOUNTERED" );
break;
case EXCEPTION_STACK_OVERFLOW:
@ -201,20 +201,20 @@ static LONG CallHandler (DWORD dwExceptionCode,
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
// try recovering from stack overflow: available in MS VC++ 7.0
if (!_resetstkoflw())
lstrcpy ( buffer, TEXT( "Unrecoverable STACK OVERFLOW" ) );
lstrcpyA ( buffer, "Unrecoverable STACK OVERFLOW" );
else
#endif
lstrcpy ( buffer, TEXT( "STACK OVERFLOW" ) );
lstrcpyA ( buffer, "STACK OVERFLOW" );
break;
default:
wsprintf( buffer, TEXT("unknown exception code 0x%x, params 0x%p 0x%p"),
wsprintf( buffer, "unknown exception code 0x%x, params 0x%p 0x%p",
dwExceptionCode, ExceptionInformation1, ExceptionInformation0 );
} // end switch
// provide message to the user with possibility to stop
int idx = lstrlen ( buffer );
int idx = lstrlenA ( buffer );
if ( idx && fMsgBox && dwExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION ) {
// reset FP operations before message box, otherwise it may fail to show up
_fpreset();
@ -437,9 +437,9 @@ static BOOL WINAPI _osd_ctrl_break_handler ( DWORD dwCode ) {
//==== _osd_raise
//============================================================================
static LONG __fastcall _osd_raise ( DWORD dwCode, LPTSTR msg )
static LONG __fastcall _osd_raise ( DWORD dwCode, LPSTR msg )
{
if (msg[0] == TEXT('\x03')) ++msg;
if (msg[0] == '\x03') ++msg;
switch (dwCode)
{

View File

@ -15,7 +15,6 @@
// commercial license or contractual agreement.
#include <PCDM_ReadWriter.ixx>
#include <UTL.hxx>
#include <PCDM_ReadWriter_1.hxx>
#include <Storage_Schema.hxx>
#include <Standard_ErrorHandler.hxx>
@ -106,7 +105,8 @@ TCollection_ExtendedString PCDM_ReadWriter::FileFormat
PCDM_BaseDriverPointer theFileDriver;
TCollection_AsciiString theFileName (UTL::CString(aFileName));
// conversion to UTF-8 is done inside
TCollection_AsciiString theFileName (aFileName);
if (PCDM::FileDriverType (theFileName, theFileDriver) == PCDM_TOFD_Unknown)
return ::TryXmlDriverType (theFileName);
@ -125,7 +125,8 @@ TCollection_ExtendedString PCDM_ReadWriter::FileFormat
for (Standard_Integer i =1; !found && i<= refUserInfo.Length() ; i++) {
if(refUserInfo(i).Search(FILE_FORMAT) != -1) {
found=Standard_True;
theFormat=UTL::ExtendedString(refUserInfo(i).Token(" ",2));
theFormat=TCollection_ExtendedString(refUserInfo(i).Token(" ",2).ToCString(),
Standard_True);
}
}
if(!found) theFormat=s->ReadTypeSection(*theFileDriver)->Types()->Value(1);

View File

@ -119,7 +119,7 @@ static TCollection_AsciiString AbsolutePath(
}
static TCollection_AsciiString GetDirFromFile(const TCollection_ExtendedString& aFileName) {
TCollection_AsciiString theCFile=UTL::CString(aFileName);
TCollection_AsciiString theCFile(aFileName);
TCollection_AsciiString theDirectory;
Standard_Integer i=theCFile.SearchFromEnd("/");
#ifdef WNT
@ -172,13 +172,13 @@ void PCDM_ReadWriter_1::WriteReferences(const Handle(Storage_Data)& aData, const
ligne += TCollection_ExtendedString(it.Document()->Modifications());
ligne += " ";
TCollection_AsciiString thePath=UTL::CString(it.Document()->MetaData()->FileName());
TCollection_AsciiString thePath(it.Document()->MetaData()->FileName());
TCollection_AsciiString theRelativePath;
if(!theAbsoluteDirectory.IsEmpty()) {
theRelativePath=OSD_Path::RelativePath(theAbsoluteDirectory,thePath);
if(!theRelativePath.IsEmpty()) thePath=theRelativePath;
}
ligne += UTL::ExtendedString(thePath);
ligne += TCollection_ExtendedString(thePath);
UTL::AddToUserInfo(aData,ligne);
}
aData->AddToUserInfo(END_REF);
@ -226,7 +226,9 @@ Standard_Integer PCDM_ReadWriter_1::ReadReferenceCounter(const TCollection_Exten
static Standard_Integer i ;
PCDM_BaseDriverPointer theFileDriver;
if(PCDM::FileDriverType(TCollection_AsciiString(UTL::CString(aFileName)), theFileDriver) == PCDM_TOFD_Unknown) return theReferencesCounter;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return theReferencesCounter;
static Standard_Boolean theFileIsOpen ;
theFileIsOpen=Standard_False;
@ -290,7 +292,7 @@ void PCDM_ReadWriter_1::ReadReferences(const TCollection_ExtendedString& aFileNa
theFileName=theRest.Split(pos2);
theDocumentVersion=UTL::IntegerValue(theRest);
TCollection_AsciiString thePath=UTL::CString(theFileName);
TCollection_AsciiString thePath(theFileName);
TCollection_AsciiString theAbsolutePath;
if(!theAbsoluteDirectory.IsEmpty()) {
theAbsolutePath=AbsolutePath(theAbsoluteDirectory,thePath);
@ -302,7 +304,8 @@ void PCDM_ReadWriter_1::ReadReferences(const TCollection_ExtendedString& aFileNa
aMsg = aMsg.Cat("reference found; ReferenceIdentifier: ").Cat(theReferenceIdentifier).Cat("; File:").Cat(thePath).Cat(", version:").Cat(theDocumentVersion).Cat("\0");
theMsgDriver->Write(aMsg.ToExtString());
}
theReferences.Append(PCDM_Reference (theReferenceIdentifier,UTL::ExtendedString(thePath),theDocumentVersion));
TCollection_ExtendedString aPathW(thePath);
theReferences.Append(PCDM_Reference (theReferenceIdentifier,aPathW,theDocumentVersion));
}
}
@ -333,7 +336,9 @@ void PCDM_ReadWriter_1::ReadUserInfo(const TCollection_ExtendedString& aFileName
static Standard_Integer i ;
PCDM_BaseDriverPointer theFileDriver;
if(PCDM::FileDriverType(TCollection_AsciiString(UTL::CString(aFileName)), theFileDriver) == PCDM_TOFD_Unknown) return;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return;
PCDM_ReadWriter::Open(*theFileDriver,aFileName,Storage_VSRead);
Handle(Storage_Schema) s = new Storage_Schema;
@ -349,7 +354,8 @@ void PCDM_ReadWriter_1::ReadUserInfo(const TCollection_ExtendedString& aFileName
}
if(debut != 0) {
for (i=debut+1 ; i<fin; i++) {
theUserInfo.Append(UTL::ExtendedString(refUserInfo(i)));
TCollection_ExtendedString aInfoW(refUserInfo(i));
theUserInfo.Append(aInfoW);
}
}
theFileDriver->Close();
@ -367,7 +373,9 @@ Standard_Integer PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_Extend
theVersion=-1;
PCDM_BaseDriverPointer theFileDriver;
if(PCDM::FileDriverType(TCollection_AsciiString(UTL::CString(aFileName)), theFileDriver) == PCDM_TOFD_Unknown) return theVersion;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return theVersion;
static Standard_Boolean theFileIsOpen ;
theFileIsOpen =Standard_False;

View File

@ -30,7 +30,6 @@
#include <PCDM_ReadWriter.hxx>
#include <Resource_Manager.hxx>
#include <Standard_ErrorHandler.hxx>
#include <UTL.hxx>
#include <PCDM.hxx>
#include <Storage_HSeqOfRoot.hxx>
#include <locale.h>
@ -38,7 +37,9 @@
void PCDM_RetrievalDriver::RaiseIfUnknownTypes(const Handle(Storage_Schema)& aSchema, const TCollection_ExtendedString& aFileName) {
PCDM_BaseDriverPointer theFileDriver;
if(PCDM::FileDriverType(TCollection_AsciiString(UTL::CString(aFileName)), theFileDriver) == PCDM_TOFD_Unknown) return;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return;
PCDM_ReadWriter::Open(*theFileDriver,aFileName,Storage_VSRead);
@ -94,7 +95,8 @@ void PCDM_RetrievalDriver::Read(const TCollection_ExtendedString& theFileName,
}
PCDM_BaseDriverPointer theFileDriver;
if(PCDM::FileDriverType(TCollection_AsciiString(UTL::CString(theFileName)), theFileDriver) == PCDM_TOFD_Unknown) {
TCollection_AsciiString aFileNameU(theFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown) {
myReaderStatus = PCDM_RS_UnknownFileDriver;
return;
}

View File

@ -120,7 +120,12 @@ Standard_Integer StepFile_Read
checkread->Clear();
recfile_modeprint ( (modepr > 0 ? modepr-1 : 0) );
#ifdef _WIN32
TCollection_ExtendedString aFileNameW(ficnom, Standard_True);
FILE* newin = stepread_setinput((char*)aFileNameW.ToExtString());
#else
FILE* newin = stepread_setinput(ficnom);
#endif
if (!newin) return -1;
#ifdef CHRONOMESURE
Standard_Integer n ;

View File

@ -19,6 +19,7 @@
*/
/**
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -83,7 +84,13 @@ FILE* stepread_setinput (char* nomfic)
{
FILE* newin ;
if (strlen(nomfic) == 0) return stepin ;
#ifdef _WIN32
// file name is treated as UTF-8 string
// nomfic is prepared UTF-8 string
newin = _wfopen((const wchar_t*)nomfic, L"r") ;
#else
newin = fopen(nomfic,"r") ;
#endif
if (newin == NULL) {
return NULL ;
} else {

View File

@ -87,8 +87,7 @@ is
---Purpose: Creation by converting an extended string to an ascii string.
-- If replaceNonAscii is non-null charecter, it will be used
-- in place of any non-ascii character found in the source string.
-- Otherwise, raises OutOfRange exception if at least one character
-- in the source string is not in the "Ascii range".
-- Otherwise, creates UTF-8 unicode string.
returns AsciiString from TCollection
raises OutOfRange from Standard;

View File

@ -231,10 +231,10 @@ TCollection_AsciiString::TCollection_AsciiString(const TCollection_ExtendedStrin
mystring[mylength] = '\0';
}
else {
Standard_SStream amsg;
amsg << "It's not an ascii string : " ;
astring.Print(amsg);
Standard_OutOfRange::Raise(amsg);
// create UTF-8 string
mylength = astring.LengthOfCString();
mystring = Allocate(mylength+1);
astring.ToUTF8CString(mystring);
}
}

View File

@ -41,7 +41,12 @@ is
Create( astring : CString; isMultiByte : Boolean = Standard_False)
returns ExtendedString from TCollection
raises NullObject;
---Purpose: Creation by converting a CString to an extended string.
---Purpose: Creation by converting a CString to an extended
-- string. If <isMultiByte> is true then the string is
-- treated as having UTF-8 coding. If it is not a UTF-8
-- then <isMultiByte> is ignored and each character is
-- copied to ExtCharacter.
Create( astring : ExtString)
returns ExtendedString from TCollection
@ -73,7 +78,9 @@ is
Create( astring : AsciiString from TCollection)
returns ExtendedString from TCollection;
---Purpose: Creation by converting a normal Ascii string to an extended string.
---Purpose: Creation by converting an Ascii string to an extended
-- string. The string is treated as having UTF-8 coding.
-- If it is not a UTF-8 then each character is copied to ExtCharacter.
AssignCat (me : out ; other : ExtendedString from TCollection)
is static;

View File

@ -35,10 +35,11 @@ Standard_EXPORT short NULL_EXTSTRING[1] = {0};
inline Standard_ExtCharacter ConvertToUnicode2B (unsigned char *p)
{
// *p, *(p+1)
// little endian
union {
struct {
unsigned char h;
unsigned char l;
unsigned char h;
} hl;
Standard_ExtCharacter chr;
} EL;
@ -61,10 +62,11 @@ inline Standard_ExtCharacter ConvertToUnicode2B (unsigned char *p)
inline Standard_ExtCharacter ConvertToUnicode3B (unsigned char *p)
{
// *p, *(p+1), *(p+2) =>0 , 1, 2
// little endian
union {
struct {
unsigned char h;
unsigned char l;
unsigned char h;
} hl;
Standard_ExtCharacter chr;
} EL;
@ -143,9 +145,11 @@ TCollection_ExtendedString::TCollection_ExtendedString
mystring = Allocate( (mylength+1)*2 );
if(!ConvertToUnicode (astring))
{
#ifdef DEB
cout <<"UTF8 decoding failure..." <<endl;
#endif
mylength = (int)strlen( astring );
mystring = Reallocate(mystring, (mylength+1)*2);
for (int i = 0 ; i < mylength ; i++)
mystring[i] = ToExtCharacter(astring[i]);
mystring[mylength] = '\0';
}
}
}
@ -268,12 +272,17 @@ TCollection_ExtendedString::TCollection_ExtendedString
TCollection_ExtendedString::TCollection_ExtendedString
(const TCollection_AsciiString& astring)
{
mylength = astring.Length();
mylength = nbSymbols(astring.ToCString());
mystring = Allocate((mylength+1)*2);
if(!ConvertToUnicode (astring.ToCString()))
{
mylength = astring.Length();
mystring = Reallocate(mystring, (mylength+1)*2);
Standard_CString aCString = astring.ToCString();
for (Standard_Integer i = 0; i <= mylength ; i++)
mystring[i] = ToExtCharacter( aCString[i] );
}
}
// ----------------------------------------------------------------------------
// AssignCat

View File

@ -25,102 +25,116 @@
#include <OSD_File.hxx>
#include <OSD_Protection.hxx>
#include <OSD_SingleProtection.hxx>
#define MaxChar 10000
static Standard_Character longtc[MaxChar];
static Standard_PCharacter aLongCString = longtc;
static TCollection_ExtendedString outExtendedString;
static TCollection_AsciiString ASCII(const TCollection_ExtendedString& anXString) {
Resource_Unicode::ConvertUnicodeToFormat(anXString,aLongCString,MaxChar);
return TCollection_AsciiString(aLongCString);
}
static TCollection_ExtendedString UNICODE(const TCollection_AsciiString& aCString) {
Resource_Unicode::ConvertFormatToUnicode(aCString.ToCString(),outExtendedString);
return outExtendedString;
}
TCollection_ExtendedString UTL::xgetenv(const Standard_CString aCString) {
TCollection_ExtendedString x;
OSD_Environment theEnv(aCString);
TCollection_AsciiString theValue=theEnv.Value();
if( ! theValue.IsEmpty()) x=UNICODE(theValue);
if( ! theValue.IsEmpty())
x = TCollection_ExtendedString(theValue);
return x;
}
TCollection_ExtendedString UTL::Extension(const TCollection_ExtendedString& aFileName) {
OSD_Path p = OSD_Path(ASCII(aFileName));
TCollection_ExtendedString UTL::Extension(const TCollection_ExtendedString& aFileName)
{
TCollection_AsciiString aFileNameU(aFileName);
OSD_Path p = OSD_Path(aFileNameU);
TCollection_AsciiString theExtension = p.Extension();
TCollection_AsciiString theGoodExtension=theExtension;;
if(TCollection_AsciiString(theExtension.Value(1))==".")
theGoodExtension=theExtension.Split(1);
return UNICODE(theGoodExtension);
}
Storage_Error UTL::OpenFile(Storage_BaseDriver& aDriver, const TCollection_ExtendedString& aFileName, const Storage_OpenMode aMode) {
return aDriver.Open(ASCII(aFileName),aMode);
if (theExtension.Value(1) == '.')
theExtension.Remove(1, 1);
return TCollection_ExtendedString(theExtension);
}
void UTL::AddToUserInfo(const Handle(Storage_Data)& aData, const TCollection_ExtendedString& anInfo) {
aData->AddToUserInfo(ASCII(anInfo));
Storage_Error UTL::OpenFile(Storage_BaseDriver& aDriver,
const TCollection_ExtendedString& aFileName,
const Storage_OpenMode aMode)
{
return aDriver.Open(TCollection_AsciiString(aFileName),aMode);
}
OSD_Path UTL::Path(const TCollection_ExtendedString& aFileName) {
// cout << "Path : " << aFileName << endl;
// TCollection_AsciiString theAciiString=ASCII(aFileName);
// OSD_Path p = OSD_Path(theAciiString);
OSD_Path p = OSD_Path(ASCII(aFileName));
void UTL::AddToUserInfo(const Handle(Storage_Data)& aData,
const TCollection_ExtendedString& anInfo)
{
aData->AddToUserInfo(TCollection_AsciiString(anInfo));
}
OSD_Path UTL::Path(const TCollection_ExtendedString& aFileName)
{
OSD_Path p = OSD_Path(TCollection_AsciiString(aFileName));
return p;
}
TCollection_ExtendedString UTL::Disk(const OSD_Path& aPath) {
return UNICODE(aPath.Disk());
TCollection_ExtendedString UTL::Disk(const OSD_Path& aPath)
{
return TCollection_ExtendedString(aPath.Disk());
}
TCollection_ExtendedString UTL::Trek(const OSD_Path& aPath) {
return UNICODE(aPath.Trek());
TCollection_ExtendedString UTL::Trek(const OSD_Path& aPath)
{
return TCollection_ExtendedString(aPath.Trek());
}
TCollection_ExtendedString UTL::Name(const OSD_Path& aPath) {
return UNICODE(aPath.Name());
TCollection_ExtendedString UTL::Name(const OSD_Path& aPath)
{
return TCollection_ExtendedString(aPath.Name());
}
TCollection_ExtendedString UTL::Extension(const OSD_Path& aPath) {
return UNICODE(aPath.Extension());
TCollection_ExtendedString UTL::Extension(const OSD_Path& aPath)
{
return TCollection_ExtendedString(aPath.Extension());
}
OSD_FileIterator UTL::FileIterator(const OSD_Path& aPath, const TCollection_ExtendedString& aMask) {
OSD_FileIterator it = OSD_FileIterator(aPath,ASCII(aMask));
OSD_FileIterator UTL::FileIterator(const OSD_Path& aPath, const TCollection_ExtendedString& aMask)
{
OSD_FileIterator it = OSD_FileIterator(aPath,TCollection_AsciiString(aMask));
return it;
}
TCollection_ExtendedString UTL::LocalHost() {
TCollection_ExtendedString UTL::LocalHost()
{
OSD_Host h;
return UNICODE(h.HostName());
return TCollection_ExtendedString(h.HostName());
}
TCollection_ExtendedString UTL::ExtendedString(const TCollection_AsciiString& anAsciiString) {
return UNICODE(anAsciiString);
TCollection_ExtendedString UTL::ExtendedString(const TCollection_AsciiString& anAsciiString)
{
return TCollection_ExtendedString(anAsciiString);
}
Standard_GUID UTL::GUID(const TCollection_ExtendedString& anXString) {
Standard_GUID UTL::GUID(const TCollection_ExtendedString& anXString)
{
return Standard_GUID(TCollection_AsciiString(anXString,'?').ToCString());
}
Standard_Boolean UTL::Find(const Handle(Resource_Manager)& aResourceManager, const TCollection_ExtendedString& aResourceName) {
return aResourceManager->Find(ASCII(aResourceName).ToCString());
}
TCollection_ExtendedString UTL::Value(const Handle(Resource_Manager)& aResourceManager, const TCollection_ExtendedString& aResourceName) {
return UNICODE(aResourceManager->Value(ASCII(aResourceName).ToCString()));
Standard_Boolean UTL::Find(const Handle(Resource_Manager)& aResourceManager,
const TCollection_ExtendedString& aResourceName)
{
return aResourceManager->Find(TCollection_AsciiString(aResourceName).ToCString());
}
Standard_Integer UTL::IntegerValue(const TCollection_ExtendedString& anExtendedString) {
TCollection_AsciiString a=ASCII(anExtendedString);
TCollection_ExtendedString UTL::Value(const Handle(Resource_Manager)& aResourceManager,
const TCollection_ExtendedString& aResourceName)
{
TCollection_AsciiString aResourceNameU(aResourceName);
return TCollection_ExtendedString(aResourceManager->Value(aResourceNameU.ToCString()),
Standard_True);
}
Standard_Integer UTL::IntegerValue(const TCollection_ExtendedString& anExtendedString)
{
TCollection_AsciiString a(anExtendedString);
return a.IntegerValue();
}
Standard_CString UTL::CString(const TCollection_ExtendedString& anExtendedString) {
Standard_CString UTL::CString(const TCollection_ExtendedString& anExtendedString)
{
static TCollection_AsciiString theValue;
theValue=ASCII(anExtendedString);
theValue = TCollection_AsciiString(anExtendedString);
return theValue.ToCString();
}
Standard_Boolean UTL::IsReadOnly(const TCollection_ExtendedString& aFileName) {
Standard_Boolean UTL::IsReadOnly(const TCollection_ExtendedString& aFileName)
{
switch (OSD_File(UTL::Path(aFileName)).Protection().User()) {
case OSD_W:
case OSD_RW:

View File

@ -2606,23 +2606,7 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char**
const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (Draw::Atoi(argv[15]) != 0);
// Read text string
TCollection_ExtendedString name;
if (isMultibyte)
{
const char *str = argv[1];
while ( *str || *(str+1)=='\x0A' || *(str+1)=='\x0B' || *(str+1)=='\x0C' || *(str+1)=='\x0D'
|| *(str+1)=='\x07' || *(str+1)=='\x08' || *(str+1)=='\x09' )
{
unsigned short c1 = *str++;
unsigned short c2 = *str++;
if (!c2) break;
name += (Standard_ExtCharacter)((c1 << 8) | c2);
}
}
else
{
name += argv[1];
}
TCollection_ExtendedString name(argv[1],isMultibyte);
if (name.Length())
{

View File

@ -9,7 +9,9 @@ puts ""
set BugNumber OCC22796
vfont add [locate_data_file bug22149_mona.ttf] Mona
vdrawtext "\x30\x42\x00\x09\x30\x79\x00\x0A\x30\x6F" 0 0 0 255 255 255 0 0 0 1 50 0 Mona 1
set s [encoding convertfrom unicode "\x42\x30\x09\x00\x79\x30\x0A\x00\x6F\x30\x42\x26"]
#vdrawtext "\x30\x42\x00\x09\x30\x79\x00\x0A\x30\x6F" 0 0 0 255 255 255 0 0 0 1 50 0 Mona 1
vdrawtext $s 0 0 0 255 255 255 0 0 0 1 50 0 Mona 1
set only_screen 1