find bug solved and fixed; contacting the maintainer TC 2.01 has memory layout
ff95 ff lfnSupported now when no LFN are detected, LFNFirstFile() findfirst(wildcard, &ff, 0); findfile(ff, FIND_FIRST, name, attr); convDOS(ff) { memcpy(ff->ff_95.ff_shortname, ff->ff_name, sizeof(ff->ff_name)); memcpy(ff->ff_95.ff_longname, ff->ff_name, sizeof(ff->ff_name)); ff->ff_95.ff_attr95 = ff->ff_attr; the last statement accesses memory behind ff, because ff is ffblk ff; and not ffblk95 ff; the following source code fixes the bug **** LFNAPI.C *************************************************************************************************************** #include <dir.h> #include <string.h> #include <dos.h> #include "io95\io95.h" #include "io95\find95.h" #include "lfnapi.h" /* MAP files are useful !! */ #define STATIC STATIC int CheckDriveOnLFN(char drive) { struct REGPACK rp; /* temporary stack for the registers */ static char strDrive[4]; static char filesys[32]; strcpy(strDrive, "?:\\"); strDrive[0] = drive; rp.r_flags = 1; /* asure that the carry is set */ rp.r_ax = 0x71A0; rp.r_ds = FP_SEG(strDrive); rp.r_dx = FP_OFF(strDrive); rp.r_es = FP_SEG(filesys); rp.r_di = FP_OFF(filesys); rp.r_cx = 32; intr(0x21, &rp); if (rp.r_flags & 1) return 0; return (rp.r_bx & 16384) > 0; } STATIC int IsLFNSupported (char *filename) { if (filename && filename[0] && (filename[1] == ':')) return CheckDriveOnLFN (filename[0]); else return CheckDriveOnLFN (getdisk () + 'A'); } int LFNConvertToSFN(char* file) { static char buffer[67]; if (IsLFNSupported(file)) { if (lfn2sfn95(file, buffer) == 0) { strcpy(file, buffer); return 1; } else return 0; } return 1; } STATIC int lfnSupported; STATIC union { struct ffblk95 ff95; struct ffblk ff; } finddata; int LFNFirstFile(char* wildcard, char* file, char* longfile) { int retVal; if (IsLFNSupported(wildcard)) { lfnSupported = 1; retVal = findfirst95(wildcard, &finddata.ff95, 0); if (retVal == 0) { strcpy(file, finddata.ff95.ff_95.ff_shortname); strcpy(longfile, finddata.ff95.ff_95.ff_longname); } return retVal; } else { lfnSupported = 0; retVal = findfirst(wildcard, &finddata.ff, 0); if (retVal == 0) { strcpy(file, finddata.ff.ff_name); strcpy(longfile, finddata.ff.ff_name); } return retVal; } } int LFNNextFile(char* file, char* longfile) { int retVal; if (lfnSupported) { retVal = findnext95(&finddata.ff95); if (retVal == 0) { strcpy(file, finddata.ff95.ff_95.ff_shortname); strcpy(longfile, finddata.ff95.ff_95.ff_longname); } return retVal; } else { retVal = findnext(&finddata.ff); if (retVal == 0) { strcpy(file, finddata.ff.ff_name); strcpy(longfile, finddata.ff.ff_name); } return retVal; } } void LFNFindStop() { if (lfnSupported) { findstop95(&finddata.ff95); } } *********************************************************************** Tom ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel