From 8e10a1f8982532f3a344f53ce9797683873dfc03 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 12 Mar 2021 00:05:02 +0000 Subject: [PATCH] Merge OS/2 directory depth code. --- setter/src/os2/32bit/dirdepth.c | 91 --------------------------- setter/src/os2/{16bit => }/dirdepth.c | 17 +++-- 2 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 setter/src/os2/32bit/dirdepth.c rename setter/src/os2/{16bit => }/dirdepth.c (85%) diff --git a/setter/src/os2/32bit/dirdepth.c b/setter/src/os2/32bit/dirdepth.c deleted file mode 100644 index 05c20cd..0000000 --- a/setter/src/os2/32bit/dirdepth.c +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -Aaru Data Preservation Suite ------------------------------------------------------------------------------ - -Filename : os2_32.c -Author(s) : Natalia Portillo - ---[ Description ] ----------------------------------------------------------- - -Contains 32-bit OS/2 code - ---[ 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 -*****************************************************************************/ - -#if(defined(__I386__) || defined(__i386__) || defined(__THW_INTEL) || defined(_M_I386)) && \ - (defined(__OS2__) || defined(__os2__)) && !defined(__DOS__) - -#define INCL_DOSMISC -#define INCL_DOSFILEMGR - -#include -#include -#include -#include - -#include "../os2.h" -#include "include/consts.h" -#include "include/defs.h" - -void DirectoryDepth(const char* path) -{ - char drivePath[4]; - APIRET rc = 0; - char filename[9]; - long pos = 2; - - drivePath[0] = path[0]; - drivePath[1] = ':'; - drivePath[2] = '\\'; - drivePath[3] = 0; - - rc = DosSetCurrentDir(drivePath); - - if(rc) - { - printf("Cannot change to specified path, not continuing.\n"); - return; - } - - rc = DosCreateDir("DEPTH", NULL); - - if(rc) - { - printf("Cannot create working directory.\n"); - return; - } - - rc = DosSetCurrentDir("DEPTH"); - - printf("Creating deepest directory tree.\n"); - - while(!rc) - { - memset(&filename, 0, 9); - sprintf(&filename, "%08d", pos); - rc = DosCreateDir(filename, NULL); - - if(!rc) rc = DosSetCurrentDir(filename); - - pos++; - } - - printf("\tCreated %d levels of directory hierarchy\n", pos); -} - -#endif diff --git a/setter/src/os2/16bit/dirdepth.c b/setter/src/os2/dirdepth.c similarity index 85% rename from setter/src/os2/16bit/dirdepth.c rename to setter/src/os2/dirdepth.c index e5df5e1..9abb86c 100644 --- a/setter/src/os2/16bit/dirdepth.c +++ b/setter/src/os2/dirdepth.c @@ -27,8 +27,7 @@ Contains 16-bit OS/2 code Copyright (C) 2011-2021 Natalia Portillo *****************************************************************************/ -#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) && (defined(__OS2__) || defined(__os2__)) && \ - !defined(__DOS__) +#if((defined(__OS2__) || defined(__os2__)) && !defined(__DOS__) #define INCL_DOSMISC #define INCL_DOSFILEMGR @@ -38,14 +37,14 @@ Copyright (C) 2011-2021 Natalia Portillo #include #include -#include "../os2.h" #include "include/consts.h" #include "include/defs.h" +#include "os2.h" void DirectoryDepth(const char* path) { char drivePath[4]; - USHORT rc = 0; + APIRET rc = 0; char filename[9]; long pos = 2; @@ -54,7 +53,7 @@ void DirectoryDepth(const char* path) drivePath[2] = '\\'; drivePath[3] = 0; - rc = DosChDir(drivePath, 0); + rc = __os2_chdir(drivePath); if(rc) { @@ -62,7 +61,7 @@ void DirectoryDepth(const char* path) return; } - rc = DosMkDir("DEPTH", 0); + rc = __os2_mkdir("DEPTH"); if(rc) { @@ -70,7 +69,7 @@ void DirectoryDepth(const char* path) return; } - rc = DosChDir("DEPTH", 0); + rc = __os2_chdir("DEPTH"); printf("Creating deepest directory tree.\n"); @@ -78,9 +77,9 @@ void DirectoryDepth(const char* path) { memset(&filename, 0, 9); sprintf(&filename, "%08d", pos); - rc = DosMkDir(filename, 0); + rc = __os2_mkdir(filename); - if(!rc) rc = DosChDir(filename, 0); + if(!rc) rc = __os2_chdir(filename); pos++; }