From 61ce0798d9cbc93da3ab2b0316f946913ef771eb Mon Sep 17 00:00:00 2001 From: dolphin6k Date: Thu, 28 Oct 2021 22:47:32 +0900 Subject: [PATCH] Initial implimentation of win32_trash() --- Makefile | 8 +++++++- src/tuxpaint.c | 9 +++++++++ src/win32_trash.c | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/win32_trash.c diff --git a/Makefile b/Makefile index 8866af803..df6e97e82 100644 --- a/Makefile +++ b/Makefile @@ -158,7 +158,7 @@ macos_BUNDLE:=./TuxPaint.app ios_BUNDLE:=./TuxPaint-$(SDK).app BUNDLE:=$($(OS)_BUNDLE) -windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o +windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o obj/win32_trash.o macos_ARCH_LIBS:=src/macos_print.m obj/macos.o ios_ARCH_LIBS:=src/ios_print.m obj/ios.o beos_ARCH_LIBS:=obj/BeOS_print.o @@ -1262,6 +1262,12 @@ obj/win32_print.o: src/win32_print.c src/win32_print.h src/debug.h @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \ -c src/win32_print.c -o obj/win32_print.o +obj/win32_trash.o: src/win32_trash.c src/debug.h + @echo + @echo "...Compiling win32 trash support..." + @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \ + -c src/win32_trash.c -o obj/win32_trash.o + obj/postscript_print.o: src/postscript_print.c \ src/postscript_print.h src/debug.h @echo diff --git a/src/tuxpaint.c b/src/tuxpaint.c index a154c04c6..eb841d00d 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -2137,7 +2137,14 @@ static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned #endif static SDL_Surface *myIMG_Load_RWops(const char *file); static SDL_Surface *myIMG_Load(const char *file); +#ifndef WIN32 static int trash(char *path); +#else +#ifndef UNLINK_ONLY +static int win32_trash(char *path); +#define trash(file) win32_trash(file) +#endif +#endif int file_exists(char *path); int generate_fontconfig_cache_spinner(SDL_Surface * screen); @@ -25851,6 +25858,7 @@ int main(int argc, char *argv[]) /** * FIXME */ +#ifndef WIN32 static int trash(char *path) { #ifdef UNLINK_ONLY @@ -26023,6 +26031,7 @@ static int trash(char *path) return (0); #endif /* UNLINK_ONLY */ } +#endif /** * FIXME diff --git a/src/win32_trash.c b/src/win32_trash.c new file mode 100644 index 000000000..d7fd90f41 --- /dev/null +++ b/src/win32_trash.c @@ -0,0 +1,13 @@ +#include + +int win32_trash(char *path); +int win32_trash(char *path) +{ + SHFILEOPSTRUCT op; + + op.wFunc = FO_DELETE; + op.pFrom = path; + op.fFlags = FOF_SILENT|FOF_ALLOWUNDO; + + return SHFileOperationA(&op); +}