-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "DF_Container.hxx"
#include "DF_ChildIterator.hxx"
+#include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
+
#ifndef WIN32
#include <unistd.h>
#include <sys/time.h>
struct tm transfert;
struct timeval tval;
struct timezone tzone;
- int status;
-
- status = gettimeofday( &tval, &tzone );
+
+ gettimeofday( &tval, &tzone );
memcpy(&transfert, localtime((time_t *)&tval.tv_sec), sizeof(tm));
month = transfert.tm_mon + 1;
std::string GetUserName()
{
#ifdef WIN32
- char* pBuff = new char[UNLEN + 1];
+#ifdef UNICODE
+ wchar_t* pBuff = new wchar_t[UNLEN + 1];
+#else
+ char* pBuff = new char[UNLEN + 1];
+#endif
DWORD dwSize = UNLEN + 1;
std::string retVal;
GetUserName ( pBuff, &dwSize );
- std::string theTmpUserName(pBuff,(int)dwSize -1 );
+#ifdef UNICODE
+ std::wstring theTmpUserName(pBuff, (int)dwSize - 1);
+ retVal = Kernel_Utils::utf8_encode_s(theTmpUserName);
+#else
+ std::string theTmpUserName(pBuff, (int)dwSize - 1);
retVal = theTmpUserName;
+#endif
delete [] pBuff;
return retVal;
#else
bool Exists(const std::string thePath)
{
-#ifdef WIN32
- if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) {
- if ( GetLastError () != ERROR_FILE_NOT_FOUND ) {
- return false;
- }
- }
-#else
- int status = access ( thePath.c_str() , F_OK );
- if (status != 0) return false;
-#endif
- return true;
+ return Kernel_Utils::IsExists( thePath );
}
}
-int main (int argc, char * argv[])
+int main ()
{
std::cout << "Test started " << std::endl;
std::string s("012-56");
int pos = s.find('-');
- std::cout << "Fisrt part : " << s.substr(0, pos) << std::endl;
+ std::cout << "First part : " << s.substr(0, pos) << std::endl;
std::cout << "Last part : " << s.substr(pos+1, s.size()) << std::endl;
std::vector<std::string> vs = splitString("/dn20/salome/srn/salome2/", '/');