win32_trash.c: converted newline from <CR><LF> to <LF>
This commit is contained in:
parent
2a6b55e3c2
commit
0cb079acb0
1 changed files with 34 additions and 34 deletions
|
|
@ -1,34 +1,34 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
int MoveFileToRecycleBin(const TCHAR *fullPathName);
|
int MoveFileToRecycleBin(const TCHAR *fullPathName);
|
||||||
int win32_trash(const char *path);
|
int win32_trash(const char *path);
|
||||||
|
|
||||||
int MoveFileToRecycleBin(const TCHAR *fullPathName)
|
int MoveFileToRecycleBin(const TCHAR *fullPathName)
|
||||||
{
|
{
|
||||||
SHFILEOPSTRUCT fileOp;
|
SHFILEOPSTRUCT fileOp;
|
||||||
const TCHAR *src = fullPathName;
|
const TCHAR *src = fullPathName;
|
||||||
TCHAR *dest;
|
TCHAR *dest;
|
||||||
|
|
||||||
fileOp.pFrom = dest = alloca(sizeof(*dest) * (_tcslen(fullPathName) + 2));
|
fileOp.pFrom = dest = alloca(sizeof(*dest) * (_tcslen(fullPathName) + 2));
|
||||||
while((*dest++ = *src++) != _T('\0')) {}
|
while((*dest++ = *src++) != _T('\0')) {}
|
||||||
*dest = _T('\0');
|
*dest = _T('\0');
|
||||||
|
|
||||||
fileOp.hwnd = NULL;
|
fileOp.hwnd = NULL;
|
||||||
fileOp.wFunc = FO_DELETE;
|
fileOp.wFunc = FO_DELETE;
|
||||||
fileOp.pTo = NULL;
|
fileOp.pTo = NULL;
|
||||||
fileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
|
fileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
|
||||||
return SHFileOperation(&fileOp);
|
return SHFileOperation(&fileOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int win32_trash(const char *path)
|
int win32_trash(const char *path)
|
||||||
{
|
{
|
||||||
char *p, *src;
|
char *p, *src;
|
||||||
|
|
||||||
src = p = strdup(path);
|
src = p = strdup(path);
|
||||||
while(*p != '\0'){
|
while(*p != '\0'){
|
||||||
if (*p == '/') *p = '\\';
|
if (*p == '/') *p = '\\';
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
return MoveFileToRecycleBin(src);
|
return MoveFileToRecycleBin(src);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue