mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-26 10:19:45 +03:00
Build tools are updated to support building with Visual Studion 2019 toolset ClangCL (LLVM clang-cl): - In CMake builds, use of unsupported option "-std=c++0x" is avoided - Tool genconf recognizes availability of ClangCL toolset and proposes it in the list - Tool genproj recognizes new compiler specification VCVER=vclang and generates VS 2019 projects for it Note that vclang configuration puts binaries to folder "vc14" as it is compatible with vc14 CRT. Code is updated to build with Clang for Windows without errors and warnings: - In BVH classes, pure virtual destructors are replaced by empty ones, to avoid bogus compiler warning - In .lex files, pragmas are added to disable warnings in parser code - In OSD, signature of function _osd_wnt_set_error() is corrected to avoid warning on incorrect use of va_args (undefined behavior) - In OSD_Host, OSD_Parallel_TBB, warnings on usage of deprecated function are disabled - In Quantity_ColorRGBA and ViewerTest_CmdParser, incorrect use of predefined macro __FUNCTION__ assuming it was a string literal is avoided - In Standard_Macro.hxx, code is reordered to handle Clang for Windows appropriately - In AdvApp2Var_SysBase.hxx, inclusion of obsolete (MSVC-specific) header file is replaced by Standard_TypeDef.hxx - In Standard_ErrorHandler.hxx, empty statements added to avoid warning on unused class fields - In IVtkDraw and ViewerTest, interface is corrected to use actual type avoiding unnecessary type casts Off-topic: corrections of some errors (uninitialized class fields) reported by VS Code Analysis in TKernel
178 lines
4.9 KiB
C++
178 lines
4.9 KiB
C++
// 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 <OSD_Directory.hxx>
|
|
|
|
#include <OSD_Path.hxx>
|
|
#include <OSD_Protection.hxx>
|
|
#include <OSD_WhoAmI.hxx>
|
|
#include <Standard_ProgramError.hxx>
|
|
#include <TCollection_ExtendedString.hxx>
|
|
#include <NCollection_String.hxx>
|
|
|
|
#ifdef _WIN32
|
|
#include <OSD_WNT.hxx>
|
|
#include <stdio.h>
|
|
|
|
#ifndef _INC_TCHAR
|
|
#include <tchar.h>
|
|
#endif
|
|
|
|
void _osd_wnt_set_error (OSD_Error&, Standard_Integer, ... );
|
|
#else
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
const OSD_WhoAmI Iam = OSD_WDirectory;
|
|
#endif
|
|
|
|
// =======================================================================
|
|
// function : OSD_Directory
|
|
// purpose :
|
|
// =======================================================================
|
|
OSD_Directory::OSD_Directory()
|
|
{
|
|
//
|
|
}
|
|
|
|
// =======================================================================
|
|
// function : OSD_Directory
|
|
// purpose :
|
|
// =======================================================================
|
|
OSD_Directory::OSD_Directory (const OSD_Path& theName)
|
|
: OSD_FileNode (theName)
|
|
{
|
|
//
|
|
}
|
|
|
|
// =======================================================================
|
|
// function : Build
|
|
// purpose :
|
|
// =======================================================================
|
|
void OSD_Directory::Build (const OSD_Protection& theProtect)
|
|
{
|
|
#ifdef _WIN32
|
|
TCollection_AsciiString aDirName;
|
|
myPath.SystemName (aDirName);
|
|
if (aDirName.IsEmpty())
|
|
{
|
|
throw Standard_ProgramError ( "OSD_Directory::Build(): incorrect call - no directory name");
|
|
}
|
|
|
|
Standard_Boolean isOK = Exists();
|
|
if (!isOK)
|
|
{
|
|
// myError will be set to fail by Exists() if intermediate dirs do not exist
|
|
myError.Reset();
|
|
|
|
// create directory if it does not exist;
|
|
TCollection_ExtendedString aDirNameW (aDirName);
|
|
if (CreateDirectoryW (aDirNameW.ToWideString(), NULL))
|
|
{
|
|
isOK = Standard_True;
|
|
}
|
|
// if failed due to absence of intermediate directories, create them recursively
|
|
else if (GetLastError() == ERROR_PATH_NOT_FOUND)
|
|
{
|
|
OSD_Path aSupPath = myPath;
|
|
aSupPath.UpTrek();
|
|
aSupPath.SetName (myPath.TrekValue (myPath.TrekLength())); // incredible, but required!
|
|
OSD_Directory aSupDir (aSupPath);
|
|
aSupDir.Build (theProtect);
|
|
if (aSupDir.Failed())
|
|
{
|
|
myError = aSupDir.myError;
|
|
return;
|
|
}
|
|
isOK = (CreateDirectoryW (aDirNameW.ToWideString(), NULL) != 0);
|
|
}
|
|
}
|
|
|
|
if (isOK)
|
|
{
|
|
#ifndef OCCT_UWP
|
|
SetProtection (theProtect);
|
|
#else
|
|
(void)theProtect;
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
_osd_wnt_set_error (myError, OSD_WDirectory);
|
|
}
|
|
#else
|
|
TCollection_AsciiString aBuffer;
|
|
mode_t anInternalProt = (mode_t )theProtect.Internal();
|
|
myPath.SystemName (aBuffer);
|
|
umask (0);
|
|
int aStatus = mkdir (aBuffer.ToCString(), anInternalProt);
|
|
if (aStatus == -1 && errno == ENOENT)
|
|
{
|
|
OSD_Path aSupPath = myPath;
|
|
aSupPath.UpTrek();
|
|
aSupPath.SetName (myPath.TrekValue (myPath.TrekLength())); // incredible, but required!
|
|
OSD_Directory aSupDir (aSupPath);
|
|
aSupDir.Build (theProtect);
|
|
if (aSupDir.Failed())
|
|
{
|
|
myError = aSupDir.myError;
|
|
return;
|
|
}
|
|
aStatus = mkdir (aBuffer.ToCString(), anInternalProt);
|
|
}
|
|
if (aStatus == -1 && errno != EEXIST)
|
|
{
|
|
char anErrMsg[2048];
|
|
Sprintf (anErrMsg, "OSD_Directory::Build Directory \"%.2000s\"", aBuffer.ToCString());
|
|
myError.SetValue (errno, Iam, anErrMsg);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
// =======================================================================
|
|
// function : BuildTemporary
|
|
// purpose :
|
|
// =======================================================================
|
|
OSD_Directory OSD_Directory::BuildTemporary()
|
|
{
|
|
#ifdef _WIN32
|
|
wchar_t* aTmpNameW = _wtmpnam (NULL);
|
|
if (aTmpNameW == NULL)
|
|
{
|
|
return OSD_Directory();
|
|
}
|
|
|
|
TCollection_AsciiString aTmpName (aTmpNameW);
|
|
OSD_Path aDirPath (aTmpName);
|
|
OSD_Directory aDir;
|
|
aDir.SetPath (aDirPath);
|
|
aDir.Build (OSD_Protection());
|
|
return aDir;
|
|
#else
|
|
// create a temporary directory with 0700 permissions
|
|
char aTmpName[] = "/tmp/CSFXXXXXX";
|
|
if (NULL == mkdtemp (aTmpName))
|
|
{
|
|
return OSD_Directory(); // can't create a directory
|
|
}
|
|
|
|
unlink (aTmpName); // destroys link but directory still exists while current process lives
|
|
OSD_Directory aDir;
|
|
aDir.SetPath (TCollection_AsciiString (aTmpName));
|
|
return aDir;
|
|
#endif
|
|
}
|