1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0027350: Support for Universal Windows Platform

- Toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application was added (CMake).
- There is no support for environment variables in UWP.
- SID is not supported (were excluded).
- Windows registry is not supported (were excluded).
- Mess with usage of Unicode/ANSI was corrected.
- Added sample to check UWP functionality.
- Excluded usage of methods with Unicode characters where it is possible.
- Minor corrections to allow building OCAF (except TKVCAF) and DE (except VRML and XDE)
- Building of unsupported modules for UWP platform is off by default .
- Checking of DataExchange functionality was added to XAML (UWP) sample.
- Added information about UWP to the documentation.
- Update of results of merge with issue 27801
This commit is contained in:
ski
2016-08-12 18:38:48 +03:00
committed by abv
parent f3ec3b372c
commit 742cc8b01d
69 changed files with 1526 additions and 639 deletions

View File

@@ -38,12 +38,6 @@
#include <TColgp_Array1OfVec.hxx>
#include <TColgp_Array1OfVec2d.hxx>
#include <OSD_Chronometer.hxx>
static OSD_Chronometer chr1;
static AppParCurves_Constraint FirstConstraint
(const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints,
const Standard_Integer FirstPoint)

View File

@@ -28,6 +28,7 @@
#include <BRepAlgoAPI_Check.hxx>
#include <BRepLib_FuseEdges.hxx>
#include <BRepTools.hxx>
#include <OSD_Environment.hxx>
#include <OSD_File.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopExp.hxx>
@@ -53,9 +54,10 @@ class BRepAlgoAPI_DumpOper {
myIsDump(Standard_False),
myIsDumpArgs(Standard_False),
myIsDumpRes(Standard_False) {
char *pathdump = getenv("CSF_DEBUG_BOP");
myIsDump=(pathdump!=NULL);
myPath=pathdump;
OSD_Environment env("CSF_DEBUG_BOP");
TCollection_AsciiString pathdump = env.Value();
myIsDump = (!pathdump.IsEmpty() ? Standard_True: Standard_False);
myPath=pathdump.ToCString();
};
//
virtual ~BRepAlgoAPI_DumpOper() {

View File

@@ -23,31 +23,6 @@
#include <gp_Dir.hxx>
#include <Standard_DomainError.hxx>
static gp_Ax2 ConeComputeAxes() {
static Standard_Integer firsttime=1;
static Standard_Integer modif=0;
static Standard_Real cosa=cos(0.122);
static Standard_Real sina=sin(0.122);
static Standard_Real ux=1.0;
static Standard_Real uy=0.0;
if(firsttime) {
modif = getenv("PRIM_CONE") != NULL;
firsttime = 0;
}
if(modif) {
Standard_Real nux = cosa*ux+sina*uy;
Standard_Real nuy =-sina*ux+cosa*uy;
ux=nux; uy=nuy;
return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
}
else {
return(gp::XOY());
}
}
//=======================================================================
//function : BRepPrimAPI_MakeCone
//purpose :
@@ -56,7 +31,7 @@ static gp_Ax2 ConeComputeAxes() {
BRepPrimAPI_MakeCone::BRepPrimAPI_MakeCone(const Standard_Real R1,
const Standard_Real R2,
const Standard_Real H) :
myCone(ConeComputeAxes(),R1, R2, H)
myCone(gp::XOY(),R1, R2, H)
{
}

View File

@@ -23,32 +23,6 @@
#include <gp_Dir.hxx>
#include <Standard_DomainError.hxx>
static gp_Ax2 CylinderComputeAxes() {
static Standard_Integer firsttime=1;
static Standard_Integer modif=0;
static Standard_Real cosa=cos(0.1);
static Standard_Real sina=sin(0.1);
static Standard_Real ux=1.0;
static Standard_Real uy=0.0;
if(firsttime) {
modif = getenv("PRIM_CYLINDER") != NULL;
firsttime = 0;
}
if(modif) {
Standard_Real nux = cosa*ux+sina*uy;
Standard_Real nuy =-sina*ux+cosa*uy;
ux=nux; uy=nuy;
return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
}
else {
return(gp::XOY());
}
}
//=======================================================================
//function : BRepPrimAPI_MakeCylinder
//purpose :
@@ -56,7 +30,7 @@ static gp_Ax2 CylinderComputeAxes() {
BRepPrimAPI_MakeCylinder::BRepPrimAPI_MakeCylinder(const Standard_Real R,
const Standard_Real H) :
myCylinder(CylinderComputeAxes(), R , H)
myCylinder(gp::XOY(), R , H)
{
}

View File

@@ -24,37 +24,13 @@
#include <gp_Pnt.hxx>
#include <Standard_DomainError.hxx>
static gp_Ax2 SphereComputeAxes() {
static Standard_Integer firsttime=1;
static Standard_Integer modif=0;
static Standard_Real cosa=cos(0.111);
static Standard_Real sina=sin(0.111);
static Standard_Real ux=1.0;
static Standard_Real uy=0.0;
if(firsttime) {
modif = getenv("PRIM_SPHERE") != NULL;
firsttime = 0;
}
if(modif) {
Standard_Real nux = cosa*ux+sina*uy;
Standard_Real nuy =-sina*ux+cosa*uy;
ux=nux; uy=nuy;
return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0)));
}
else {
return(gp::XOY());
}
}
//=======================================================================
//function : BRepPrimAPI_MakeSphere
//purpose :
//=======================================================================
BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R) :
mySphere(SphereComputeAxes(),R)
mySphere(gp::XOY(),R)
{
}

View File

@@ -53,7 +53,6 @@
#include <gp_GTrsf2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_TrsfForm.hxx>
#include <OSD_Chronometer.hxx>
#include <ProjLib_ComputeApprox.hxx>
#include <ProjLib_ComputeApproxOnPolarSurface.hxx>
#include <Standard_NoSuchObject.hxx>

View File

@@ -69,7 +69,6 @@
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Sphere.hxx>
#include <OSD_Chronometer.hxx>
#include <Precision.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_OutOfRange.hxx>
@@ -92,14 +91,20 @@
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#ifdef OCCT_DEBUG
#include <OSD_Chronometer.hxx>
#endif
#include <stdio.h>
// include - all hxx,
// - all small static functions.
//======================== START STATIC FUNCTIONS ============
// variables for performance
Standard_Real t_mkcurve;
#ifdef OCCT_DEBUG
extern void ChFi3d_InitChron(OSD_Chronometer& ch);
extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
#endif
#ifdef DRAW
static Standard_Boolean Affich = Standard_False;
static char name[100];

View File

@@ -32,52 +32,14 @@ class CDF_Store;
class CDF_MetaDataDriver;
class CDF_FWOSDriver;
class CDF_MetaDataDriverFactory;
class CDF_Timer;
class CDF
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT static void GetLicense (const Standard_Integer anApplicationIdentifier);
Standard_EXPORT static Standard_Boolean IsAvailable (const Standard_Integer anApplicationIdentifier);
protected:
private:
friend class CDF_Directory;
friend class CDF_DirectoryIterator;
friend class CDF_Session;
friend class CDF_Application;
friend class CDF_StoreList;
friend class CDF_Store;
friend class CDF_MetaDataDriver;
friend class CDF_FWOSDriver;
friend class CDF_MetaDataDriverFactory;
friend class CDF_Timer;
};
#endif // _CDF_HeaderFile

View File

@@ -20,7 +20,6 @@
#include <CDF_Directory.hxx>
#include <CDF_MetaDataDriver.hxx>
#include <CDF_Session.hxx>
#include <CDF_Timer.hxx>
#include <CDM_CanCloseStatus.hxx>
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
@@ -99,11 +98,8 @@ Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString&
Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString& aFolder,
const TCollection_ExtendedString& aName,
const TCollection_ExtendedString& aVersion,
const Standard_Boolean UseStorageConfiguration) {
#ifdef OCCT_DEBUG
CDF_Timer theTimer;
#endif
const Standard_Boolean UseStorageConfiguration)
{
Handle(CDM_MetaData) theMetaData;
if(aVersion.Length() == 0)
@@ -111,28 +107,14 @@ Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString
else
theMetaData=theMetaDataDriver->MetaData(aFolder,aName,aVersion);
#ifdef OCCT_DEBUG
theTimer.ShowAndRestart("Getting MetaData: ");
#endif
CDF_TypeOfActivation theTypeOfActivation=TypeOfActivation(theMetaData);
Handle(CDM_Document) theDocument=Retrieve(theMetaData,UseStorageConfiguration,Standard_False);
#ifdef OCCT_DEBUG
theTimer.ShowAndRestart("Creating Transient: ");
#endif
CDF_Session::CurrentSession()->Directory()->Add(theDocument);
Activate(theDocument,theTypeOfActivation);
#ifdef OCCT_DEBUG
theTimer.ShowAndStop("Activate: ");
#endif
theDocument->Open(this);
return theDocument;
}
//=======================================================================
@@ -150,25 +132,13 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&
//=======================================================================
PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) {
#ifdef OCCT_DEBUG
CDF_Timer theTimer;
#endif
if (!theMetaDataDriver->Find(aFolder,aName,aVersion))
return PCDM_RS_UnknownDocument;
else if (!theMetaDataDriver->HasReadPermission(aFolder,aName,aVersion))
return PCDM_RS_PermissionDenied;
else {
#ifdef OCCT_DEBUG
theTimer.ShowAndRestart("theMetaDataDriver->Find: ");
#endif
Handle(CDM_MetaData) theMetaData = theMetaDataDriver->MetaData(aFolder,aName,aVersion);
#ifdef OCCT_DEBUG
theTimer.ShowAndStop("Getting MetaData: ");
#endif
if(theMetaData->IsRetrieved()) {
return theMetaData->Document()->IsModified()
? PCDM_RS_AlreadyRetrievedAndModified : PCDM_RS_AlreadyRetrieved;
@@ -199,11 +169,8 @@ PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString&
}
}
return PCDM_RS_OK;
}
//=======================================================================
//function : Activate
//purpose :

View File

@@ -20,7 +20,6 @@
#include <CDF_MetaDataDriverError.hxx>
#include <CDF_Session.hxx>
#include <CDF_StoreList.hxx>
#include <CDF_Timer.hxx>
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
#include <CDM_ReferenceIterator.hxx>
@@ -28,9 +27,7 @@
#include <PCDM_Document.hxx>
#include <PCDM_StorageDriver.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Macro.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList,Standard_Transient)
@@ -112,15 +109,9 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData, TCollect
}
TCollection_ExtendedString theName=theMetaDataDriver->BuildFileName(theDocument);
CDF_Timer theTimer;
aDocumentStorageDriver->Write(theDocument,theName);
status = aDocumentStorageDriver->GetStoreStatus();
theTimer.ShowAndRestart("Driver->Write: ");
aMetaData = theMetaDataDriver->CreateMetaData(theDocument,theName);
theTimer.ShowAndStop("metadata creating: ");
theDocument->SetMetaData(aMetaData);
CDM_ReferenceIterator it(theDocument);

View File

@@ -1,49 +0,0 @@
// Created on: 1998-07-17
// Created by: Jean-Louis Frenkel
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <CDF_Timer.hxx>
#include <stdlib.h>
CDF_Timer::CDF_Timer() {
myTimer.Start();
}
void CDF_Timer::ShowAndRestart(const Standard_CString aMessage) {
if(MustShow()) {
Show(aMessage);
myTimer.Reset();
myTimer.Start();
}
}
void CDF_Timer::ShowAndStop(const Standard_CString aMessage) {
if(MustShow()) {
Show(aMessage);
myTimer.Stop();
}
}
void CDF_Timer::Show(const Standard_CString aMessage) {
Standard_Integer minutes,hours; Standard_Real seconds,CPUtime;
myTimer.Show(seconds,minutes,hours,CPUtime);
cout << aMessage << hours << "h " << minutes << "' " << seconds << "'' (cpu: " << CPUtime << ")" << endl;
}
Standard_Boolean CDF_Timer::MustShow() {
static Standard_Boolean theMustShow=getenv("STORETIMER") != NULL;
return theMustShow;
}

View File

@@ -1,71 +0,0 @@
// Created on: 1998-07-17
// Created by: Jean-Louis Frenkel
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _CDF_Timer_HeaderFile
#define _CDF_Timer_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <OSD_Timer.hxx>
#include <Standard_CString.hxx>
#include <Standard_Boolean.hxx>
class CDF_Timer
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT CDF_Timer();
Standard_EXPORT void ShowAndRestart (const Standard_CString aMessage);
Standard_EXPORT void ShowAndStop (const Standard_CString aMessage);
Standard_EXPORT Standard_Boolean MustShow();
protected:
private:
Standard_EXPORT void Show (const Standard_CString aMessage);
OSD_Timer myTimer;
};
#endif // _CDF_Timer_HeaderFile

View File

@@ -21,7 +21,5 @@ CDF_StoreList.cxx
CDF_StoreList.hxx
CDF_StoreSetNameStatus.hxx
CDF_SubComponentStatus.hxx
CDF_Timer.cxx
CDF_Timer.hxx
CDF_TryStoreStatus.hxx
CDF_TypeOfActivation.hxx

View File

@@ -161,7 +161,6 @@
#include <ChFi3d_Builder_0.hxx>
#ifdef OCCT_DEBUG
#include <OSD_Chronometer.hxx>
extern Standard_Boolean ChFi3d_GetcontextFORCEBLEND();
extern Standard_Boolean ChFi3d_GettraceDRAWINT();
extern Standard_Boolean ChFi3d_GettraceDRAWENLARGE();
@@ -169,8 +168,6 @@ extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
extern Standard_Real t_sameparam, t_batten;
extern void ChFi3d_SettraceDRAWINT(const Standard_Boolean b);
extern void ChFi3d_SettraceDRAWSPINE(const Standard_Boolean b);
extern void ChFi3d_InitChron(OSD_Chronometer& ch);
extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
#endif
#include <stdio.h>

View File

@@ -100,11 +100,6 @@
#include <TopTools_ListOfShape.hxx>
#include <stdio.h>
#ifdef OCCT_DEBUG
// For measurements.
#include <OSD_Chronometer.hxx>
//static OSD_Chronometer appclock;
#endif
//#define DRAW

View File

@@ -33,13 +33,13 @@
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Ax1.hxx>
#include <OSD_Chronometer.hxx>
#ifdef DRAW
#include <DBRep.hxx>
#endif
#ifdef OCCT_DEBUG
#include <OSD_Chronometer.hxx>
OSD_Chronometer simul,elspine,chemine;
#endif
@@ -169,6 +169,7 @@ void ChFi3d_SetcontextNOOPT(const Standard_Boolean b)
Standard_Boolean ChFi3d_GetcontextNOOPT()
{ return ChFi3d_contextNOOPT; }
#ifdef OCCT_DEBUG
// ***********************************************
// initialization and result of a chrono
//************************************************
@@ -186,7 +187,7 @@ Standard_EXPORT void ChFi3d_ResultChron( OSD_Chronometer & ch,
ch.Show(tch);
time=time +tch;
}
#endif
//==============================================================
// function : ChFi3d_CheckSurfData

View File

@@ -71,6 +71,7 @@
#include <TopTools_ListIteratorOfListOfShape.hxx>
#ifdef OCCT_DEBUG
#include <OSD_Chronometer.hxx>
extern Standard_Boolean ChFi3d_GettraceCHRON();
extern Standard_Real t_computedata ,t_completedata;

View File

@@ -37,10 +37,10 @@ IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SessionPilot,IFSelect_Activator)
#define MAXCARS 1000
static int initactor = 0;
static char* trace;
static TCollection_AsciiString nulword;
//#define DEBUG_TRACE
// Nb Maxi de words : cf thewords et method SetCommandLine
IFSelect_SessionPilot::IFSelect_SessionPilot (const Standard_CString prompt)
@@ -57,7 +57,6 @@ static TCollection_AsciiString nulword;
Add (4,"xsource");
Add (5,"xstep");
Add (6,"xnew");
trace = getenv("DEBUGMODE");
}
@@ -100,7 +99,9 @@ static TCollection_AsciiString nulword;
if (thenbwords >= MAXWORDS) { unarg[nc] = val; nc ++; continue; }
unarg[nc] = '\0';
thewords(thenbwords).Clear(); thewords(thenbwords).AssignCat(unarg);
if (trace) cout<<"thewords("<<thenbwords<<") ="<<unarg<<endl;
#ifdef DEBUG_TRACE
cout<<"thewords("<<thenbwords<<") ="<<unarg<<endl;
#endif
thenbwords ++; nc = 0;
continue;
}
@@ -111,7 +112,9 @@ static TCollection_AsciiString nulword;
if (nc > 0) {
unarg[nc] = '\0'; thewords(thenbwords).Clear();
thewords(thenbwords).AssignCat(unarg);
if (trace) cout<<"thewords("<<thenbwords<<")="<<unarg<<endl<<" .. Fin avec thenbwords="<<thenbwords+1<<endl;
#ifdef DEBUG_TRACE
cout<<"thewords("<<thenbwords<<")="<<unarg<<endl<<" .. Fin avec thenbwords="<<thenbwords+1<<endl;
#endif
thenbwords ++;
}
/*

View File

@@ -33,7 +33,6 @@ class OSD_File;
class OSD_FileIterator;
class OSD_Directory;
class OSD_DirectoryIterator;
class OSD_Chronometer;
class OSD_Timer;
class OSD_Printer;
class OSD_Host;

View File

@@ -136,10 +136,15 @@ static inline __int64 EncodeFILETIME (PFILETIME pFt)
//=======================================================================
void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
{
#ifndef OCCT_UWP
FILETIME ftStart, ftExit, ftKernel, ftUser;
::GetProcessTimes (GetCurrentProcess(), &ftStart, &ftExit, &ftKernel, &ftUser);
UserSeconds = 0.0000001 * EncodeFILETIME (&ftUser);
SystemSeconds = 0.0000001 * EncodeFILETIME (&ftKernel);
#else
UserSeconds = 0.0;
SystemSeconds = 0.0;
#endif
}
//=======================================================================
@@ -148,10 +153,15 @@ void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real&
//=======================================================================
void OSD_Chronometer::GetThreadCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
{
#ifndef OCCT_UWP
FILETIME ftStart, ftExit, ftKernel, ftUser;
::GetThreadTimes (GetCurrentThread(), &ftStart, &ftExit, &ftKernel, &ftUser);
UserSeconds = 0.0000001 * EncodeFILETIME (&ftUser);
SystemSeconds = 0.0000001 * EncodeFILETIME (&ftKernel);
#else
UserSeconds = 0.0;
SystemSeconds = 0.0;
#endif
}
#endif /* _WIN32 */

View File

@@ -84,6 +84,7 @@ char name[] = "/tmp/CSFXXXXXX";
#include <OSD_Protection.hxx>
#include <Standard_ProgramError.hxx>
#include <TCollection_ExtendedString.hxx>
#include <NCollection_String.hxx>
#include <OSD_WNT_1.hxx>
@@ -110,7 +111,7 @@ OSD_Directory :: OSD_Directory ( const OSD_Path& Name ) :
} // end constructor ( 2 )
void OSD_Directory :: Build (const OSD_Protection& Protect ) {
void OSD_Directory :: Build (const OSD_Protection& Protect) {
TCollection_AsciiString dirName;
@@ -118,15 +119,15 @@ void OSD_Directory :: Build (const OSD_Protection& Protect ) {
if ( dirName.IsEmpty () )
Standard_ProgramError :: Raise (
TEXT( "OSD_Directory :: Build (): incorrect call - no directory name" )
);
Standard_ProgramError :: Raise ( "OSD_Directory :: Build (): incorrect call - no directory name");
TCollection_ExtendedString dirNameW(dirName);
if ( Exists () || CreateDirectoryW ( (const wchar_t*) dirNameW.ToExtString (), NULL ) )
SetProtection ( Protect );
else
if (Exists() || CreateDirectoryW((const wchar_t*)dirNameW.ToExtString(), NULL)) {
#ifndef OCCT_UWP
SetProtection(Protect);
#else
(void)Protect;
#endif
} else
_osd_wnt_set_error ( myError, OSD_WDirectory );
@@ -136,7 +137,10 @@ OSD_Directory OSD_Directory :: BuildTemporary () {
OSD_Directory retVal;
OSD_Protection prt;
OSD_Path dirPath ( tctmpnam ( NULL ) );
wchar_t* aName = _wtmpnam(NULL);
NCollection_String aFolder(aName != NULL ? aName : L"");
OSD_Path dirPath(aFolder.ToCString());
retVal.SetPath ( dirPath );
retVal.Build ( prt );

View File

@@ -239,7 +239,7 @@ Standard_Boolean OSD_DirectoryIterator :: More () {
// make wchar_t string from UTF-8
TCollection_ExtendedString wcW(wc);
myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
myHandle = FindFirstFileExW ((const wchar_t*)wcW.ToExtString(), FindExInfoStandard, (PWIN32_FIND_DATAW)myData, FindExSearchNameMatch, NULL, 0);
if ( myHandle == INVALID_HANDLE_VALUE )

View File

@@ -162,6 +162,8 @@ Standard_Integer OSD_Disk::Error()const{
#include <OSD_OSDError.hxx>
#include <OSD_Path.hxx>
#include <Standard_ProgramError.hxx>
#include <NCollection_String.hxx>
#include <TCollection_ExtendedString.hxx>
#include <windows.h>
@@ -170,14 +172,22 @@ void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString&, const OSD_Path& );
OSD_Disk :: OSD_Disk () {
TCHAR cwd[ MAX_PATH ];
GetCurrentDirectory ( MAX_PATH, cwd );
cwd[ 3 ] = TEXT( '\x00' );
DiskName = cwd;
DWORD aBuffLen = GetCurrentDirectoryW(0, NULL);
wchar_t* aBuff = new wchar_t[size_t(aBuffLen) + 1];
GetCurrentDirectoryW(aBuffLen, aBuff);
aBuff[aBuffLen - 1] = (aBuff[aBuffLen - 2] == L'\\') ? L'\0' : L'\\';
aBuff[aBuffLen] = L'\0';
if (aBuffLen > 3 && aBuff[0] != L'\\')
{
aBuff[3] = L'\0';
NCollection_String aFolder(aBuff);
DiskName = aFolder.ToCString();
delete[] aBuff;
}
else
{
DiskName = "";
}
} // end constructor ( 1 )
OSD_Disk :: OSD_Disk ( const OSD_Path& Name ) {
@@ -223,8 +233,8 @@ Standard_Integer OSD_Disk :: DiskSize () {
ULARGE_INTEGER lpTotalNumberOfBytes; // receives the number of bytes on disk
ULARGE_INTEGER lpTotalNumberOfFreeBytes;// receives the free bytes on disk
if (!GetDiskFreeSpaceEx (DiskName.ToCString (),
TCollection_ExtendedString DiskNameW(DiskName);
if (!GetDiskFreeSpaceExW ((const wchar_t*)DiskNameW.ToExtString(),
&lpFreeBytesAvailableToCaller,
&lpTotalNumberOfBytes,
&lpTotalNumberOfFreeBytes))
@@ -261,8 +271,8 @@ Standard_Integer OSD_Disk :: DiskFree () {
ULARGE_INTEGER lpTotalNumberOfFreeBytes;// receives the free bytes on disk
// if ( !GetDiskFreeSpace ( DiskName.ToCString (), &dwSpC, &dwBpS, &dwFC, &dwC ) )
if (!GetDiskFreeSpaceEx (DiskName.ToCString (),
TCollection_ExtendedString DiskNameW(DiskName);
if (!GetDiskFreeSpaceExW((const wchar_t*)DiskNameW.ToExtString(),
&lpFreeBytesAvailableToCaller,
&lpTotalNumberOfBytes,
&lpTotalNumberOfFreeBytes))
@@ -349,26 +359,26 @@ static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString& result,
dir = path.Trek ();
if ( ( j = dir.UsefullLength () ) > 2 &&
dir.Value ( 1 ) == TEXT( '|' ) &&
dir.Value ( 2 ) == TEXT( '|' )
dir.Value ( 1 ) == '|' &&
dir.Value ( 2 ) == '|'
) {
dir.SetValue ( 1, TEXT( '\\' ) );
dir.SetValue ( 2, TEXT( '\\' ) );
dir.SetValue ( 1, '\\');
dir.SetValue ( 2, '\\');
for ( i = 3, k = 0; i <= j; ++i )
if ( dir.Value ( i ) == TEXT( '|' ) ) {
if ( dir.Value ( i ) == '|') {
if ( k == 0 ) {
dir.SetValue ( i, TEXT( "\\" ) );
dir.SetValue ( i, '\\');
++k;
continue;
} // end if
dir.SetValue ( i, TEXT( "\\" ) );
dir.SetValue ( i, '\\');
break;
} /* end if */
@@ -381,14 +391,14 @@ static void __fastcall _osd_wnt_set_disk_name ( TCollection_AsciiString& result,
else {
dir += TEXT( "\\" );
dir += '\\';
dir += path.Name ();
dir += path.Extension ();
} // end else
}
if ( dir.Value ( dir.UsefullLength () ) != TEXT( '\\' ) ) dir += TEXT( "\\" );
if ( dir.Value ( dir.UsefullLength () ) != '\\') dir += '\\';
result = dir;
@@ -398,7 +408,7 @@ badPath:
} // end else
} else result += TEXT( "/" );
} else result += '/';
} // end _osd_set_disk_name

View File

@@ -246,7 +246,9 @@ Standard_Integer OSD_Environment::Error() const
#pragma warning( disable : 4700 )
#endif
#ifndef OCCT_UWP
static void __fastcall _set_error ( OSD_Error&, DWORD );
#endif
OSD_Environment :: OSD_Environment () {
@@ -276,6 +278,7 @@ void OSD_Environment :: SetValue ( const TCollection_AsciiString& Value ) {
TCollection_AsciiString OSD_Environment::Value()
{
#ifndef OCCT_UWP
myValue.Clear();
SetLastError (ERROR_SUCCESS);
@@ -306,6 +309,10 @@ TCollection_AsciiString OSD_Environment::Value()
}
myValue = aValue.ToCString();
return myValue;
#else
myValue = "";
return myValue;
#endif
}
void OSD_Environment :: SetName ( const TCollection_AsciiString& name ) {
@@ -322,14 +329,18 @@ TCollection_AsciiString OSD_Environment :: Name () const {
void OSD_Environment::Build()
{
#ifndef OCCT_UWP
NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=" + myValue.ToCString();
_wputenv (aSetVariable.ToUtfWide().ToCString());
#endif
}
void OSD_Environment::Remove()
{
#ifndef OCCT_UWP
NCollection_Utf8String aSetVariable = NCollection_Utf8String(myName.ToCString()) + "=";
_wputenv (aSetVariable.ToUtfWide().ToCString());
#endif
}
Standard_Boolean OSD_Environment :: Failed () const {
@@ -355,6 +366,7 @@ Standard_Integer OSD_Environment :: Error () const {
} // end OSD_Environment :: Error
#ifndef OCCT_UWP
static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
DWORD errCode;
@@ -377,5 +389,6 @@ static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
err.SetValue ( errCode, OSD_WEnvironment, buffer );
} // end _set_error
#endif
#endif

View File

@@ -449,6 +449,7 @@ void OSD_Error::Perror() {
#include <TCollection_ExtendedString.hxx>
#include <windows.h>
#include <Strsafe.h>
typedef struct _error_table {
@@ -570,82 +571,60 @@ OSD_Error :: OSD_Error () :
void OSD_Error :: Perror () {
Standard_Character buff[ 32 ];
Standard_CString ptr;
wchar_t buff[32];
lstrcpy ( buff, "Error ( " );
StringCchCopyW(buff, _countof(buff), L"Error ( ");
switch ( myCode ) {
case OSD_WDirectoryIterator:
ptr = "OSD_DirectoryIterator";
StringCchCatW(buff, _countof(buff), L"OSD_DirectoryIterator");
break;
case OSD_WDirectory:
ptr = "OSD_Directory";
StringCchCatW(buff, _countof(buff), L"OSD_Directory");
break;
case OSD_WFileIterator:
ptr = "OSD_FileIterator";
StringCchCatW(buff, _countof(buff), L"OSD_FileIterator");
break;
case OSD_WFile:
ptr = "OSD_File";
StringCchCatW(buff, _countof(buff), L"OSD_File");
break;
case OSD_WFileNode:
ptr = "OSD_FileNode";
StringCchCatW(buff, _countof(buff), L"OSD_FileNode");
break;
case OSD_WHost:
ptr = "OSD_Host";
StringCchCatW(buff, _countof(buff), L"OSD_Host");
break;
case OSD_WProcess:
ptr = "OSD_Environment";
StringCchCatW(buff, _countof(buff), L"OSD_Environment");
break;
case OSD_WEnvironmentIterator:
ptr = "OSD_EnvironmentIterator";
StringCchCatW(buff, _countof(buff), L"OSD_EnvironmentIterator");
break;
case OSD_WEnvironment:
ptr = "OSD_Environment";
StringCchCatW(buff, _countof(buff), L"OSD_Environment");
break;
case OSD_WDisk:
ptr = "OSD_Disk";
StringCchCatW(buff, _countof(buff), L"OSD_Disk");
break;
default:
ptr = "Unknown";
StringCchCatW(buff, _countof(buff), L"Unknown");
} // end switch
lstrcat ( buff, ptr );
lstrcat ( buff, " )" );
std::cerr << buff;
StringCchCatW(buff, _countof(buff), L" )");
std::wcerr << buff;
std::cerr << myMessage.ToCString() << std::endl << std::flush;

View File

@@ -839,6 +839,8 @@ void OSD_File::Rewind() {
# include <tchar.h>
#endif // _INC_TCHAR
#include <Strsafe.h>
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#define VAC
#endif
@@ -858,15 +860,16 @@ void OSD_File::Rewind() {
#define OPEN_APPEND 2
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
#ifndef OCCT_UWP
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, const wchar_t* );
static int __fastcall _get_buffer(HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL);
#endif
static void __fastcall _test_raise ( HANDLE, Standard_CString );
static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD dwBuffSize, LONG& theSeekPos);
static int __fastcall _get_buffer ( HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL );
static DWORD __fastcall _get_access_mask ( OSD_SingleProtection );
static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt );
static HANDLE __fastcall _open_file ( Standard_CString, OSD_OpenMode, DWORD, LPBOOL = NULL );
@@ -942,7 +945,9 @@ int OSD_File::Capture(int theDescr) {
}
void OSD_File::Rewind() {
SetFilePointer( myFileHandle, 0, NULL, FILE_BEGIN );
LARGE_INTEGER aDistanceToMove = { 0 };
aDistanceToMove.QuadPart = 0;
SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_BEGIN);
}
// protect against occasional use of myFileHande in Windows code
@@ -952,9 +957,7 @@ void OSD_File::Rewind() {
// Build a file if it doesn't exist or create again if it already exists
// ---------------------------------------------------------------------
void OSD_File :: Build (
const OSD_OpenMode Mode, const OSD_Protection& Protect
) {
void OSD_File :: Build ( const OSD_OpenMode Mode, const OSD_Protection& Protect) {
TCollection_AsciiString fName;
@@ -980,8 +983,11 @@ void OSD_File :: Build (
_osd_wnt_set_error ( myError, OSD_WFile );
else {
#ifndef OCCT_UWP
SetProtection ( Protect );
#else
(void)Protect;
#endif
myIO |= FLAG_FILE;
} // end else
@@ -1027,9 +1033,7 @@ void OSD_File :: Open (const OSD_OpenMode Mode, const OSD_Protection& /*Protect*
// Append to an existing file
// ---------------------------------------------------------------------
void OSD_File :: Append (
const OSD_OpenMode Mode, const OSD_Protection& Protect
) {
void OSD_File :: Append ( const OSD_OpenMode Mode, const OSD_Protection& Protect) {
BOOL fNew = FALSE;
TCollection_AsciiString fName;
@@ -1059,8 +1063,11 @@ void OSD_File :: Append (
Seek ( 0, OSD_FromEnd );
} else {
SetProtection ( Protect );
#ifndef OCCT_UWP
SetProtection ( Protect );
#else
(void)Protect;
#endif
myIO |= FLAG_FILE;
} // end else
@@ -1170,12 +1177,13 @@ void OSD_File :: ReadLine (
} else if ( dwDummy != 0 ) { // end-of-file reached ?
if ( peekChar != '\n' ) // if we did not get a <CR><LF> sequence
// adjust file position
SetFilePointer (myFileHandle, -1, NULL, FILE_CURRENT);
if (peekChar != '\n') // if we did not get a <CR><LF> sequence
{
// adjust file position
LARGE_INTEGER aDistanceToMove = { 0 };
aDistanceToMove.QuadPart = -1;
SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_CURRENT);
}
} else
myIO |= FLAG_EOF;
@@ -1183,13 +1191,15 @@ void OSD_File :: ReadLine (
} else if ( aSeekPos != 0 )
{
SetFilePointer (myFileHandle, aSeekPos, NULL, FILE_CURRENT);
LARGE_INTEGER aDistanceToMove = { 0 };
aDistanceToMove.QuadPart = aSeekPos;
SetFilePointerEx(myFileHandle, aDistanceToMove, NULL, FILE_CURRENT);
}
} // end else
} else if ( myIO & FLAG_SOCKET || myIO & FLAG_PIPE || myIO & FLAG_NAMED_PIPE ) {
#ifndef OCCT_UWP
dwBytesRead = (DWORD)_get_buffer (myFileHandle, cBuffer,
(DWORD)NByte, TRUE, myIO & FLAG_SOCKET);
@@ -1241,7 +1251,7 @@ void OSD_File :: ReadLine (
delete [] cDummyBuffer ;
} // end else
#endif
} else
RAISE( "OSD_File :: ReadLine (): incorrect call - file is a directory" );
@@ -1360,8 +1370,10 @@ void OSD_File :: Seek (
RAISE( "OSD_File :: Seek (): invalid parameter" );
} // end switch
LARGE_INTEGER aDistanceToMove, aNewFilePointer = { 0 };
aDistanceToMove.QuadPart = Offset;
if (SetFilePointer (myFileHandle, (LONG)Offset, NULL, dwMoveMethod) == 0xFFFFFFFF)
if (!SetFilePointerEx(myFileHandle, aDistanceToMove, &aNewFilePointer, dwMoveMethod))
_osd_wnt_set_error ( myError, OSD_WFile );
@@ -1464,9 +1476,13 @@ typedef struct _osd_wnt_key {
void OSD_File::BuildTemporary () {
OSD_Protection prt;
HKEY hKey;
TCHAR tmpPath[ MAX_PATH ];
wchar_t tmpPath[ MAX_PATH ];
BOOL fOK = FALSE;
// Windows Registry not supported by UWP
#ifndef OCCT_UWP
HKEY hKey;
OSD_WNT_KEY regKey[ 2 ] = {
{ HKEY_LOCAL_MACHINE,
@@ -1488,25 +1504,25 @@ typedef struct _osd_wnt_key {
DWORD dwType;
DWORD dwSize = 0;
if ( RegQueryValueEx (
hKey, "TEMP", NULL, &dwType, NULL, &dwSize
if ( RegQueryValueExW (
hKey, L"TEMP", NULL, &dwType, NULL, &dwSize
) == ERROR_SUCCESS
) {
LPTSTR kVal = ( LPTSTR )HeapAlloc (
wchar_t* kVal = (wchar_t*)HeapAlloc (
GetProcessHeap (), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS,
dwSize + sizeof ( TCHAR )
dwSize + sizeof (wchar_t)
);
RegQueryValueEx ( hKey, "TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize );
RegQueryValueExW ( hKey, L"TEMP", NULL, &dwType, ( LPBYTE )kVal, &dwSize );
if ( dwType == REG_EXPAND_SZ )
ExpandEnvironmentStrings ( kVal, tmpPath, MAX_PATH );
ExpandEnvironmentStringsW ( kVal, tmpPath, MAX_PATH );
else
lstrcpy ( tmpPath, kVal );
StringCchCopyW (tmpPath, _countof(tmpPath), kVal);
HeapFree ( GetProcessHeap (), 0, ( LPVOID )kVal );
fOK = TRUE;
@@ -1520,15 +1536,21 @@ typedef struct _osd_wnt_key {
if ( fOK ) break;
} // end for
#else
if (GetTempPathW(_countof(tmpPath), tmpPath))
fOK = TRUE;
#endif
if ( !fOK ) StringCchCopyW(tmpPath, _countof(tmpPath), L"./");
if ( !fOK ) lstrcpy ( tmpPath, "./" );
GetTempFileName ( tmpPath, "CSF", 0, tmpPath );
GetTempFileNameW ( tmpPath, L"CSF", 0, tmpPath );
if ( IsOpen() )
Close();
SetPath ( OSD_Path ( tmpPath ) );
char tmpPathA[MAX_PATH];
WideCharToMultiByte(CP_UTF8, 0, tmpPath, -1, tmpPathA, sizeof(tmpPathA), NULL, NULL);
SetPath(OSD_Path(tmpPathA));
Build ( OSD_ReadWrite, prt );
} // end OSD_File :: BuildTemporary
@@ -1598,8 +1620,12 @@ void OSD_File :: UnLock () {
LARGE_INTEGER aSize;
aSize.QuadPart = Size();
if (!UnlockFile (myFileHandle, 0, 0, aSize.LowPart, aSize.HighPart))
OVERLAPPED anOverlappedArea;
anOverlappedArea.Offset = 0;
anOverlappedArea.OffsetHigh = 0;
if (!UnlockFileEx(myFileHandle, 0, aSize.LowPart, aSize.HighPart,&anOverlappedArea))
_osd_wnt_set_error ( myError, OSD_WFile );
ImperativeFlag = Standard_False;
@@ -1651,9 +1677,8 @@ Standard_Size OSD_File::Size()
// --------------------------------------------------------------------------
// Print contains of a file
// --------------------------------------------------------------------------
void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
void OSD_File :: Print ( const OSD_Printer& WhichPrinter) {
#ifndef OCCT_UWP
if (myFileHandle != INVALID_HANDLE_VALUE)
RAISE( "OSD_File :: Print (): incorrect call - file opened" );
@@ -1668,9 +1693,10 @@ void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
(const wchar_t*)fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFile );
#else
(void)WhichPrinter;
#endif
} // end OSD_File :: Print
// --------------------------------------------------------------------------
// Test if a file is open
// --------------------------------------------------------------------------
@@ -1687,6 +1713,7 @@ Standard_Boolean OSD_File :: IsOpen () const {
#define __leave return retVal
#endif
#ifndef OCCT_UWP
PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd (
const OSD_Protection& prot, BOOL fDir, wchar_t* fName
) {
@@ -1945,6 +1972,7 @@ leave: ; // added for VisualAge
return retVal;
} // end _osd_wnt_protection_to_sd */
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try
@@ -1954,17 +1982,13 @@ leave: ; // added for VisualAge
static void __fastcall _test_raise ( HANDLE hFile, Standard_CString str ) {
Standard_Character buff[ 64 ];
if (hFile == INVALID_HANDLE_VALUE) {
TCollection_AsciiString buff = "OSD_File :: ";
buff += str;
buff += " (): wrong access";
if (hFile == INVALID_HANDLE_VALUE) {
strcpy ( buff, "OSD_File :: " );
strcat ( buff, str );
strcat ( buff, " (): wrong access" );
Standard_ProgramError :: Raise ( buff );
} // end if
Standard_ProgramError::Raise(buff.ToCString());
} // end if
} // end _test_raise
@@ -2006,6 +2030,7 @@ static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD
return dwBuffSize;
} // end _get_line
#ifndef OCCT_UWP
static int __fastcall _get_buffer (
HANDLE hChannel,
Standard_PCharacter& buffer,
@@ -2283,7 +2308,7 @@ static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ) {
return retVal;
} // end _get_dir_access_mask
#endif
static HANDLE __fastcall _open_file (
Standard_CString fName,
OSD_OpenMode oMode,
@@ -2324,12 +2349,24 @@ static HANDLE __fastcall _open_file (
// make wide character string from UTF-8
TCollection_ExtendedString fNameW(fName, Standard_True);
#ifndef OCCT_UWP
retVal = CreateFileW (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
);
#else
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {};
pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams.lpSecurityAttributes = NULL;
pCreateExParams.hTemplateFile = NULL;
retVal = CreateFile2 (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
dwCreationDistribution, &pCreateExParams
);
#endif
if ( retVal == INVALID_HANDLE_VALUE &&
dwOptions == OPEN_APPEND &&
GetLastError () == ERROR_FILE_NOT_FOUND
@@ -2337,12 +2374,24 @@ static HANDLE __fastcall _open_file (
dwCreationDistribution = CREATE_ALWAYS;
#ifndef OCCT_UWP
retVal = CreateFileW (
(const wchar_t*) fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
);
#else
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams2 = {};
pCreateExParams2.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams2.lpSecurityAttributes = NULL;
pCreateExParams2.hTemplateFile = NULL;
retVal = CreateFile2(
(const wchar_t*)fNameW.ToExtString(), dwDesiredAccess,
FILE_SHARE_READ | FILE_SHARE_WRITE,
dwCreationDistribution, &pCreateExParams2
);
#endif
*fNew = TRUE;
@@ -2357,7 +2406,6 @@ Standard_Integer __fastcall _get_file_type (
) {
Standard_Integer retVal = 0;
DWORD dwType;
int fileType;
fileType = (fileHandle == INVALID_HANDLE_VALUE ?
@@ -2375,10 +2423,11 @@ Standard_Integer __fastcall _get_file_type (
{
// 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;
WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
if (GetFileAttributesExW((const wchar_t*)fNameW.ToExtString(), GetFileExInfoStandard, &aFileInfo))
retVal = aFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
else
@@ -2410,6 +2459,8 @@ Standard_Integer __fastcall _get_file_type (
#define __leave return retVal
#endif
#ifndef OCCT_UWP
// None of the existing security APIs are supported in a UWP applications
BOOL __fastcall _osd_wnt_sd_to_protection (
PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL fDir
) {
@@ -2495,13 +2546,14 @@ leave: ; // added for VisualAge
return retVal;
} // end _osd_wnt_sd_to_protection
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try
#undef __finally
#undef __leave
#endif
#ifndef OCCT_UWP
static OSD_SingleProtection __fastcall _get_protection ( DWORD mask ) {
OSD_SingleProtection retVal;
@@ -2717,6 +2769,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
return retVal;
} // end _get_protection_dir
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#define __try
@@ -2724,6 +2777,7 @@ static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
#define __leave return fOK
#endif
#ifndef OCCT_UWP
BOOL __fastcall _osd_print (const Standard_PCharacter pName, const wchar_t* fName ) {
BOOL fOK, fJob;
@@ -2802,6 +2856,7 @@ leave: ; // added for VisualAge
return fOK;
} // end _osd_print
#endif
#if defined(__CYGWIN32__) || defined(__MINGW32__)
#undef __try

View File

@@ -317,7 +317,7 @@ Standard_Boolean OSD_FileIterator :: More () {
// make wchar_t string from UTF-8
TCollection_ExtendedString wcW(wc);
myHandle = FindFirstFileW ((const wchar_t*)wcW.ToExtString(), (PWIN32_FIND_DATAW)myData);
myHandle = FindFirstFileExW((const wchar_t*)wcW.ToExtString(), FindExInfoStandard, (PWIN32_FIND_DATAW)myData, FindExSearchNameMatch, NULL, 0);
if ( myHandle == INVALID_HANDLE_VALUE )

View File

@@ -363,6 +363,11 @@ Standard_Integer OSD_FileNode::Error()const{
//----------------------------------------------------------------------------
#define STRICT
#ifdef NONLS
#undef NONLS
#endif
#include <windows.h>
#include <OSD_FileNode.hxx>
#include <OSD_Protection.hxx>
#include <Quantity_Date.hxx>
@@ -375,13 +380,18 @@ Standard_Integer OSD_FileNode::Error()const{
# include <tchar.h>
#endif // _INC_TCHAR
#include <Strsafe.h>
#define TEST_RAISE( arg ) _test_raise ( fName, ( arg ) )
#define RAISE( arg ) Standard_ProgramError :: Raise ( ( arg ) )
#ifndef OCCT_UWP
// None of the existing security APIs are supported in a UWP applications
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
);
#endif
Standard_Integer __fastcall _get_file_type ( Standard_CString, HANDLE );
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
@@ -447,12 +457,14 @@ Standard_Boolean OSD_FileNode::Exists () {
// 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 )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
if ( !GetFileAttributesExW((const wchar_t*)fNameW.ToExtString(), GetFileExInfoStandard, &aFileInfo)) {
if ( GetLastError () != ERROR_FILE_NOT_FOUND )
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
} else
retVal = Standard_True;
@@ -480,9 +492,7 @@ void OSD_FileNode::Remove () {
case FLAG_FILE:
if ( !DeleteFileW ( (const wchar_t*) fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
break;
case FLAG_DIRECTORY:
@@ -492,16 +502,11 @@ void OSD_FileNode::Remove () {
// ne pas detruire un repertoire no vide.
if ( !RemoveDirectoryW ( (const wchar_t*) fNameW.ToExtString () ) )
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
break;
default:
RAISE( TEXT( "OSD_FileNode :: Remove ():"
" invalid file type - neither file nor directory" ) );
RAISE("OSD_FileNode :: Remove (): invalid file type - neither file nor directory");
} // end switch
} // end OSD_FileNode :: Remove
@@ -533,9 +538,7 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED
)
)
_osd_wnt_set_error ( myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString () );
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
case FLAG_DIRECTORY:
@@ -544,17 +547,11 @@ void OSD_FileNode::Move ( const OSD_Path& NewPath ) {
(const wchar_t*) fNameW.ToExtString (), (const wchar_t*) fNameDstW.ToExtString ()
)
)
_osd_wnt_set_error ( myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString () );
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
default:
RAISE( TEXT( "OSD_FileNode :: Move (): "
"invalid file type - neither file nor directory" ) );
RAISE("OSD_FileNode :: Move (): invalid file type - neither file nor directory");
} // end switch
} // end OSD_FileNode :: Move
@@ -580,11 +577,14 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
switch (_get_file_type (fName.ToCString(), INVALID_HANDLE_VALUE)) {
case FLAG_FILE:
if (!CopyFileW ((const wchar_t*)fNameW.ToExtString (),
(const wchar_t*)fNameDstW.ToExtString (), FALSE ))
_osd_wnt_set_error (myError, OSD_WFileNode,
fName.ToCString (), fNameDst.ToCString ());
#ifndef OCCT_UWP
if (!CopyFileW((const wchar_t*)fNameW.ToExtString(),
(const wchar_t*)fNameDstW.ToExtString(), FALSE))
#else
if (CopyFile2((const wchar_t*)fNameW.ToExtString (),
(const wchar_t*)fNameDstW.ToExtString (), FALSE ) != S_OK)
#endif
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
case FLAG_DIRECTORY:
@@ -593,22 +593,21 @@ void OSD_FileNode::Copy ( const OSD_Path& ToPath ) {
(const wchar_t*)fNameW.ToExtString (), (const wchar_t*)fNameDstW.ToExtString ()
)
)
_osd_wnt_set_error (
myError, OSD_WFileNode, fName.ToCString (), fNameDst.ToCString ()
);
_osd_wnt_set_error(myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString(), (const wchar_t*)fNameDstW.ToExtString());
break;
default:
RAISE( TEXT( "OSD_FileNode :: Copy ():"
" invalid file type - neither file nor directory" ) );
RAISE("OSD_FileNode :: Copy (): invalid file type - neither file nor directory");
} // end switch
} // end OSD_FileNode :: Copy
// None of the existing security APIs are supported in a UWP applications
#ifndef OCCT_UWP
//=======================================================================
//function : Protection
//purpose :
@@ -671,8 +670,7 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
(const wchar_t*) fNameW.ToExtString (), DACL_SECURITY_INFORMATION, pSD
)
)
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
if ( pSD != NULL )
@@ -680,6 +678,46 @@ void OSD_FileNode::SetProtection ( const OSD_Protection& Prot ) {
} // end OSD_FileNode :: SetProtection
#else /* UWP stub */
#include <io.h>
//=======================================================================
//function : Protection
//purpose :
//=======================================================================
OSD_Protection OSD_FileNode::Protection ()
{
TCollection_AsciiString fName;
myPath.SystemName ( fName );
TCollection_ExtendedString fNameW(fName);
OSD_SingleProtection aProt = OSD_None;
if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 6))
aProt = OSD_RW;
else if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 2))
aProt = OSD_W;
else if (_waccess_s ((const wchar_t*)fNameW.ToExtString(), 4))
aProt = OSD_R;
// assume full access for system and none for everybody
OSD_Protection retVal (OSD_RWXD, aProt, aProt, OSD_None);
return retVal;
} // end OSD_FileNode :: Protection
//=======================================================================
//function : SetProtection
//purpose :
//=======================================================================
void OSD_FileNode::SetProtection ( const OSD_Protection& /*Prot*/ )
{
} // end OSD_FileNode :: SetProtection
#endif
//=======================================================================
//function : AccessMoment
//purpose :
@@ -714,8 +752,7 @@ Quantity_Date OSD_FileNode::AccessMoment () {
);
}
else
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
return retVal;
@@ -755,8 +792,7 @@ Quantity_Date OSD_FileNode::CreationMoment () {
);
}
else
_osd_wnt_set_error ( myError, OSD_WFileNode, fName.ToCString () );
_osd_wnt_set_error ( myError, OSD_WFileNode, (const wchar_t*)fNameW.ToExtString());
return retVal;
@@ -809,26 +845,30 @@ Standard_Integer OSD_FileNode::Error () const {
void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) {
DWORD errCode;
Standard_Character buffer[ 2048 ];
wchar_t buffer[2048];
va_list arg_ptr;
va_start ( arg_ptr, who);
errCode = GetLastError ();
if ( !FormatMessage (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
if ( !FormatMessageW (
FORMAT_MESSAGE_FROM_SYSTEM,
0, errCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
buffer, 2048, &arg_ptr
)
) {
sprintf ( buffer, "error code %d", (Standard_Integer)errCode );
StringCchPrintfW(buffer, _countof(buffer), L"error code %d", (Standard_Integer)errCode);
SetLastError ( errCode );
} // end if
err.SetValue ( errCode, who, buffer );
char aBufferA[2048];
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
err.SetValue(errCode, who, aBufferA);
va_end ( arg_ptr );
@@ -851,11 +891,23 @@ static BOOL __fastcall _get_file_time (
HANDLE hFile = INVALID_HANDLE_VALUE;
__try {
if ( ( hFile = CreateFileW ((const wchar_t*) fName, 0, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
) == INVALID_HANDLE_VALUE
) __leave;
#ifndef OCCT_UWP
if ((hFile = CreateFileW((const wchar_t*)fName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
) == INVALID_HANDLE_VALUE
)
#else
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {};
pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams.lpSecurityAttributes = NULL;
pCreateExParams.hTemplateFile = NULL;
if ((hFile = CreateFile2(
(const wchar_t*)fName, NULL, NULL,
OPEN_EXISTING, &pCreateExParams)
) == INVALID_HANDLE_VALUE
)
#endif
__leave;
if ( !GetFileTime ( hFile, &ftCreationTime, NULL, &ftLastWriteTime ) ) __leave;
@@ -890,17 +942,12 @@ leave: ; // added for VisualAge
#endif
static void __fastcall _test_raise ( TCollection_AsciiString fName, Standard_CString str ) {
Standard_Character buff[ 64 ];
if ( fName.IsEmpty () ) {
strcpy ( buff, "OSD_FileNode :: " );
strcat ( buff, str );
strcat ( buff, " (): wrong access" );
TCollection_AsciiString buff = "OSD_FileNode :: ";
buff += str;
buff += " (): wrong access";
Standard_ProgramError :: Raise ( buff );
Standard_ProgramError::Raise(buff.ToCString());
} // end if
} // end _test_raise

View File

@@ -57,13 +57,14 @@ public:
//! Copies <me> to another FileNode
Standard_EXPORT void Copy (const OSD_Path& ToPath);
// None of the existing security APIs are supported in a UWP applications
//! Returns access mode of <me>.
Standard_EXPORT OSD_Protection Protection();
//! Changes protection of the FileNode
Standard_EXPORT void SetProtection (const OSD_Protection& Prot);
//! Returns last write access.
//! On UNIX, AccessMoment and CreationMoment return the
//! same value.

View File

@@ -200,7 +200,7 @@ static TCollection_AsciiString interAddr;
static Standard_Integer memSize;
OSD_Host :: OSD_Host () {
#ifndef OCCT_UWP
DWORD nSize;
Standard_Character szHostName[ MAX_COMPUTERNAME_LENGTH + 1 ];
char* hostAddr = 0;
@@ -280,7 +280,7 @@ OSD_Host :: OSD_Host () {
if ( fInit )
myName = hostName;
#endif
} // end constructor
TCollection_AsciiString OSD_Host :: SystemVersion () {

View File

@@ -57,7 +57,7 @@ void OSD_MemInfo::Update()
{
myCounters[anIter] = Standard_Size(-1);
}
#ifndef OCCT_UWP
#if defined(_WIN32)
#if (_WIN32_WINNT >= 0x0500)
MEMORYSTATUSEX aStatEx;
@@ -167,6 +167,7 @@ void OSD_MemInfo::Update()
myCounters[MemHeapUsage] = aStats.size_in_use;
}
#endif
#endif
}
// =======================================================================

View File

@@ -30,13 +30,14 @@
#endif
#endif
#ifdef _WIN32
#if defined(_WIN32) && !defined(OCCT_UWP)
namespace {
// for a 64-bit app running under 64-bit Windows, this is FALSE
static bool isWow64()
{
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE , PBOOL);
BOOL bIsWow64 = FALSE;
HMODULE aKern32Module = GetModuleHandleW(L"kernel32");
LPFN_ISWOW64PROCESS aFunIsWow64 = (aKern32Module == NULL) ? (LPFN_ISWOW64PROCESS )NULL
: (LPFN_ISWOW64PROCESS)GetProcAddress(aKern32Module, "IsWow64Process");
@@ -62,11 +63,14 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
#ifdef _WIN32
// GetSystemInfo() will return the number of processors in a data field in a SYSTEM_INFO structure.
SYSTEM_INFO aSysInfo;
#ifndef OCCT_UWP
if ( isWow64() )
{
typedef BOOL (WINAPI *LPFN_GSI)(LPSYSTEM_INFO );
HMODULE aKern32 = GetModuleHandleW(L"kernel32");
LPFN_GSI aFuncSysInfo = (LPFN_GSI )GetProcAddress(aKern32, "GetNativeSystemInfo");
// So, they suggest 32-bit apps should call this instead of the other in WOW64
if ( aFuncSysInfo != NULL )
{
@@ -81,6 +85,9 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
{
GetSystemInfo(&aSysInfo);
}
#else
GetNativeSystemInfo(&aSysInfo);
#endif
aNumLogicalProcessors = aSysInfo.dwNumberOfProcessors;
#else
// These are the choices. We'll check number of processors online.

View File

@@ -210,7 +210,7 @@ OSD_Process :: OSD_Process () {
Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
const Standard_Boolean ShowWindow /* = Standard_True */) {
#ifndef OCCT_UWP
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD aRes = 0;
@@ -248,6 +248,11 @@ Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
} // end else
return aRes;
#else
(void)cmd;
(void)ShowWindow;
return 0;
#endif
} // end OSD_Process :: Spawn
void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
@@ -273,6 +278,7 @@ Quantity_Date OSD_Process :: SystemDate () {
TCollection_AsciiString OSD_Process :: UserName ()
{
#ifndef OCCT_UWP
Standard_PCharacter pBuff = new char[UNLEN + 1];
DWORD dwSize = UNLEN + 1;
TCollection_AsciiString retVal;
@@ -287,10 +293,13 @@ TCollection_AsciiString OSD_Process :: UserName ()
}
delete [] pBuff;
return retVal;
#else
return "";
#endif
} // end OSD_Process :: UserName
Standard_Boolean OSD_Process :: IsSuperUser () {
#ifndef OCCT_UWP
Standard_Boolean retVal = FALSE;
PSID pSIDadmin;
HANDLE hProcessToken = INVALID_HANDLE_VALUE;
@@ -327,7 +336,9 @@ Standard_Boolean OSD_Process :: IsSuperUser () {
if ( pTKgroups != NULL ) FreeTokenInformation ( pTKgroups );
return retVal;
#else
return FALSE;
#endif
} // end OSD_Process :: IsSuperUser
Standard_Integer OSD_Process :: ProcessId () {
@@ -337,9 +348,8 @@ Standard_Integer OSD_Process :: ProcessId () {
} // end OSD_Process :: ProcessId
OSD_Path OSD_Process :: CurrentDirectory () {
OSD_Path anCurrentDirectory;
#ifndef OCCT_UWP
DWORD dwSize = PATHLEN + 1;
Standard_WideChar* pBuff = new wchar_t[dwSize];
@@ -353,6 +363,7 @@ OSD_Path OSD_Process :: CurrentDirectory () {
_osd_wnt_set_error ( myError, OSD_WProcess );
delete[] pBuff;
#endif
return anCurrentDirectory;
} // end OSD_Process :: CurrentDirectory

View File

@@ -184,13 +184,15 @@ void OSD_SharedLibrary::Destroy() {
#endif
#include <windows.h>
#include <OSD_Path.hxx>
#include <OSD_SharedLibrary.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
static DWORD lastDLLError;
static Standard_Character errMsg[ 1024 ];
static wchar_t errMsg[1024];
static char errMsgA[1024];
OSD_SharedLibrary :: OSD_SharedLibrary () {
@@ -224,7 +226,13 @@ void OSD_SharedLibrary :: SetName ( const Standard_CString aName ) {
name = path.Name ();
name.AssignCat ( path.Extension () );
myHandle = GetModuleHandle ( name.ToCString () );
#ifndef OCCT_UWP
myHandle = GetModuleHandle(name.ToCString());
#else
TCollection_ExtendedString nameW(name);
myHandle = LoadPackagedLibrary ((const wchar_t*)nameW.ToExtString(), NULL );
FreeLibrary ((HMODULE) myHandle);
#endif
} // end OSD_SharedLibrary :: SetName
@@ -238,15 +246,17 @@ Standard_Boolean OSD_SharedLibrary :: DlOpen ( const OSD_LoadMode /*Mode*/ ) {
Standard_Boolean retVal = Standard_True;
if ( ( myHandle ) == NULL &&
( myHandle = ( HINSTANCE )LoadLibraryEx (
myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH
) ) == NULL
) {
lastDLLError = GetLastError ();
retVal = Standard_False;
if ( myHandle == NULL ) {
#ifndef OCCT_UWP
myHandle = (HINSTANCE)LoadLibraryEx(myName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
#else
TCollection_ExtendedString myNameW(myName);
myHandle = (HINSTANCE)LoadPackagedLibrary((const wchar_t*)myNameW.ToExtString(), NULL);
#endif
if ( myHandle == NULL ) {
lastDLLError = GetLastError ();
retVal = Standard_False;
}
} // end if
return retVal;
@@ -273,13 +283,14 @@ void OSD_SharedLibrary :: DlClose () const {
Standard_CString OSD_SharedLibrary :: DlError () const {
FormatMessage (
FormatMessageW (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
0, lastDLLError, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ), errMsg, 1024, ( va_list* )&myName
0, lastDLLError, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
errMsg, 1024, ( va_list* )&myName
);
return errMsg;
WideCharToMultiByte(CP_UTF8, 0, errMsg, -1, errMsgA, sizeof(errMsgA), NULL, NULL);
return errMsgA;
} // end OSD_SharedLibrary :: DlError
void OSD_SharedLibrary :: Destroy () {

View File

@@ -42,7 +42,6 @@ static inline Standard_Real GetWallClockTime ()
}
#else
//------------------- Windows NT ------------------
#define STRICT
@@ -62,7 +61,11 @@ static inline Standard_Real GetWallClockTime ()
LARGE_INTEGER time;
return isOk && QueryPerformanceCounter (&time) ?
(Standard_Real)time.QuadPart / (Standard_Real)freq.QuadPart :
#ifndef OCCT_UWP
0.001 * GetTickCount();
#else
0.001 * GetTickCount64();
#endif
}
#endif /* _WIN32 */

View File

@@ -23,9 +23,14 @@
/***/
#include <OSD_WNT_1.hxx>
#include <Strsafe.h>
#include <wchar.h>
#include <stdlib.h>
#include <Standard_Macro.hxx>
/***/
#ifndef OCCT_UWP
static void Init ( void );
/***/
class Init_OSD_WNT { // provides initialization
@@ -37,6 +42,7 @@ class Init_OSD_WNT { // provides initialization
}; // end Init_OSD_WNT
static Init_OSD_WNT initOsdWnt;
#endif
/***/
static BOOL fInit = FALSE;
static PSID* predefinedSIDs;
@@ -59,6 +65,8 @@ static RESPONSE_DIR_PROC _response_dir_proc;
#define SID_WORLD 7
#define SID_NULL 8
/***/
#ifndef OCCT_UWP
// None of the existing security APIs are supported in a UWP applications
/******************************************************************************/
/* Function : AllocSD */
/* Purpose : Allocates and initializes security identifier */
@@ -597,7 +605,7 @@ void FreeAce ( PVOID pACE ) {
HeapFree ( hHeap, 0, pACE );
} /* end FreeAce */
#endif
#define WILD_CARD L"/*.*"
#define WILD_CARD_LEN ( sizeof ( WILD_CARD ) )
@@ -697,23 +705,24 @@ retry:
retVal = CreateDirectoryW ( newDir, NULL );
if ( retVal || ( !retVal && GetLastError () == ERROR_ALREADY_EXISTS ) ) {
size_t anOldDirLength;
StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength);
if ( ( pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATAW )
)
) != NULL &&
( pName = ( LPWSTR )HeapAlloc (
hHeap, 0, lstrlenW ( oldDir ) + WILD_CARD_LEN +
sizeof ( L'\x00' )
)
(
pName = (LPWSTR)HeapAlloc(
hHeap, 0, anOldDirLength + WILD_CARD_LEN +
sizeof(L'\x00')
)
) != NULL
) {
lstrcpyW ( pName, oldDir );
lstrcatW ( pName, WILD_CARD );
StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), oldDir);
StringCchCatW (pName, sizeof(pName), WILD_CARD);
retVal = TRUE;
fFind = ( hFindFile = FindFirstFileW ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
fFind = ( hFindFile = FindFirstFileExW(pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0) ) != INVALID_HANDLE_VALUE;
while ( fFind ) {
@@ -721,28 +730,35 @@ retry:
pFD -> cFileName[ 0 ] != L'.' &&
pFD -> cFileName[ 1 ] != L'.'
) {
if ( ( pFullNameSrc = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( oldDir ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL ||
( pFullNameDst = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( newDir ) + lstrlenW ( pFD -> cFileName ) +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL
) break;
lstrcpyW ( pFullNameSrc, oldDir );
lstrcatW ( pFullNameSrc, L"/" );
lstrcatW ( pFullNameSrc, pFD -> cFileName );
size_t anOldDirLength2;
size_t aNewDirLength;
size_t aFileNameLength;
lstrcpyW ( pFullNameDst, newDir );
lstrcatW ( pFullNameDst, L"/" );
lstrcatW ( pFullNameDst, pFD -> cFileName );
StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength2);
StringCchLengthW (newDir, sizeof(newDir) / sizeof(newDir[0]), &aNewDirLength);
StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength);
if ( (pFullNameSrc = (LPWSTR)HeapAlloc(
hHeap, 0,
anOldDirLength2 + aFileNameLength +
sizeof(L'/') + sizeof(L'\x00')
)
) == NULL ||
(pFullNameDst = (LPWSTR)HeapAlloc(
hHeap, 0,
aNewDirLength + aFileNameLength +
sizeof(L'/') + sizeof(L'\x00')
)
) == NULL
) break;
StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), oldDir);
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), newDir);
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
@@ -862,22 +878,24 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
if ( retVal || ( !retVal && GetLastError () == ERROR_ALREADY_EXISTS ) ) {
size_t aDirSrcLength;
StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength);
if ( ( pFD = ( PWIN32_FIND_DATAW )HeapAlloc (
hHeap, 0, sizeof ( WIN32_FIND_DATAW )
)
) != NULL &&
( pName = ( LPWSTR )HeapAlloc (
hHeap, 0, lstrlenW ( dirSrc ) + WILD_CARD_LEN +
hHeap, 0, aDirSrcLength + WILD_CARD_LEN +
sizeof ( L'\x00' )
)
) != NULL
) {
lstrcpyW ( pName, dirSrc );
lstrcatW ( pName, WILD_CARD );
StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), dirSrc);
StringCchCatW (pName, sizeof(pName) / sizeof(pName[0]), WILD_CARD);
retVal = TRUE;
fFind = ( hFindFile = FindFirstFileW ( pName, pFD ) ) != INVALID_HANDLE_VALUE;
fFind = (hFindFile = FindFirstFileExW(pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0)) != INVALID_HANDLE_VALUE;
while ( fFind ) {
@@ -885,28 +903,36 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
pFD -> cFileName[ 0 ] != L'.' &&
pFD -> cFileName[ 1 ] != L'.'
) {
size_t aDirSrcLength2;
size_t aDirDstLength;
size_t aFileNameLength;
StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength2);
StringCchLengthW (dirDst, sizeof(dirDst) / sizeof(dirDst[0]), &aDirDstLength);
StringCchLengthW (pFD -> cFileName, sizeof(pFD -> cFileName) / sizeof(pFD -> cFileName[0]), &aFileNameLength);
if ( ( pFullNameSrc = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( dirSrc ) + lstrlenW ( pFD -> cFileName ) +
aDirSrcLength2 + aFileNameLength +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL ||
( pFullNameDst = ( LPWSTR )HeapAlloc (
hHeap, 0,
lstrlenW ( dirDst ) + lstrlenW ( pFD -> cFileName ) +
aDirDstLength + aFileNameLength +
sizeof ( L'/' ) + sizeof ( L'\x00' )
)
) == NULL
) break;
lstrcpyW ( pFullNameSrc, dirSrc );
lstrcatW ( pFullNameSrc, L"/" );
lstrcatW ( pFullNameSrc, pFD -> cFileName );
lstrcpyW ( pFullNameDst, dirDst );
lstrcatW ( pFullNameDst, L"/" );
lstrcatW ( pFullNameDst, pFD -> cFileName );
StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), dirSrc);
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), dirDst);
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
@@ -915,7 +941,11 @@ BOOL CopyDirectory ( LPCWSTR dirSrc, LPCWSTR dirDst ) {
} else {
retry:
retVal = CopyFileW ( pFullNameSrc, pFullNameDst, FALSE );
#ifndef OCCT_UWP
retVal = CopyFileW(pFullNameSrc, pFullNameDst, FALSE);
#else
retVal = (CopyFile2(pFullNameSrc, pFullNameDst, FALSE) == S_OK) ? TRUE : FALSE;
#endif
if ( ! retVal ) {
if ( _response_dir_proc != NULL ) {

View File

@@ -24,8 +24,13 @@
#ifdef NOUSER
#undef NOUSER
#endif
#ifdef NONLS
#undef NONLS
#endif
#include <windows.h>
#include <Strsafe.h>
#ifndef STATUS_FLOAT_MULTIPLE_FAULTS
// <ntstatus.h>
#define STATUS_FLOAT_MULTIPLE_FAULTS (0xC00002B4L)
@@ -72,7 +77,9 @@ static Standard_Mutex THE_SIGNAL_MUTEX;
static LONG __fastcall _osd_raise ( DWORD, LPSTR );
static BOOL WINAPI _osd_ctrl_break_handler ( DWORD );
#ifndef OCCT_UWP
static LONG _osd_debug ( void );
#endif
//# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW )
# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW )
@@ -86,7 +93,9 @@ static LONG CallHandler (DWORD dwExceptionCode,
ptrdiff_t ExceptionInformation0)
{
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
static char buffer[ 2048 ];
static wchar_t buffer[2048];
int flterr = 0;
buffer[0] = '\0' ;
@@ -95,47 +104,47 @@ static LONG CallHandler (DWORD dwExceptionCode,
switch ( dwExceptionCode ) {
case EXCEPTION_FLT_DENORMAL_OPERAND:
// cout << "CallHandler : EXCEPTION_FLT_DENORMAL_OPERAND:" << endl ;
lstrcpyA ( buffer, "FLT DENORMAL OPERAND" );
StringCchCopyW (buffer, _countof(buffer), L"FLT DENORMAL OPERAND");
flterr = 1 ;
break ;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
// cout << "CallHandler : EXCEPTION_FLT_DIVIDE_BY_ZERO:" << endl ;
lstrcpyA ( buffer, "FLT DIVIDE BY ZERO" );
StringCchCopyW (buffer, _countof(buffer), L"FLT DIVIDE BY ZERO");
flterr = 1 ;
break ;
case EXCEPTION_FLT_INEXACT_RESULT:
// cout << "CallHandler : EXCEPTION_FLT_INEXACT_RESULT:" << endl ;
lstrcpyA ( buffer, "FLT INEXACT RESULT" );
StringCchCopyW (buffer, _countof(buffer), L"FLT INEXACT RESULT");
flterr = 1 ;
break ;
case EXCEPTION_FLT_INVALID_OPERATION:
// cout << "CallHandler : EXCEPTION_FLT_INVALID_OPERATION:" << endl ;
lstrcpyA ( buffer, "FLT INVALID OPERATION" );
StringCchCopyW (buffer, _countof(buffer), L"FLT INVALID OPERATION");
flterr = 1 ;
break ;
case EXCEPTION_FLT_OVERFLOW:
// cout << "CallHandler : EXCEPTION_FLT_OVERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"FLT OVERFLOW");
flterr = 1 ;
break ;
case EXCEPTION_FLT_STACK_CHECK:
// cout << "CallHandler : EXCEPTION_FLT_STACK_CHECK:" << endl ;
lstrcpyA ( buffer, "FLT STACK CHECK" );
StringCchCopyW (buffer, _countof(buffer), L"FLT STACK CHECK");
flterr = 1 ;
break ;
case EXCEPTION_FLT_UNDERFLOW:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT UNDERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"FLT UNDERFLOW");
flterr = 1 ;
break ;
case STATUS_FLOAT_MULTIPLE_TRAPS:
// cout << "CallHandler : EXCEPTION_FLT_UNDERFLOW:" << endl ;
lstrcpyA ( buffer, "FLT MULTIPLE TRAPS (possible overflow in conversion of double to integer)" );
StringCchCopyW (buffer, _countof(buffer), L"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 ;
lstrcpyA ( buffer, "FLT MULTIPLE FAULTS" );
StringCchCopyW (buffer, _countof(buffer), L"FLT MULTIPLE FAULTS");
flterr = 1 ;
break ;
case STATUS_NO_MEMORY:
@@ -144,89 +153,92 @@ static LONG CallHandler (DWORD dwExceptionCode,
Raise ( "MEMORY ALLOCATION ERROR ( no room in the process heap )" );
case EXCEPTION_ACCESS_VIOLATION:
// cout << "CallHandler : EXCEPTION_ACCESS_VIOLATION:" << endl ;
wsprintf ( buffer, "%s%s%s0x%.8p%s%s%s", "ACCESS VIOLATION",
fMsgBox ? "\n" : " ", "at address ",
StringCchPrintfW (buffer, _countof(buffer), L"%s%s%s0x%.8p%s%s%s", L"ACCESS VIOLATION",
fMsgBox ? L"\n" : L" ", L"at address ",
ExceptionInformation1 ,
" during '",
ExceptionInformation0 ? "WRITE" : "READ",
"' operation");
L" during '",
ExceptionInformation0 ? L"WRITE" : L"READ",
L"' operation");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
// cout << "CallHandler : EXCEPTION_ARRAY_BOUNDS_EXCEEDED:" << endl ;
lstrcpyA ( buffer, "ARRAY BOUNDS EXCEEDED" );
StringCchCopyW (buffer, _countof(buffer), L"ARRAY BOUNDS EXCEEDED");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
// cout << "CallHandler : EXCEPTION_DATATYPE_MISALIGNMENT:" << endl ;
lstrcpyA ( buffer, "DATATYPE MISALIGNMENT" );
StringCchCopyW (buffer, _countof(buffer), L"DATATYPE MISALIGNMENT");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
// cout << "CallHandler : EXCEPTION_ILLEGAL_INSTRUCTION:" << endl ;
lstrcpyA ( buffer, "ILLEGAL INSTRUCTION" );
StringCchCopyW (buffer, _countof(buffer), L"ILLEGAL INSTRUCTION");
break;
case EXCEPTION_IN_PAGE_ERROR:
// cout << "CallHandler : EXCEPTION_IN_PAGE_ERROR:" << endl ;
lstrcpyA ( buffer, "IN_PAGE ERROR" );
StringCchCopyW (buffer, _countof(buffer), L"IN_PAGE ERROR");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
// cout << "CallHandler : EXCEPTION_INT_DIVIDE_BY_ZERO:" << endl ;
lstrcpyA ( buffer, "INTEGER DIVISION BY ZERO" );
StringCchCopyW (buffer, _countof(buffer), L"INTEGER DIVISION BY ZERO");
break;
case EXCEPTION_INT_OVERFLOW:
// cout << "CallHandler : EXCEPTION_INT_OVERFLOW:" << endl ;
lstrcpyA ( buffer, "INTEGER OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"INTEGER OVERFLOW");
break;
case EXCEPTION_INVALID_DISPOSITION:
// cout << "CallHandler : EXCEPTION_INVALID_DISPOSITION:" << endl ;
lstrcpyA ( buffer, "INVALID DISPOSITION" );
StringCchCopyW (buffer, _countof(buffer), L"INVALID DISPOSITION");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
// cout << "CallHandler : EXCEPTION_NONCONTINUABLE_EXCEPTION:" << endl ;
lstrcpyA ( buffer, "NONCONTINUABLE EXCEPTION" );
StringCchCopyW (buffer, _countof(buffer), L"NONCONTINUABLE EXCEPTION");
break;
case EXCEPTION_PRIV_INSTRUCTION:
// cout << "CallHandler : EXCEPTION_PRIV_INSTRUCTION:" << endl ;
lstrcpyA ( buffer, "PRIVELEGED INSTRUCTION ENCOUNTERED" );
StringCchCopyW (buffer, _countof(buffer), L"PRIVELEGED INSTRUCTION ENCOUNTERED");
break;
case EXCEPTION_STACK_OVERFLOW:
// cout << "CallHandler : EXCEPTION_STACK_OVERFLOW:" << endl ;
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) && !defined(OCCT_UWP)
// try recovering from stack overflow: available in MS VC++ 7.0
if (!_resetstkoflw())
lstrcpyA ( buffer, "Unrecoverable STACK OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"Unrecoverable STACK OVERFLOW");
else
#endif
lstrcpyA ( buffer, "STACK OVERFLOW" );
StringCchCopyW (buffer, _countof(buffer), L"STACK OVERFLOW");
break;
default:
wsprintf( buffer, "unknown exception code 0x%x, params 0x%p 0x%p",
StringCchPrintfW (buffer, _countof(buffer), L"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 = lstrlenA ( buffer );
size_t idx;
StringCchLengthW (buffer, _countof(buffer),&idx);
if ( idx && fMsgBox && dwExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION ) {
// reset FP operations before message box, otherwise it may fail to show up
_fpreset();
_clearfp();
#ifndef OCCT_UWP
MessageBeep ( MB_ICONHAND );
int aChoice = ::MessageBox (0, buffer, "OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
int aChoice = ::MessageBoxW (0, buffer, L"OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
if (aChoice == IDRETRY)
{
_osd_debug();
DebugBreak();
} else if (aChoice == IDABORT)
exit(0xFFFF);
#endif
}
// reset FPE state
@@ -237,7 +249,10 @@ static LONG CallHandler (DWORD dwExceptionCode,
_controlfp ( 0, _OSD_FPX ) ; // JR add :
// cout << "OSD::WntHandler _controlfp( 0, _OSD_FPX ) " << hex << _controlfp(0,0) << dec << endl ;
}
return _osd_raise ( dwExceptionCode, buffer );
char aBufferA[2048];
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
return _osd_raise(dwExceptionCode, aBufferA);
}
//=======================================================================
@@ -292,7 +307,9 @@ static void SIGWntHandler (int signum, int sub_code)
cout << "SIGWntHandler unexpected signal : " << signum << endl ;
break ;
}
#ifndef OCCT_UWP
DebugBreak ();
#endif
}
#endif
@@ -348,7 +365,7 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
LPTOP_LEVEL_EXCEPTION_FILTER aPreviousFilter;
OSD_Environment env (TEXT("CSF_DEBUG_MODE"));
OSD_Environment env ("CSF_DEBUG_MODE");
TCollection_AsciiString val = env.Value();
if (!env.Failed())
{
@@ -377,8 +394,9 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
// Set Ctrl-C and Ctrl-Break handler
fCtrlBrk = Standard_False;
#ifndef OCCT_UWP
SetConsoleCtrlHandler (&_osd_ctrl_break_handler, TRUE);
#endif
#ifdef _MSC_VER
// _se_translator_function pOldSeFunc =
_set_se_translator (TranslateSE);
@@ -401,11 +419,11 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
void OSD::ControlBreak () {
if ( fCtrlBrk ) {
fCtrlBrk = Standard_False;
OSD_Exception_CTRL_BREAK :: Raise ( TEXT( "*** INTERRUPT ***" ) );
OSD_Exception_CTRL_BREAK :: Raise ( "*** INTERRUPT ***" );
}
} // end OSD :: ControlBreak
#if !defined(__MINGW32__) && !defined(__CYGWIN32__)
#ifndef OCCT_UWP
//============================================================================
//==== _osd_ctrl_break_handler
//============================================================================
@@ -418,7 +436,7 @@ static BOOL WINAPI _osd_ctrl_break_handler ( DWORD dwCode ) {
return TRUE;
} // end _osd_ctrl_break_handler
#endif
//============================================================================
//==== _osd_raise
//============================================================================
@@ -487,6 +505,7 @@ static LONG __fastcall _osd_raise ( DWORD dwCode, LPSTR msg )
//============================================================================
//==== _osd_debug
//============================================================================
#ifndef OCCT_UWP
LONG _osd_debug ( void ) {
LONG action ;
@@ -525,7 +544,7 @@ LONG _osd_debug ( void ) {
if ( ( hEvent = CreateEvent ( &sa, TRUE, FALSE, NULL ) ) == NULL ) __leave;
wsprintf ( cmdLine, keyValue, GetCurrentProcessId (), hEvent );
StringCchPrintf(cmdLine, _countof(cmdLine), keyValue, GetCurrentProcessId(), hEvent);
ZeroMemory ( &si, sizeof ( STARTUPINFO ) );
@@ -569,8 +588,9 @@ LONG _osd_debug ( void ) {
return action ;
} // end _osd_debug
#endif
#endif
#endif
#else
//---------- All Systems except Windows NT : ----------------------------------

View File

@@ -14,6 +14,7 @@
#include <OSD_Directory.hxx>
#include <OSD_Environment.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
@@ -86,11 +87,13 @@ Resource_Manager::Resource_Manager(const Standard_CString aName,
Resource_Manager::Resource_Manager(const Standard_CString aName,
const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose)
{
Debug = (getenv("ResourceDebug") != NULL) ;
OSD_Environment envDebug("ResourceDebug");
Debug = (!envDebug.Value().IsEmpty()) ;
TCollection_AsciiString Directory ;
if ( getenv ("CSF_ResourceVerbose") != NULL )
OSD_Environment envVerbose("CSF_ResourceVerbose");
if (!envVerbose.Value().IsEmpty())
myVerbose = Standard_True;
TCollection_AsciiString aPath,aUserPath;
@@ -231,8 +234,10 @@ Standard_Boolean Resource_Manager::Save() const
anEnvVar += myName;
anEnvVar += "UserDefaults";
Standard_CString dir;
if ((dir = getenv (anEnvVar.ToCString())) == NULL) {
TCollection_AsciiString dir;
OSD_Environment anEnv(anEnvVar);
dir = anEnv.Value();
if (dir.IsEmpty()) {
if (myVerbose)
cout << "Resource Manager Warning: environment variable \""
<< anEnvVar << "\" not set. Cannot save resources." << endl ;
@@ -479,8 +484,10 @@ void Resource_Manager::GetResourcePath (TCollection_AsciiString& aPath, const St
anEnvVar += aName;
anEnvVar += isUserDefaults?"UserDefaults":"Defaults";
Standard_CString dir;
if ((dir = getenv (anEnvVar.ToCString())) == NULL)
TCollection_AsciiString dir;
OSD_Environment anEnv(anEnvVar);
dir = anEnv.Value();
if (dir.IsEmpty())
return;
TCollection_AsciiString aResPath(dir);

View File

@@ -36,6 +36,12 @@
extern "C" int posix_memalign (void** thePtr, size_t theAlign, size_t theSize);
#endif
// There is no support for environment variables in UWP
// OSD_Environment could not be used here because of cyclic dependency
#ifdef OCCT_UWP
#define getenv(x) NULL
#endif
#ifndef OCCT_MMGT_OPT_DEFAULT
#define OCCT_MMGT_OPT_DEFAULT 0
#endif

View File

@@ -13,6 +13,10 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifdef _WIN32
#include <windows.h>
#endif
#include <Standard_MMgrOpt.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard_Assert.hxx>
@@ -20,9 +24,7 @@
#include <stdio.h>
#include <errno.h>
#ifdef _WIN32
# include <windows.h>
#else
#ifndef _WIN32
# include <sys/mman.h> /* mmap() */
#endif
@@ -32,6 +34,9 @@
extern "C" int getpagesize() ;
#endif
#ifdef _WIN32
#include <Strsafe.h>
#endif
//======================================================================
// Assumptions
//======================================================================
@@ -752,10 +757,16 @@ retry:
goto retry;
// if nothing helps, make error message and raise exception
const int BUFSIZE=1024;
char message[BUFSIZE];
if ( FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), 0, message, BUFSIZE-1, 0) <=0 )
strcpy (message, "Standard_MMgrOpt::AllocMemory() failed to mmap");
Standard_OutOfMemory::Raise (message);
wchar_t message[BUFSIZE];
if ( FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), 0,
message, BUFSIZE-1, 0) <=0 )
StringCchCopyW(message, _countof(message), L"Standard_MMgrOpt::AllocMemory() failed to mmap");
char messageA[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, message, -1, messageA, sizeof(messageA), NULL, NULL);
Standard_OutOfMemory::Raise(messageA);
}
// record map handle in the beginning

View File

@@ -169,4 +169,13 @@
# endif // __Standard_DLL
# endif // __Standard_API
#endif
// Support of Universal Windows Platform
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP
#define OCCT_UWP
#else
#ifdef OCCT_UWP
#undef OCCT_UWP
#endif
#endif
#endif

View File

@@ -3,5 +3,4 @@ TKMath
TKBRep
TKG2d
TKG3d
TKMesh
TKTopAlgo

View File

@@ -35,7 +35,6 @@
#include <gp_Pnt2d.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <OSD_Chronometer.hxx>
#include <Precision.hxx>
#include <Standard_Failure.hxx>
#include <TCollection_AsciiString.hxx>

View File

@@ -47,7 +47,6 @@
#include <gp_Pln.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <OSD_Chronometer.hxx>
#include <Precision.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <Standard_NotImplemented.hxx>

View File

@@ -200,11 +200,12 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
"CSF_XmlOcafResource",
"CASROOT"
};
TCollection_AsciiString aResourceDir = "";
aResourceDir = getenv (aCSFVariable[0]);
OSD_Environment anEnv (aCSFVariable[0]);
TCollection_AsciiString aResourceDir = anEnv.Value();
if (aResourceDir.IsEmpty()) {
// now try by CASROOT
aResourceDir = getenv (aCSFVariable[1]);
OSD_Environment anEnv2(aCSFVariable[1]);
aResourceDir = anEnv2.Value();
if ( !aResourceDir.IsEmpty() ) {
aResourceDir += "/src/XmlOcafResource" ;
aToSetCSFVariable = Standard_True; //CSF variable to be set later