mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0030692: Data Exchange - introduce base framework RWMesh for importing mesh data formats into XDE document
RWMesh_CafReader - added new interface class for common workflow for reading mesh data files into XDE document. OSD_Path - added auxiliary methods splitting path into folder+file pair and checking relative/absolute path semantically: OSD_Path::FolderAndFileFromPath(), ::IsRelativePath(), ::IsAbsolutePath(). V3d_TypeOfOrientation enumeration has been extended with aliases (like front/left) for Z-up and Y-up conventions. V3d_View::SetProj() now accepts argument for asking Y-up instead of Z-up. Added command vviewproj defining standard camera direction. Commands vaxo, vleft, vright, vtop, vbottom, vfront, vbottom now redirect to vviewproj. TCollection_AsciiString::SubString() now uses Standard_OutOfRange_Always_Raise_if() to suppress GCC warning. Eliminated gcc 4.4 compilation errors within Standard_OutOfRange_Raise_if,Standard_RangeError_Raise_if.
This commit is contained in:
@@ -1635,3 +1635,40 @@ Standard_Boolean LocateExecFile(OSD_Path& )
|
||||
{
|
||||
return Standard_False ;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FolderAndFileFromPath
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OSD_Path::FolderAndFileFromPath (const TCollection_AsciiString& theFilePath,
|
||||
TCollection_AsciiString& theFolder,
|
||||
TCollection_AsciiString& theFileName)
|
||||
{
|
||||
Standard_Integer aLastSplit = -1;
|
||||
Standard_CString aString = theFilePath.ToCString();
|
||||
for (Standard_Integer anIter = 0; anIter < theFilePath.Length(); ++anIter)
|
||||
{
|
||||
if (aString[anIter] == '/'
|
||||
|| aString[anIter] == '\\')
|
||||
{
|
||||
aLastSplit = anIter;
|
||||
}
|
||||
}
|
||||
|
||||
if (aLastSplit == -1)
|
||||
{
|
||||
theFolder.Clear();
|
||||
theFileName = theFilePath;
|
||||
return;
|
||||
}
|
||||
|
||||
theFolder = theFilePath.SubString (1, aLastSplit + 1);
|
||||
if (aLastSplit + 2 <= theFilePath.Length())
|
||||
{
|
||||
theFileName = theFilePath.SubString (aLastSplit + 2, theFilePath.Length());
|
||||
}
|
||||
else
|
||||
{
|
||||
theFileName.Clear();
|
||||
}
|
||||
}
|
||||
|
@@ -20,27 +20,14 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <OSD_SysType.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
class Standard_ConstructionError;
|
||||
class Standard_NullObject;
|
||||
class OSD_OSDError;
|
||||
class Standard_NumericError;
|
||||
class Standard_ProgramError;
|
||||
class TCollection_AsciiString;
|
||||
|
||||
|
||||
|
||||
class OSD_Path
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Creates a Path object initialized to an empty string.
|
||||
//! i.e. current directory.
|
||||
Standard_EXPORT OSD_Path();
|
||||
@@ -199,10 +186,12 @@ public:
|
||||
//! "which" Unix utility. Uses the path environment variable.
|
||||
//! Returns False if executable file not found.
|
||||
Standard_EXPORT Standard_Boolean LocateExecFile (OSD_Path& aPath);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//! Returns the relative file path between the absolute directory
|
||||
//! path <DirPath> and the absolute file path <AbsFilePath>.
|
||||
//! If <DirPath> starts with "/", pathes are handled as
|
||||
//! If <DirPath> starts with "/", paths are handled as
|
||||
//! on Unix, if it starts with a letter followed by ":", as on
|
||||
//! WNT. In particular on WNT directory names are not key sensitive.
|
||||
//! If handling fails, an empty string is returned.
|
||||
@@ -215,19 +204,109 @@ public:
|
||||
//! If handling fails, an empty string is returned.
|
||||
Standard_EXPORT static TCollection_AsciiString AbsolutePath (const TCollection_AsciiString& DirPath, const TCollection_AsciiString& RelFilePath);
|
||||
|
||||
//! Split absolute filepath into folder path and file name.
|
||||
//! Example: IN theFilePath ='/media/cdrom/image.jpg'
|
||||
//! OUT theFolder ='/media/cdrom/'
|
||||
//! OUT theFileName ='image.jpg'
|
||||
//! @param theFilePath [in] file path
|
||||
//! @param theFolder [out] folder path (with trailing separator)
|
||||
//! @param theFileName [out] file name
|
||||
Standard_EXPORT static void FolderAndFileFromPath (const TCollection_AsciiString& theFilePath,
|
||||
TCollection_AsciiString& theFolder,
|
||||
TCollection_AsciiString& theFileName);
|
||||
|
||||
//! Detect absolute DOS-path also used in Windows.
|
||||
//! The total path length is limited to 256 characters.
|
||||
//! Sample path:
|
||||
//! C:\folder\file
|
||||
//! @return true if DOS path syntax detected.
|
||||
static Standard_Boolean IsDosPath (const char* thePath) { return thePath[0] != '\0' && thePath[1] == ':'; }
|
||||
|
||||
//! Detect extended-length NT path (can be only absolute).
|
||||
//! Approximate maximum path is 32767 characters.
|
||||
//! Sample path:
|
||||
//! \\?\D:\very long path
|
||||
//! File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix.
|
||||
//! @return true if extended-length NT path syntax detected.
|
||||
static Standard_Boolean IsNtExtendedPath (const char* thePath) { return ::memcmp (thePath, "\\\\?\\", 4) == 0; }
|
||||
|
||||
protected:
|
||||
//! UNC is a naming convention used primarily to specify and map network drives in Microsoft Windows.
|
||||
//! Sample path:
|
||||
//! \\server\share\file
|
||||
//! @return true if UNC path syntax detected.
|
||||
static Standard_Boolean IsUncPath (const char* thePath)
|
||||
{
|
||||
if (::memcmp (thePath, "\\\\", 2) == 0)
|
||||
{
|
||||
return thePath[2] != '?'
|
||||
|| IsUncExtendedPath (thePath);
|
||||
}
|
||||
return ::memcmp (thePath, "//", 2) == 0;
|
||||
}
|
||||
|
||||
//! Detect extended-length UNC path.
|
||||
//! Sample path:
|
||||
//! \\?\UNC\server\share
|
||||
//! @return true if extended-length UNC path syntax detected.
|
||||
static Standard_Boolean IsUncExtendedPath (const char* thePath) { return ::memcmp (thePath, "\\\\?\\UNC\\", 8) == 0; }
|
||||
|
||||
//! Detect absolute UNIX-path.
|
||||
//! Sample path:
|
||||
//! /media/cdrom/file
|
||||
//! @return true if UNIX path syntax detected.
|
||||
static Standard_Boolean IsUnixPath (const char* thePath) { return thePath[0] == '/' && thePath[1] != '/'; }
|
||||
|
||||
//! Detect special URLs on Android platform.
|
||||
//! Sample path:
|
||||
//! content://filename
|
||||
//! @return true if content path syntax detected
|
||||
static Standard_Boolean IsContentProtocolPath (const char* thePath) { return ::memcmp (thePath, "content://", 10) == 0; }
|
||||
|
||||
//! Detect remote protocol path (http / ftp / ...).
|
||||
//! Actually shouldn't be remote...
|
||||
//! Sample path:
|
||||
//! http://domain/path/file
|
||||
//! @return true if remote protocol path syntax detected.
|
||||
static Standard_Boolean IsRemoteProtocolPath (const char* thePath)
|
||||
{
|
||||
const char* anIter = thePath;
|
||||
if (*anIter == ':')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (; *anIter != '\0'; ++anIter)
|
||||
{
|
||||
if (*anIter == ':')
|
||||
{
|
||||
return *(++anIter) == '/'
|
||||
&& *(++anIter) == '/';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Method to recognize path is absolute or not.
|
||||
//! Detection is based on path syntax - no any filesystem / network access performed.
|
||||
//! @return true if path is incomplete (relative).
|
||||
static Standard_Boolean IsRelativePath (const char* thePath)
|
||||
{
|
||||
return !IsUncPath (thePath)
|
||||
&& !IsDosPath (thePath)
|
||||
&& !IsNtExtendedPath (thePath)
|
||||
&& !IsUnixPath (thePath)
|
||||
&& !IsRemoteProtocolPath (thePath);
|
||||
}
|
||||
|
||||
//! Method to recognize path is absolute or not.
|
||||
//! Detection is based on path syntax - no any filesystem / network access performed.
|
||||
//! @return true if path is complete (absolute)
|
||||
static Standard_Boolean IsAbsolutePath (const char* thePath)
|
||||
{
|
||||
return !IsRelativePath (thePath);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
TCollection_AsciiString myNode;
|
||||
TCollection_AsciiString myUserName;
|
||||
TCollection_AsciiString myPassword;
|
||||
@@ -238,13 +317,6 @@ private:
|
||||
Standard_Boolean myUNCFlag;
|
||||
OSD_SysType mySysDep;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _OSD_Path_HeaderFile
|
||||
|
Reference in New Issue
Block a user