From 87376dfd4f8ce7c86bdd414b5a626185ed5f4cff Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 25 Apr 2021 17:55:49 +0100 Subject: [PATCH] Implement file deletion for Atari ST. --- setter/src/atarist/deleted.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 setter/src/atarist/deleted.c diff --git a/setter/src/atarist/deleted.c b/setter/src/atarist/deleted.c new file mode 100644 index 0000000..20fa722 --- /dev/null +++ b/setter/src/atarist/deleted.c @@ -0,0 +1,68 @@ +/**************************************************************************** +Aaru Data Preservation Suite +----------------------------------------------------------------------------- + + Author(s) : Natalia Portillo + +--[ License ] --------------------------------------------------------------- + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +----------------------------------------------------------------------------- +Copyright (C) 2011-2021 Natalia Portillo +*****************************************************************************/ + +#include +#include +#include + +#include "../include/defs.h" +#include "../log.h" + +void DeleteFiles(const char* path) +{ + char driveNo = path[0] - '@'; + unsigned int rc; + char filename[9]; + short pos; + int handle; + + if(driveNo > 32) driveNo -= 32; + + Dsetdrv(driveNo); + Dsetpath("\\"); + + rc = Dcreate("DELETED"); + + if(rc) + { + log_write("Cannot create working directory.\n"); + return; + } + + Dsetpath("DELETED"); + + log_write("Creating and deleting files.\n"); + + for(pos = 0; pos < 64; pos++) + { + memset(filename, 0, 9); + sprintf(filename, "%X", pos); + handle = Fcreate(filename, 0); + + if(handle < 0) break; + + Fclose(handle); + Fdelete(filename); + } +}