/****************************************************************************
* OUVERTURE DU FICHIER EN LECTURE *
****************************************************************************/
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring file2Read = Kernel_Utils::utf8_decode_s(myFile);
+ FILE* aFileId = _wfopen(file2Read.c_str(), L"r");
+#else
char *file2Read = (char *)myFile.c_str();
FILE* aFileId = fopen(file2Read, "r");
+#endif
if ( !aFileId ) {
fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
return DRS_FAIL;
Status aResult = DRS_OK;
int nbNodes, nbCells;
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring file2Read = Kernel_Utils::utf8_decode_s(myFile);
+ FILE* aFileId = _wfopen(file2Read.c_str(), L"w+");
+#else
char *file2Read = (char *)myFile.c_str();
FILE* aFileId = fopen(file2Read, "w+");
+#endif
if ( !aFileId )
{
fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
#include <math.h>
#include <ctype.h>
#include "libmesh5.h"
-
+#ifdef WIN32
+#include <windows.h>
+#endif
/*----------------------------------------------------------*/
/* Defines */
GmfMshSct *msh;
char *ptr;
int k;
-
+#if defined(WIN32) && defined(UNICODE)
+ wchar_t* encoded = 0;
+ int size_needed = 0;
+#endif
if(!GmfIniFlg)
{
for(i=0;i<=MaxMsh;i++)
va_end(VarArg);
/* Create the name string and open the file */
-
- if(!(msh->hdl = fopen(msh->FilNam, "rb")))
+#if defined(WIN32) && defined(UNICODE)
+ size_needed = MultiByteToWideChar(CP_UTF8, 0, msh->FilNam, strlen(msh->FilNam), NULL, 0);
+ encoded = malloc((size_needed + 1)*sizeof(wchar_t));
+ MultiByteToWideChar(CP_UTF8, 0, msh->FilNam, strlen(msh->FilNam), encoded, size_needed);
+ encoded[size_needed] = '\0';
+ if (!(msh->hdl = _wfopen(encoded, L"rb")))
+#else
+ if (!(msh->hdl = fopen(msh->FilNam, "rb")))
+#endif
{
free (msh);
+#if defined(WIN32) && defined(UNICODE)
+ free(encoded);
+#endif
return(0);
}
+#if defined(WIN32) && defined(UNICODE)
+ free(encoded);
+#endif
+
/* Read the endian coding tag, the mesh version and the mesh dimension (mandatory kwd) */
if(msh->typ & Bin)
}
/* Create the mesh file */
-
+#if defined(WIN32) && defined(UNICODE)
+ size_needed = MultiByteToWideChar(CP_UTF8, 0, msh->FilNam, strlen(msh->FilNam), NULL, 0);
+ encoded = malloc((size_needed + 1) * sizeof(wchar_t));
+ MultiByteToWideChar(CP_UTF8, 0, msh->FilNam, strlen(msh->FilNam), encoded, size_needed);
+ encoded[size_needed] = '\0';
+ if (!(msh->hdl = _wfopen(encoded, L"wb")))
+#else
if(!(msh->hdl = fopen(msh->FilNam, "wb")))
+#endif
{
free (msh);
+#if defined(WIN32) && defined(UNICODE)
+ free(encoded);
+#endif
return(0);
}
+#if defined(WIN32) && defined(UNICODE)
+ free(encoded);
+#endif
GmfMshTab[ MshIdx ] = msh;
theFile.close();
// Open the file
- FILE* file = fopen( myFile.c_str(),"r");
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring aFile = Kernel_Utils::utf8_decode_s(myFile);
+ FILE* file = _wfopen( aFile.c_str(), L"r");
+#else
+ FILE* file = fopen(myFile.c_str(), "r");
+#endif
// count the number of lines
Standard_Integer nbLines = 0;
{
Kernel_Utils::Localizer loc;
Status aResult = DRS_OK;
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring aFile = Kernel_Utils::utf8_decode_s(myFile);
+ std::ifstream in_stream(aFile.c_str());
+#else
std::ifstream in_stream(myFile.c_str());
+#endif
try
{
{
{
Kernel_Utils::Localizer loc;
Status aResult = DRS_OK;
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring aFile = Kernel_Utils::utf8_decode_s(myFile);
+ std::ofstream out_stream(aFile.c_str());
+#else
std::ofstream out_stream(myFile.c_str());
+#endif
try{
UNV164::Write( out_stream ); // unit system
{
#ifdef WIN32
#ifdef UNICODE
- size_t length = strlen(fileName.c_str()) + sizeof(char);
- wchar_t* path = new wchar_t[length];
- memset(path, '\0', length);
- mbstowcs(path, fileName.c_str(), length);
+ int size_needed = MultiByteToWideChar(CP_UTF8, 0, fileName.c_str(), strlen(fileName.c_str()), NULL, 0);
+ wchar_t* path = new wchar_t[size_needed + 1];
+ MultiByteToWideChar(CP_UTF8, 0, fileName.c_str(), strlen(fileName.c_str()), path, size_needed);
+ path[size_needed] = '\0';
#else
cosnt char* path = xmlPath.c_str();
#endif
{
#ifdef WIN32
#ifdef UNICODE
- const wchar_t* name = Kernel_Utils::decode(_name.data());
+ std::wstring aName = Kernel_Utils::utf8_decode_s(_name);
+ const wchar_t* name = aName.c_str();
#else
char* name = name.data();
#endif
_file = CreateFile(name, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
bool ok = ( _file != INVALID_HANDLE_VALUE );
-#ifdef UNICODE
- delete name;
-#endif
#else
_file = ::open(_name.data(), O_RDONLY );
bool ok = ( _file >= 0 );
close();
boost::system::error_code err;
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring name = Kernel_Utils::utf8_decode_s(_name);
+ boofs::remove(name.c_str(), err);
+#else
boofs::remove( _name, err );
+#endif
_error = err.message();
return !err;
if ( _size >= 0 ) return _size; // size of an open file
boost::system::error_code err;
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring name = Kernel_Utils::utf8_decode_s(_name);
+ boost::uintmax_t size = boofs::file_size(name.c_str(), err);
+#else
boost::uintmax_t size = boofs::file_size( _name, err );
+#endif
_error = err.message();
return !err ? (long) size : -1;
bool SMESH_File::exists()
{
boost::system::error_code err;
- bool res = boofs::exists( _name, err );
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring name = Kernel_Utils::utf8_decode_s(_name);
+ bool res = boofs::exists(name.c_str(), err);
+#else
+ bool res = boofs::exists(_name, err);
+#endif
+
_error = err.message();
return err ? false : res;
bool SMESH_File::isDirectory()
{
boost::system::error_code err;
+#if defined(WIN32) && defined(UNICODE)
+ std::wstring name = Kernel_Utils::utf8_decode_s(_name);
+ bool res = boofs::is_directory(name.c_str(), err);
+#else
bool res = boofs::is_directory( _name, err );
+#endif
_error = err.message();
return err ? false : res;
{
#ifdef WIN32
#ifdef UNICODE
- const wchar_t* name = Kernel_Utils::decode(_name.data());
+ std::wstring aName = Kernel_Utils::utf8_decode_s(_name);
+ const wchar_t* name = aName.c_str();
#else
char* name = name.data();
#endif
OPEN_ALWAYS, // CREATE NEW or OPEN EXISTING
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
-#ifdef UNICODE
- delete name;
-#endif
return ( _file != INVALID_HANDLE_VALUE );
-
#else
_file = ::open( _name.c_str(),