Windows Recycle Bin support seems to be stable. / Replaced mtw() with MultiByteToWideChar().

This commit is contained in:
dolphin6k 2021-11-06 00:29:10 +09:00
parent c217f62470
commit 1efedfa191

View file

@ -339,35 +339,9 @@ typedef struct safer_dirent
#undef min
#undef max
#define mkdir(path,access) _mkdir(path)
static void mtw(wchar_t * wtok, char *tok, size_t size)
{
/* workaround using iconv to get a functionallity somewhat approximate as mbstowcs() */
Uint16 *ui16;
ui16 = malloc(size);
char *wrptr = (char *)ui16;
size_t in, out, n;
iconv_t trans;
in = size;
out = size;
n = size / sizeof(wchar_t);
trans = iconv_open("WCHAR_T", "UTF-8");
iconv(trans, (char **)&tok, &in, &wrptr, &out);
*((wchar_t *) wrptr) = L'\0';
swprintf(wtok, n, L"%ls", ui16);
free(ui16);
iconv_close(trans);
}
#define USE_WINDOWS_RECYCLE_BIN
#ifdef USE_WINDOWS_RECYCLE_BIN
extern int win32_trash(const char *path);
#endif
#undef iswprint
int iswprint(wchar_t wc)
@ -22586,7 +22560,7 @@ static void load_info_about_label_surface(FILE * lfi)
tmpstr = malloc(1024);
wtmpstr = malloc(1024);
fgets(tmpstr, 1024, lfi);
mtw(wtmpstr, tmpstr, 1024);
MultiByteToWideChar(CP_UTF8,MB_COMPOSITE,tmpstr,-1,wtmpstr,1024);
for (l = 0; l < new_node->save_texttool_len; l++)
{
new_node->save_texttool_str[l] = wtmpstr[l];
@ -25916,7 +25890,7 @@ static int trash(char *path)
#ifdef UNLINK_ONLY
return (unlink(path));
#else
#ifdef USE_WINDOWS_RECYCLE_BIN
#ifdef WIN32
return win32_trash(path);
#else
char fname[MAX_PATH], trashpath[MAX_PATH], dest[MAX_PATH], infoname[MAX_PATH], bname[MAX_PATH], ext[MAX_PATH];