From 7626ea03f8947ed41058880dd5f037ba3f90044c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 5 Apr 2021 21:51:56 +0100 Subject: [PATCH] In OS/2 change current drive before changing current directory. --- setter/src/os2/16bit/xattr.c | 11 +++++++++++ setter/src/os2/attr.c | 17 +++++++++++++++++ setter/src/os2/deleted.c | 17 +++++++++++++++++ setter/src/os2/dirdepth.c | 17 +++++++++++++++++ setter/src/os2/filename.c | 17 +++++++++++++++++ setter/src/os2/files.c | 17 +++++++++++++++++ setter/src/os2/frag.c | 17 +++++++++++++++++ setter/src/os2/os2defs.h | 2 ++ setter/src/os2/time.c | 12 ++++++++++++ 9 files changed, 127 insertions(+) diff --git a/setter/src/os2/16bit/xattr.c b/setter/src/os2/16bit/xattr.c index 39a9870..ba10cb5 100644 --- a/setter/src/os2/16bit/xattr.c +++ b/setter/src/os2/16bit/xattr.c @@ -45,6 +45,17 @@ void ExtendedAttributes(const char* path) HFILE handle; char message[300]; EAOP eap; + USHORT driveNo = path[0] - '@'; + + if(driveNo > 32) driveNo -= 32; + + rc = DosSelectDisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } drivePath[0] = path[0]; drivePath[1] = ':'; diff --git a/setter/src/os2/attr.c b/setter/src/os2/attr.c index 16959ab..da45648 100644 --- a/setter/src/os2/attr.c +++ b/setter/src/os2/attr.c @@ -47,6 +47,23 @@ void FileAttributes(const char* path) FILESTATUS3 fileStatus = {{0}}; #endif +// 16 bit +#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) + USHORT driveNo = path[0] - '@'; +#else // 32 bit + ULONG driveNo = path[0] - '@'; +#endif + + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\'; diff --git a/setter/src/os2/deleted.c b/setter/src/os2/deleted.c index 919bbd8..947b363 100644 --- a/setter/src/os2/deleted.c +++ b/setter/src/os2/deleted.c @@ -44,6 +44,23 @@ void DeleteFiles(const char* path) ACTION_RET actionTaken = 0; HFILE handle; +// 16 bit +#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) + USHORT driveNo = path[0] - '@'; +#else // 32 bit + ULONG driveNo = path[0] - '@'; +#endif + + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\'; diff --git a/setter/src/os2/dirdepth.c b/setter/src/os2/dirdepth.c index d1a3beb..c6a1adf 100644 --- a/setter/src/os2/dirdepth.c +++ b/setter/src/os2/dirdepth.c @@ -42,6 +42,23 @@ void DirectoryDepth(const char* path) char filename[9]; int pos = 2; +// 16 bit +#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) + USHORT driveNo = path[0] - '@'; +#else // 32 bit + ULONG driveNo = path[0] - '@'; +#endif + + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\'; diff --git a/setter/src/os2/filename.c b/setter/src/os2/filename.c index 73f4d6d..cb89dc1 100644 --- a/setter/src/os2/filename.c +++ b/setter/src/os2/filename.c @@ -44,6 +44,23 @@ void Filenames(const char* path) char message[300]; int pos = 0; +// 16 bit +#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) + USHORT driveNo = path[0] - '@'; +#else // 32 bit + ULONG driveNo = path[0] - '@'; +#endif + + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\'; diff --git a/setter/src/os2/files.c b/setter/src/os2/files.c index b5f68ce..0d2149c 100644 --- a/setter/src/os2/files.c +++ b/setter/src/os2/files.c @@ -44,6 +44,23 @@ void MillionFiles(const char* path) ACTION_RET actionTaken = 0; HFILE handle; +// 16 bit +#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) + USHORT driveNo = path[0] - '@'; +#else // 32 bit + ULONG driveNo = path[0] - '@'; +#endif + + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\'; diff --git a/setter/src/os2/frag.c b/setter/src/os2/frag.c index 133220b..0cab752 100644 --- a/setter/src/os2/frag.c +++ b/setter/src/os2/frag.c @@ -49,6 +49,23 @@ void Fragmentation(const char* path, size_t clusterSize) HFILE handle; long i; +// 16 bit +#if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) + USHORT driveNo = path[0] - '@'; +#else // 32 bit + ULONG driveNo = path[0] - '@'; +#endif + + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\'; diff --git a/setter/src/os2/os2defs.h b/setter/src/os2/os2defs.h index 36b105d..c986702 100644 --- a/setter/src/os2/os2defs.h +++ b/setter/src/os2/os2defs.h @@ -76,12 +76,14 @@ Copyright (C) 2011-2021 Natalia Portillo #define __os2_chdir(path) DosChDir(path, 0) #define __os2_mkdir(path) DosMkDir(path, 0) #define __os2_delete(path) DosDelete(path, 0) +#define __os2_chdisk(driveNumber) DosSelectDisk(driveNumber) #else // 32 bit #define __os2_chdir(path) DosSetCurrentDir(path) #define __os2_mkdir(path) DosCreateDir(path, NULL) #define __os2_delete(path) DosDelete(path) +#define __os2_chdisk(driveNumber) DosSetDefaultDisk(driveNumber) #endif diff --git a/setter/src/os2/time.c b/setter/src/os2/time.c index 831fba5..0351887 100644 --- a/setter/src/os2/time.c +++ b/setter/src/os2/time.c @@ -49,11 +49,23 @@ void Timestamps(const char* path) #if(defined(__I86__) || defined(__i86__) || defined(_M_I86)) USHORT status_size = sizeof(FILESTATUS); FILESTATUS status; + USHORT driveNo = path[0] - '@'; #else // 32 bit ULONG status_size = sizeof(FILESTATUS3); FILESTATUS3 status; + ULONG driveNo = path[0] - '@'; #endif + if(driveNo > 32) driveNo -= 32; + + rc = __os2_chdisk(driveNo); + + if(rc) + { + log_write("Cannot change to specified drive, not continuing.\n"); + return; + } + drivePath[0] = path[0]; drivePath[1] = ':'; drivePath[2] = '\\';