{
wofstream_mode = std::ios::app | std::ios::binary ;
}
+#ifdef _MSC_VER
+ std::wofstream fileDiary(getFullFilename(_wfilename).c_str(),wofstream_mode);
+ if ( fileDiary.bad())
+ {
+ wfilename = std::wstring(L"");
+ fileAttribMode = -1;
+ setID(-1);
+ }
+ else
+ {
+ wfilename = getFullFilename(_wfilename);
+ fileAttribMode = wofstream_mode;
+ setID(ID);
+ }
+ fileDiary.close();
-// std::wofstream fileDiary(getFullFilename(_wfilename).c_str(),wofstream_mode);
+#else
+ std::wstring wstrfile = getFullFilename(_wfilename);
+ wchar_t *wcfile = (wchar_t*)wstrfile.c_str();
+ char *filename = wide_string_to_UTF8(wcfile);
- if ( /*fileDiary.bad()*/ 1 )
+ if (_mode == 0)
{
+ std::ofstream fileDiary(filename, std::ios::trunc | std::ios::binary) ;
+ if ( fileDiary.bad())
+ {
wfilename = std::wstring(L"");
fileAttribMode = -1;
setID(-1);
+ }
+ else
+ {
+ wfilename = getFullFilename(_wfilename);
+ fileAttribMode = wofstream_mode;
+ setID(ID);
+ }
+ fileDiary.close();
}
else
{
+ std::ofstream fileDiary(filename, std::ios::app | std::ios::binary );
+ if ( fileDiary.bad())
+ {
+ wfilename = std::wstring(L"");
+ fileAttribMode = -1;
+ setID(-1);
+ }
+ else
+ {
wfilename = getFullFilename(_wfilename);
fileAttribMode = wofstream_mode;
setID(ID);
+ }
+ fileDiary.close();
}
+#endif
-// fileDiary.close();
}
/*--------------------------------------------------------------------------*/
Diary::~Diary()
{
if (!suspendwrite)
{
-// std::wofstream fileDiary(wfilename.c_str(),std::ios::app | std::ios::binary );
- if (/*fileDiary.good() */ 1)
+#ifdef _MSC_VER
+ std::wofstream fileDiary(wfilename.c_str(),std::ios::app | std::ios::binary );
+#else
+ wchar_t *wcfile = (wchar_t*)wfilename.c_str();
+ char *filename = wide_string_to_UTF8(wcfile);
+ std::ofstream fileDiary(filename, std::ios::app | std::ios::binary);
+#endif
+ if (fileDiary.good())
{
char *line = NULL;
char *timeInfo = wide_string_to_UTF8((wchar_t*)getDiaryDate(Prefixmode).c_str());
if (timeInfo)
{
- // fileDiary << timeInfo << " ";
+ fileDiary << timeInfo << " ";
FREE(timeInfo); timeInfo = NULL;
}
}
-// if (line) fileDiary << line;
+ if (line) fileDiary << line;
}
}
else // output
char *timeInfo = wide_string_to_UTF8((wchar_t*)getDiaryDate(Prefixmode).c_str());
if (timeInfo)
{
-// fileDiary << timeInfo << " ";
+ fileDiary << timeInfo << " ";
FREE(timeInfo); timeInfo = NULL;
}
}
-// if (line) fileDiary << line;
+ if (line) fileDiary << line;
}
}
{
#include "machine.h"
#include "PATH_MAX.h"
+#include "MALLOC.h"
+#include "charEncoding.h"
}
/*--------------------------------------------------------------------------*/
static void wcsplitpath(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext);
/*--------------------------------------------------------------------------*/
std::wstring getFullFilename(std::wstring _wfilename)
{
- std::wstring wfullfilename(L"");
- std::wstring tmpWstr;
wchar_t wcdrive[1024];
wchar_t wcdirectory[1024];
wchar_t wcname[1024];
wchar_t wcext [1024];
+ std::wstring wfullfilename(L"");
+ std::wstring tmpWstr;
+
size_t found = _wfilename.rfind(L"\\");
while (found != std::wstring::npos)
wfullfilename.append(tmpWstr.assign(wcdirectory));
if (wfullfilename.compare(L"") == 0)
{
- wchar_t wcCurrentDir[1024];
#if _MSC_VER
+ wchar_t wcCurrentDir[1024];
if ( _wgetcwd(wcCurrentDir, PATH_MAX) != NULL)
#else
- if (/*getcwd(wcCurrentDir,1024) != NULL*/ 1)
+ char CurrentDir[1024];
+ if (getcwd(CurrentDir,1024) != NULL)
#endif
{
+#if _MSC_VER
wfullfilename = tmpWstr.assign(wcCurrentDir);
+#else
+ wchar_t *wcCurrentDir = to_wide_string(CurrentDir);
+ wfullfilename = tmpWstr.assign(wcCurrentDir);
+ FREE(wcCurrentDir);
+#endif
size_t found = wfullfilename.rfind(L"\\");
while (found != std::wstring::npos)
{
{
wfullfilename.assign(L"");
}
-
+#ifndef _MSC_VER
+ //if (CurrentDir) {FREE(CurrentDir); CurrentDir = NULL;}
+#endif
}
wfullfilename.append(tmpWstr.assign(wcname));
wfullfilename.append(tmpWstr.assign(wcext));