Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Path including non-English character, buglog and usrlog file cannot be deleted
Path including non-English character, buglog and usrlog file cannot be deleted [message #17572] Thu, 21 August 2008 09:16 Go to previous message
kasome is currently offline  kasome
Messages: 78
Registered: July 2008
Location: Taiwan
Member
In the debug mode, when the path of execute file including non-English character, like Chinese, buglog and usrlog cannot be deleted after the execute file terminated.

the content of buglog and usrlog file is as the following:

36.MainMenu with layout.2008-08-21-14-21-45.buglog:

* c:\Program Files\OpenCV\MyCode\build\win32\debug\´ú¸ÕÀÉ\36.MainMenu with layout.exe 21.08.2008 14:21:45, user: kasome


36.MainMenu with layout.2008-08-21-14-21-45.usrlog:

* c:\Program Files\OpenCV\MyCode\build\win32\debug\´ú¸ÕÀÉ\36.MainMenu with layout.exe 21.08.2008 14:21:45, user: kasome


and i find out the reason may be the file

uppsrc\Core\Path.cpp

in the following function:

bool FileDelete(const char *filename)
{
#if defined(PLATFORM_WIN32)
	if( IsWinNT() ){
		return !!UnicodeWin32().DeleteFileW( ToSystemCharsetW(filename) );
	}
	else
		return !!DeleteFile(ToSystemCharset(filename));
#elif defined(PLATFORM_POSIX)
	return !unlink(ToSystemCharset(filename));
#else
	#error
#endif//PLATFORM
}



i keep trying and finally fix the function as the following, this function WideString can be found in the attachment file got from the internet.

bool FileDelete(const char *filename)
{
#if defined(PLATFORM_WIN32)
	if( IsWinNT() ){
		return !!UnicodeWin32().DeleteFileW( ToSystemCharsetW( ToUtf8( WideString( filename ) ) ) );
	}
	else
		return !!DeleteFile(ToSystemCharset(filename));
#elif defined(PLATFORM_POSIX)
	return !unlink(ToSystemCharset(filename));
#else
	#error
#endif//PLATFORM
}


WideString.h
#include <windows.h>
#include <CtrlLib/CtrlLib.h>
#include <iostream>

using namespace std;
using namespace Upp;

WString WideString( const String s );


WideString.cpp
#include "WideString.h"

WString WideString( const String s ){

	int nIndex = MultiByteToWideChar( CP_ACP, 0, s, -1, NULL, 0 );
	wchar_t *w = new wchar_t[ nIndex + 1 ];
	MultiByteToWideChar( CP_ACP, 0, s, -1, w, nIndex );
	WString wstr = w;
	delete[] w; w = 0;

	return wstr;
}


now everthing is work fine, but i can not explain why, may be there is a more better way to solve this.

OS: Microsoft Windows XP Professional SP2
Language: Taiwan (codepage 950 )

[Updated on: Thu, 21 August 2008 09:31]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Some 'missing' string functions
Next Topic: String filter whitespace
Goto Forum:
  


Current Time: Fri May 17 21:55:57 CEST 2024

Total time taken to generate the page: 0.01612 seconds