2000-05-06 21:34:20 +02:00
|
|
|
/****************************************************************/
|
|
|
|
/* */
|
|
|
|
/* fcbfns.c */
|
|
|
|
/* */
|
|
|
|
/* Old CP/M Style Function Handlers for Kernel */
|
|
|
|
/* */
|
|
|
|
/* Copyright (c) 1995 */
|
|
|
|
/* Pasquale J. Villani */
|
|
|
|
/* All Rights Reserved */
|
|
|
|
/* */
|
|
|
|
/* This file is part of DOS-C. */
|
|
|
|
/* */
|
|
|
|
/* DOS-C 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 */
|
|
|
|
/* 2, or (at your option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* DOS-C 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 DOS-C; see the file COPYING. If not, */
|
|
|
|
/* write to the Free Software Foundation, 675 Mass Ave, */
|
|
|
|
/* Cambridge, MA 02139, USA. */
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
#include "portab.h"
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
#ifdef VERSION_STRINGS
|
2001-11-18 15:01:12 +01:00
|
|
|
static BYTE *RcsId =
|
|
|
|
"$Id$";
|
2000-05-06 21:34:20 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FCB_SUCCESS 0
|
|
|
|
#define FCB_ERR_NODATA 1
|
|
|
|
#define FCB_ERR_EOF 3
|
|
|
|
#define FCB_ERR_WRITE 1
|
|
|
|
|
|
|
|
#ifdef PROTO
|
|
|
|
fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb);
|
2001-11-18 15:01:12 +01:00
|
|
|
fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer,
|
|
|
|
COUNT * pCurDrive);
|
2000-05-06 21:34:20 +02:00
|
|
|
void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);
|
|
|
|
VOID FcbNextRecord(fcb FAR * lpFcb);
|
|
|
|
BOOL FcbCalcRec(xfcb FAR * lpXfcb);
|
|
|
|
#else
|
|
|
|
fcb FAR *ExtFcbToFcb();
|
|
|
|
fcb FAR *CommonFcbInit();
|
|
|
|
void FcbNameInit();
|
|
|
|
VOID FcbNextRecord();
|
|
|
|
BOOL FcbCalcRec();
|
|
|
|
#endif
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL)
|
|
|
|
#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL)
|
2001-04-22 00:32:53 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
static dmatch Dmatch;
|
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
|
|
|
|
UCOUNT FAR * nc, BYTE FAR ** mdp)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-14 00:36:45 +01:00
|
|
|
UCOUNT navc;
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2001-11-04 20:47:39 +01:00
|
|
|
/* get the data available from dpb */
|
2001-11-18 15:01:12 +01:00
|
|
|
*nc = 0xffff; /* pass 0xffff to skip free count */
|
|
|
|
if (DosGetFree((UBYTE) drive, spc, &navc, bps, nc))
|
|
|
|
/* Point to the media desctriptor for this drive */
|
|
|
|
*mdp = (BYTE FAR *) & (CDSp->cds_table[drive].cdsDpb->dpb_mdb);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define PARSE_SEP_STOP 0x01
|
|
|
|
#define PARSE_DFLT_DRIVE 0x02
|
|
|
|
#define PARSE_BLNK_FNAME 0x04
|
|
|
|
#define PARSE_BLNK_FEXT 0x08
|
|
|
|
|
|
|
|
#define PARSE_RET_NOWILD 0
|
|
|
|
#define PARSE_RET_WILD 1
|
|
|
|
#define PARSE_RET_BADDRIVE 0xff
|
|
|
|
|
|
|
|
#ifndef IPL
|
2002-02-16 20:20:20 +01:00
|
|
|
WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
COUNT nIndex;
|
2002-01-23 23:29:41 +01:00
|
|
|
WORD wRetCodeName = FALSE, wRetCodeExt = FALSE;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* pjv -- ExtFcbToFcb? */
|
|
|
|
/* Start out with some simple stuff first. Check if we are */
|
|
|
|
/* going to use a default drive specificaton. */
|
|
|
|
if (!(wTestMode & PARSE_DFLT_DRIVE))
|
|
|
|
lpFcb->fcb_drive = FDFLT_DRIVE;
|
|
|
|
if (!(wTestMode & PARSE_BLNK_FNAME))
|
|
|
|
{
|
|
|
|
for (nIndex = 0; nIndex < FNAME_SIZE; ++nIndex)
|
|
|
|
lpFcb->fcb_fname[nIndex] = ' ';
|
|
|
|
}
|
|
|
|
if (!(wTestMode & PARSE_BLNK_FEXT))
|
|
|
|
{
|
|
|
|
for (nIndex = 0; nIndex < FEXT_SIZE; ++nIndex)
|
|
|
|
lpFcb->fcb_fext[nIndex] = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Undocumented behavior, set record number & record size to 0 */
|
|
|
|
lpFcb->fcb_cublock = lpFcb->fcb_recsiz = 0;
|
|
|
|
|
|
|
|
if (!(wTestMode & PARSE_SEP_STOP))
|
|
|
|
{
|
|
|
|
*lpFileName = ParseSkipWh(*lpFileName);
|
|
|
|
if (TestCmnSeps(*lpFileName))
|
|
|
|
++ * lpFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Undocumented "feature," we skip white space anyway */
|
|
|
|
*lpFileName = ParseSkipWh(*lpFileName);
|
|
|
|
|
|
|
|
/* Now check for drive specification */
|
|
|
|
if (*(*lpFileName + 1) == ':')
|
|
|
|
{
|
|
|
|
/* non-portable construct to be changed */
|
2001-09-23 22:39:44 +02:00
|
|
|
REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A';
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2001-03-31 00:27:42 +02:00
|
|
|
if (Drive >= lastdrive)
|
2000-05-06 21:34:20 +02:00
|
|
|
return PARSE_RET_BADDRIVE;
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2001-09-23 22:39:44 +02:00
|
|
|
lpFcb->fcb_drive = Drive + 1;
|
2000-05-06 21:34:20 +02:00
|
|
|
*lpFileName += 2;
|
|
|
|
}
|
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
/* special cases: '.' and '..' */
|
|
|
|
if (**lpFileName == '.')
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
lpFcb->fcb_fname[0] = '.';
|
|
|
|
++*lpFileName;
|
|
|
|
if (**lpFileName == '.')
|
|
|
|
{
|
|
|
|
lpFcb->fcb_fname[1] = '.';
|
2001-07-23 14:47:42 +02:00
|
|
|
++*lpFileName;
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
|
|
|
return PARSE_RET_NOWILD;
|
2001-07-23 14:47:42 +02:00
|
|
|
}
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Now to format the file name into the string */
|
2001-11-18 15:01:12 +01:00
|
|
|
*lpFileName =
|
|
|
|
GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE,
|
|
|
|
(BOOL *) & wRetCodeName);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Do we have an extension? If do, format it else return */
|
|
|
|
if (**lpFileName == '.')
|
2001-11-18 15:01:12 +01:00
|
|
|
*lpFileName =
|
|
|
|
GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext,
|
|
|
|
FEXT_SIZE, (BOOL *) & wRetCodeExt);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-02-16 20:20:20 +01:00
|
|
|
const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
while (*lpFileName == ' ' || *lpFileName == '\t')
|
|
|
|
++lpFileName;
|
|
|
|
return lpFileName;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
#if 0 /* defined above */
|
2000-05-06 21:34:20 +02:00
|
|
|
BOOL TestCmnSeps(BYTE FAR * lpFileName)
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
BYTE *pszTest, *pszCmnSeps = ":<|>+=,";
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
for (pszTest = pszCmnSeps; *pszTest != '\0'; ++pszTest)
|
|
|
|
if (*lpFileName == *pszTest)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
#if 0
|
2000-05-06 21:34:20 +02:00
|
|
|
BOOL TestFieldSeps(BYTE FAR * lpFileName)
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
BYTE *pszTest, *pszCmnSeps = "/\"[]<>|.";
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Another non-portable construct */
|
|
|
|
if (*lpFileName <= ' ')
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (pszTest = pszCmnSeps; *pszTest != '\0'; ++pszTest)
|
|
|
|
if (*lpFileName == *pszTest)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-04-22 00:32:53 +02:00
|
|
|
#endif
|
|
|
|
|
2002-02-16 20:20:20 +01:00
|
|
|
const BYTE FAR * GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField,
|
2000-05-06 21:34:20 +02:00
|
|
|
COUNT nFieldSize, BOOL * pbWildCard)
|
|
|
|
{
|
|
|
|
COUNT nIndex = 0;
|
|
|
|
BYTE cFill = ' ';
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
while (*lpFileName != '\0' && !TestFieldSeps(lpFileName)
|
|
|
|
&& nIndex < nFieldSize)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
if (*lpFileName == ' ')
|
|
|
|
break;
|
|
|
|
if (*lpFileName == '*')
|
|
|
|
{
|
|
|
|
*pbWildCard = TRUE;
|
|
|
|
cFill = '?';
|
|
|
|
++lpFileName;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*lpFileName == '?')
|
|
|
|
*pbWildCard = TRUE;
|
2000-08-06 07:50:17 +02:00
|
|
|
*lpDestField++ = DosUpFChar(*lpFileName++);
|
2000-05-06 21:34:20 +02:00
|
|
|
++nIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Blank out remainder of field on exit */
|
|
|
|
for (; nIndex < nFieldSize; ++nIndex)
|
|
|
|
*lpDestField++ = cFill;
|
|
|
|
return lpFileName;
|
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID FcbNextRecord(fcb FAR * lpFcb)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
if (++lpFcb->fcb_curec > 128)
|
|
|
|
{
|
|
|
|
lpFcb->fcb_curec = 0;
|
|
|
|
++lpFcb->fcb_cublock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC ULONG FcbRec(VOID)
|
2001-04-15 05:21:50 +02:00
|
|
|
{
|
2002-01-23 23:29:41 +01:00
|
|
|
return ((ULONG) lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec;
|
2001-04-15 05:21:50 +02:00
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode, UCOUNT recno)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
sft FAR *s;
|
2002-01-23 23:29:41 +01:00
|
|
|
ULONG lPosit;
|
2000-05-06 21:34:20 +02:00
|
|
|
COUNT nRead;
|
2002-01-23 23:29:41 +01:00
|
|
|
BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
/* Get the SFT block that contains the SFT */
|
2001-07-23 14:47:42 +02:00
|
|
|
if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
|
2000-05-06 21:34:20 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* If this is not opened another error */
|
|
|
|
if (s->sft_count == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Now update the fcb and compute where we need to position */
|
|
|
|
/* to. */
|
2001-04-15 05:21:50 +02:00
|
|
|
lPosit = FcbRec() * lpFcb->fcb_recsiz;
|
2000-05-08 06:30:00 +02:00
|
|
|
if (SftSeek(s, lPosit, 0) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
*nErrorCode = FCB_ERR_EOF;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-04 20:47:39 +01:00
|
|
|
/* Do the read */
|
2002-01-23 23:29:41 +01:00
|
|
|
nRead = DosReadSft(s, lpFcb->fcb_recsiz, FcbIoPtr, nErrorCode);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Now find out how we will return and do it. */
|
|
|
|
if (nRead == lpFcb->fcb_recsiz)
|
|
|
|
{
|
|
|
|
*nErrorCode = FCB_SUCCESS;
|
|
|
|
FcbNextRecord(lpFcb);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (nRead < 0)
|
|
|
|
{
|
|
|
|
*nErrorCode = FCB_ERR_EOF;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (nRead == 0)
|
|
|
|
{
|
|
|
|
*nErrorCode = FCB_ERR_NODATA;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-01-23 23:29:41 +01:00
|
|
|
fmemset(FcbIoPtr + nRead, 0, lpFcb->fcb_recsiz - nRead);
|
2000-05-06 21:34:20 +02:00
|
|
|
*nErrorCode = FCB_ERR_EOF;
|
|
|
|
FcbNextRecord(lpFcb);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode, UCOUNT recno)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
sft FAR *s;
|
2002-01-23 23:29:41 +01:00
|
|
|
ULONG lPosit;
|
2000-05-06 21:34:20 +02:00
|
|
|
COUNT nWritten;
|
2002-01-23 23:29:41 +01:00
|
|
|
BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
/* Get the SFT block that contains the SFT */
|
2001-07-23 14:47:42 +02:00
|
|
|
if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
|
2000-05-06 21:34:20 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* If this is not opened another error */
|
|
|
|
if (s->sft_count == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Now update the fcb and compute where we need to position */
|
|
|
|
/* to. */
|
2001-04-15 05:21:50 +02:00
|
|
|
lPosit = FcbRec() * lpFcb->fcb_recsiz;
|
2000-05-08 06:30:00 +02:00
|
|
|
if (SftSeek(s, lPosit, 0) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
*nErrorCode = FCB_ERR_EOF;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
nWritten = DosWriteSft(s, lpFcb->fcb_recsiz, FcbIoPtr, nErrorCode);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Now find out how we will return and do it. */
|
|
|
|
if (nWritten == lpFcb->fcb_recsiz)
|
|
|
|
{
|
2000-05-08 06:30:00 +02:00
|
|
|
lpFcb->fcb_fsize = s->sft_size;
|
2000-05-06 21:34:20 +02:00
|
|
|
FcbNextRecord(lpFcb);
|
|
|
|
*nErrorCode = FCB_SUCCESS;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (nWritten <= 0)
|
|
|
|
{
|
|
|
|
*nErrorCode = FCB_ERR_WRITE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
*nErrorCode = FCB_ERR_WRITE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbGetFileSize(xfcb FAR * lpXfcb)
|
|
|
|
{
|
2001-07-23 14:47:42 +02:00
|
|
|
COUNT FcbDrive, hndl;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Build a traditional DOS file name */
|
2001-07-23 14:47:42 +02:00
|
|
|
lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* check for a device */
|
2001-07-23 14:47:42 +02:00
|
|
|
if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0))
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-07-23 14:47:42 +02:00
|
|
|
hndl = DosOpen(SecPathName, O_RDONLY);
|
|
|
|
if (hndl >= 0)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-01-23 23:29:41 +01:00
|
|
|
ULONG fsize;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Get the size */
|
2001-07-23 14:47:42 +02:00
|
|
|
fsize = DosGetFsize(hndl);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* compute the size and update the fcb */
|
|
|
|
lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz;
|
|
|
|
if ((fsize % lpFcb->fcb_recsiz) != 0)
|
|
|
|
++lpFcb->fcb_rndm;
|
|
|
|
|
|
|
|
/* close the file and leave */
|
2001-07-23 14:47:42 +02:00
|
|
|
return DosClose(hndl) == SUCCESS;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbSetRandom(xfcb FAR * lpXfcb)
|
|
|
|
{
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
/* Now update the fcb and compute where we need to position */
|
2001-04-15 05:21:50 +02:00
|
|
|
/* to. */
|
|
|
|
lpFcb->fcb_rndm = FcbRec();
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbCalcRec(xfcb FAR * lpXfcb)
|
|
|
|
{
|
2001-11-04 20:47:39 +01:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
/* Now update the fcb and compute where we need to position */
|
|
|
|
/* to. */
|
2001-11-04 20:47:39 +01:00
|
|
|
lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128;
|
2001-04-15 05:21:50 +02:00
|
|
|
lpFcb->fcb_curec = lpFcb->fcb_rndm & 127;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords,
|
|
|
|
COUNT * nErrorCode)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-01-23 23:29:41 +01:00
|
|
|
UCOUNT recno = 0;
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
FcbCalcRec(lpXfcb);
|
|
|
|
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
do
|
2002-01-23 23:29:41 +01:00
|
|
|
FcbRead(lpXfcb, nErrorCode, recno++);
|
2000-05-06 21:34:20 +02:00
|
|
|
while ((--nRecords > 0) && (*nErrorCode == 0));
|
|
|
|
|
|
|
|
/* Now update the fcb */
|
2001-04-15 05:21:50 +02:00
|
|
|
lpFcb->fcb_rndm = FcbRec();
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords,
|
|
|
|
COUNT * nErrorCode)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2002-01-23 23:29:41 +01:00
|
|
|
UCOUNT recno = 0;
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
FcbCalcRec(lpXfcb);
|
|
|
|
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
do
|
2002-01-23 23:29:41 +01:00
|
|
|
FcbWrite(lpXfcb, nErrorCode, recno++);
|
2000-05-06 21:34:20 +02:00
|
|
|
while ((--nRecords > 0) && (*nErrorCode == 0));
|
|
|
|
|
|
|
|
/* Now update the fcb */
|
2001-04-15 05:21:50 +02:00
|
|
|
lpFcb->fcb_rndm = FcbRec();
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, FcbFunc_t *FcbFunc)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
UWORD uwCurrentBlock;
|
|
|
|
UBYTE ucCurrentRecord;
|
|
|
|
|
|
|
|
FcbCalcRec(lpXfcb);
|
|
|
|
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
|
|
|
uwCurrentBlock = lpFcb->fcb_cublock;
|
|
|
|
ucCurrentRecord = lpFcb->fcb_curec;
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
(*FcbFunc) (lpXfcb, nErrorCode, 0);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
lpFcb->fcb_cublock = uwCurrentBlock;
|
|
|
|
lpFcb->fcb_curec = ucCurrentRecord;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
/* merged fcbOpen and FcbCreate - saves ~200 byte */
|
|
|
|
BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-14 00:36:45 +01:00
|
|
|
sft FAR *sftp;
|
2001-07-23 14:47:42 +02:00
|
|
|
COUNT sft_idx, FcbDrive;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Build a traditional DOS file name */
|
|
|
|
lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
if (Create)
|
|
|
|
{
|
2002-02-16 20:20:20 +01:00
|
|
|
/* pass attribute without constraints (dangerous for directories) */
|
|
|
|
int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : 0);
|
|
|
|
sft_idx = DosCreatSft(PriPathName, attr);
|
2002-01-23 23:29:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sft_idx = DosOpenSft(PriPathName, O_RDWR | SFT_MFCB);
|
|
|
|
|
|
|
|
/* if file is RDONLY, try to open rdonly */
|
|
|
|
if (sft_idx == DE_ACCESS)
|
|
|
|
sft_idx = DosOpenSft(PriPathName, O_RDONLY | SFT_MFCB);
|
|
|
|
}
|
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
if (sft_idx < 0)
|
2001-11-18 15:01:12 +01:00
|
|
|
return FALSE;
|
2001-07-23 14:47:42 +02:00
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
sftp = idx_to_sft(sft_idx);
|
2001-11-18 00:26:45 +01:00
|
|
|
sftp->sft_mode |= SFT_MFCB;
|
2001-11-14 00:36:45 +01:00
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
lpFcb->fcb_sftno = sft_idx;
|
|
|
|
lpFcb->fcb_curec = 0;
|
|
|
|
lpFcb->fcb_rndm = 0;
|
2002-01-23 23:29:41 +01:00
|
|
|
|
|
|
|
lpFcb->fcb_recsiz = 0; /* true for devices */
|
2002-02-09 16:39:35 +01:00
|
|
|
if (!(sftp->sft_flags & SFT_FDEVICE)) /* check for a device */
|
2002-01-23 23:29:41 +01:00
|
|
|
{
|
|
|
|
lpFcb->fcb_drive = FcbDrive;
|
|
|
|
lpFcb->fcb_recsiz = 128;
|
|
|
|
}
|
|
|
|
lpFcb->fcb_fsize = sftp->sft_size;
|
|
|
|
lpFcb->fcb_date = sftp->sft_date;
|
|
|
|
lpFcb->fcb_time = sftp->sft_time;
|
2001-07-23 14:47:42 +02:00
|
|
|
return TRUE;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
|
2001-07-10 00:19:33 +02:00
|
|
|
STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
if (*((UBYTE FAR *) lpExtFcb) == 0xff)
|
|
|
|
return &lpExtFcb->xfcb_fcb;
|
|
|
|
else
|
|
|
|
return (fcb FAR *) lpExtFcb;
|
|
|
|
}
|
|
|
|
|
2001-07-10 00:19:33 +02:00
|
|
|
STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer,
|
2000-05-06 21:34:20 +02:00
|
|
|
COUNT * pCurDrive)
|
|
|
|
{
|
|
|
|
fcb FAR *lpFcb;
|
|
|
|
|
|
|
|
/* convert to fcb if needed first */
|
|
|
|
lpFcb = ExtFcbToFcb(lpExtFcb);
|
|
|
|
|
|
|
|
/* Build a traditional DOS file name */
|
|
|
|
FcbNameInit(lpFcb, pszBuffer, pCurDrive);
|
|
|
|
|
|
|
|
/* and return the fcb pointer */
|
|
|
|
return lpFcb;
|
|
|
|
}
|
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; /* 'A:' + '.' + '\0' */
|
2001-07-23 14:47:42 +02:00
|
|
|
BYTE *pszBuffer = loc_szBuffer;
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Build a traditional DOS file name */
|
|
|
|
if (lpFcb->fcb_drive != 0)
|
|
|
|
{
|
|
|
|
*pCurDrive = lpFcb->fcb_drive;
|
|
|
|
pszBuffer[0] = 'A' + lpFcb->fcb_drive - 1;
|
|
|
|
pszBuffer[1] = ':';
|
2001-03-21 03:56:26 +01:00
|
|
|
pszBuffer += 2;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pCurDrive = default_drive + 1;
|
|
|
|
}
|
2001-07-24 18:56:29 +02:00
|
|
|
ConvertName83ToNameSZ(pszBuffer, (BYTE FAR *) lpFcb->fcb_fname);
|
2001-07-23 14:47:42 +02:00
|
|
|
truename(loc_szBuffer, szBuffer, FALSE);
|
|
|
|
/* XXX fix truename error handling */
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbDelete(xfcb FAR * lpXfcb)
|
|
|
|
{
|
|
|
|
COUNT FcbDrive;
|
|
|
|
|
|
|
|
/* Build a traditional DOS file name */
|
2001-07-23 14:47:42 +02:00
|
|
|
CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* check for a device */
|
2001-07-23 14:47:42 +02:00
|
|
|
if (IsDevice(SecPathName))
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-16 20:20:20 +01:00
|
|
|
int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL);
|
2000-05-06 21:34:20 +02:00
|
|
|
BYTE FAR *lpOldDta = dta;
|
|
|
|
dmatch Dmatch;
|
|
|
|
|
|
|
|
dta = (BYTE FAR *) & Dmatch;
|
2002-02-16 20:20:20 +01:00
|
|
|
if (DosFindFirst(attr, SecPathName) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
dta = lpOldDta;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
2002-02-16 20:20:20 +01:00
|
|
|
SecPathName[0] = 'A' + FcbDrive - 1;
|
|
|
|
SecPathName[1] = ':';
|
|
|
|
strcpy(&SecPathName[2], Dmatch.dm_name);
|
|
|
|
if (DosDelete(SecPathName, attr) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
dta = lpOldDta;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-07-23 14:47:42 +02:00
|
|
|
while (DosFindNext() == SUCCESS);
|
2000-05-06 21:34:20 +02:00
|
|
|
dta = lpOldDta;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbRename(xfcb FAR * lpXfcb)
|
|
|
|
{
|
|
|
|
rfcb FAR *lpRenameFcb;
|
|
|
|
COUNT FcbDrive;
|
|
|
|
|
|
|
|
/* Build a traditional DOS file name */
|
2001-07-23 14:47:42 +02:00
|
|
|
lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
2002-02-16 20:20:20 +01:00
|
|
|
wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL);
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* check for a device */
|
2001-07-23 14:47:42 +02:00
|
|
|
if (IsDevice(SecPathName))
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BYTE FAR *lpOldDta = dta;
|
|
|
|
dmatch Dmatch;
|
|
|
|
|
|
|
|
dta = (BYTE FAR *) & Dmatch;
|
2002-02-16 20:20:20 +01:00
|
|
|
if (DosFindFirst(wAttr, SecPathName) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
dta = lpOldDta;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
fcb LocalFcb;
|
2002-02-16 20:20:20 +01:00
|
|
|
BYTE *pToName;
|
|
|
|
const BYTE FAR *pFromPattern = Dmatch.dm_name;
|
|
|
|
int i;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2002-02-16 20:20:20 +01:00
|
|
|
FcbParseFname(0, &pFromPattern, &LocalFcb);
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Overlay the pattern, skipping '?' */
|
|
|
|
/* I'm cheating because this assumes that the */
|
|
|
|
/* struct alignments are on byte boundaries */
|
|
|
|
pToName = LocalFcb.fcb_fname;
|
2002-02-16 20:20:20 +01:00
|
|
|
pFromPattern = lpRenameFcb->renNewName;
|
|
|
|
for (i = 0; i < FNAME_SIZE + FEXT_SIZE; i++)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
if (*pFromPattern != '?')
|
2002-02-16 20:20:20 +01:00
|
|
|
*pToName = *pFromPattern;
|
|
|
|
pToName++;
|
|
|
|
pFromPattern++;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-02-16 20:20:20 +01:00
|
|
|
SecPathName[0] = 'A' + FcbDrive - 1;
|
|
|
|
SecPathName[1] = ':';
|
|
|
|
strcpy(&SecPathName[2], Dmatch.dm_name);
|
|
|
|
truename(SecPathName, PriPathName, FALSE);
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* now to build a dos name again */
|
2002-02-16 20:20:20 +01:00
|
|
|
LocalFcb.fcb_drive = FcbDrive;
|
2001-07-23 14:47:42 +02:00
|
|
|
FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive);
|
|
|
|
|
2002-02-16 20:20:20 +01:00
|
|
|
if (DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
dta = lpOldDta;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-07-23 14:47:42 +02:00
|
|
|
while (DosFindNext() == SUCCESS);
|
2000-05-06 21:34:20 +02:00
|
|
|
dta = lpOldDta;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-10 00:19:33 +02:00
|
|
|
/* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB
|
|
|
|
this prevents problems with ".", ".." and saves code
|
2001-07-24 18:56:29 +02:00
|
|
|
BO:use global SearchDir, as produced by FindFirst/Next
|
2001-07-10 00:19:33 +02:00
|
|
|
*/
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
BOOL FcbClose(xfcb FAR * lpXfcb)
|
|
|
|
{
|
|
|
|
sft FAR *s;
|
|
|
|
|
|
|
|
/* Convert to fcb if necessary */
|
|
|
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
|
|
|
|
2001-08-19 14:58:36 +02:00
|
|
|
/* An already closed FCB can be closed again without error */
|
2001-11-18 15:01:12 +01:00
|
|
|
if (lpFcb->fcb_sftno == (BYTE) 0xff)
|
2001-08-19 14:58:36 +02:00
|
|
|
return TRUE;
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Get the SFT block that contains the SFT */
|
2001-07-23 14:47:42 +02:00
|
|
|
if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
|
2000-05-06 21:34:20 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
/* change time and set file size */
|
|
|
|
s->sft_size = lpFcb->fcb_fsize;
|
|
|
|
if (!(s->sft_flags & SFT_FSHARED))
|
|
|
|
dos_setfsize(s->sft_status, lpFcb->fcb_fsize);
|
2001-08-19 14:58:36 +02:00
|
|
|
DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time);
|
2002-01-23 23:29:41 +01:00
|
|
|
if (DosCloseSft(lpFcb->fcb_sftno, FALSE) == SUCCESS)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
|
|
|
lpFcb->fcb_sftno = (BYTE) 0xff;
|
2001-08-19 14:58:36 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2001-07-23 14:47:42 +02:00
|
|
|
}
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
/* close all files the current process opened by FCBs */
|
2001-07-23 14:47:42 +02:00
|
|
|
VOID FcbCloseAll()
|
|
|
|
{
|
|
|
|
COUNT idx = 0;
|
2001-11-14 00:36:45 +01:00
|
|
|
sft FAR *sftp;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) - 1; idx++)
|
2001-11-18 00:26:45 +01:00
|
|
|
if ((sftp->sft_mode & SFT_MFCB) && sftp->sft_psp == cu_psp)
|
2002-01-23 23:29:41 +01:00
|
|
|
DosCloseSft(idx, FALSE);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbFindFirst(xfcb FAR * lpXfcb)
|
|
|
|
{
|
2001-07-24 18:56:29 +02:00
|
|
|
BYTE FAR *lpDir;
|
2001-04-15 05:21:50 +02:00
|
|
|
COUNT FcbDrive;
|
2000-05-06 21:34:20 +02:00
|
|
|
psp FAR *lpPsp = MK_FP(cu_psp, 0);
|
|
|
|
|
|
|
|
/* First, move the dta to a local and change it around to match */
|
|
|
|
/* our functions. */
|
2001-07-24 18:56:29 +02:00
|
|
|
lpDir = (BYTE FAR *) dta;
|
2000-05-06 21:34:20 +02:00
|
|
|
dta = (BYTE FAR *) & Dmatch;
|
|
|
|
|
|
|
|
/* Next initialze local variables by moving them from the fcb */
|
2000-08-06 07:50:17 +02:00
|
|
|
lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
2000-05-06 21:34:20 +02:00
|
|
|
if (lpXfcb->xfcb_flag == 0xff)
|
|
|
|
{
|
|
|
|
wAttr = lpXfcb->xfcb_attrib;
|
2001-11-18 15:01:12 +01:00
|
|
|
fmemcpy(lpDir, lpXfcb, 7);
|
|
|
|
lpDir += 7;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
wAttr = D_ALL;
|
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
if (DosFindFirst(wAttr, SecPathName) != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
dta = lpPsp->ps_dta;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
*lpDir++ = FcbDrive;
|
2001-07-24 18:56:29 +02:00
|
|
|
fmemcpy(lpDir, &SearchDir, sizeof(struct dirent));
|
2000-06-21 20:16:46 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster;
|
2001-07-10 00:19:33 +02:00
|
|
|
lpFcb->fcb_strtclst = Dmatch.dm_entry;
|
2000-08-06 07:50:17 +02:00
|
|
|
|
2000-06-21 20:16:46 +02:00
|
|
|
/*
|
2000-08-06 07:50:17 +02:00
|
|
|
This is undocumented and seen using Pcwatch and Ramview.
|
2000-06-21 20:16:46 +02:00
|
|
|
The First byte is the current directory count and the second seems
|
|
|
|
to be the attribute byte.
|
|
|
|
*/
|
2001-11-18 15:01:12 +01:00
|
|
|
lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date. */
|
2000-06-21 20:16:46 +02:00
|
|
|
#if 0
|
|
|
|
lpFcb->fcb_cublock = Dmatch.dm_entry;
|
|
|
|
lpFcb->fcb_cublock *= 0x100;
|
|
|
|
lpFcb->fcb_cublock += wAttr;
|
|
|
|
#endif
|
2000-08-06 07:50:17 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
dta = lpPsp->ps_dta;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FcbFindNext(xfcb FAR * lpXfcb)
|
|
|
|
{
|
2001-07-24 18:56:29 +02:00
|
|
|
BYTE FAR *lpDir;
|
2001-04-15 05:21:50 +02:00
|
|
|
COUNT FcbDrive;
|
2000-05-06 21:34:20 +02:00
|
|
|
psp FAR *lpPsp = MK_FP(cu_psp, 0);
|
|
|
|
|
|
|
|
/* First, move the dta to a local and change it around to match */
|
|
|
|
/* our functions. */
|
2001-07-24 18:56:29 +02:00
|
|
|
lpDir = (BYTE FAR *) dta;
|
2000-05-06 21:34:20 +02:00
|
|
|
dta = (BYTE FAR *) & Dmatch;
|
|
|
|
|
|
|
|
/* Next initialze local variables by moving them from the fcb */
|
2000-08-06 07:50:17 +02:00
|
|
|
lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Reconstrct the dirmatch structure from the fcb */
|
2000-08-06 07:50:17 +02:00
|
|
|
Dmatch.dm_drive = lpFcb->fcb_sftno;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 00:26:45 +01:00
|
|
|
fmemcpy(Dmatch.dm_name_pat, lpFcb->fcb_fname, FNAME_SIZE + FEXT_SIZE);
|
2000-08-06 07:50:17 +02:00
|
|
|
DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE);
|
2000-06-21 20:16:46 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
Dmatch.dm_attr_srch = wAttr;
|
2001-07-10 00:19:33 +02:00
|
|
|
Dmatch.dm_entry = lpFcb->fcb_strtclst;
|
2001-09-23 22:39:44 +02:00
|
|
|
Dmatch.dm_dircluster = lpFcb->fcb_dirclst;
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2001-07-24 18:56:29 +02:00
|
|
|
if ((xfcb FAR *) lpFcb != lpXfcb)
|
|
|
|
{
|
|
|
|
wAttr = lpXfcb->xfcb_attrib;
|
2001-11-18 00:26:45 +01:00
|
|
|
fmemcpy(lpDir, lpXfcb, 7);
|
2001-07-24 18:56:29 +02:00
|
|
|
lpDir += 7;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wAttr = D_ALL;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-07-23 14:47:42 +02:00
|
|
|
if (DosFindNext() != SUCCESS)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
dta = lpPsp->ps_dta;
|
2000-06-21 20:16:46 +02:00
|
|
|
CritErrCode = 0x12;
|
2000-05-06 21:34:20 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
*lpDir++ = FcbDrive;
|
2001-07-24 18:56:29 +02:00
|
|
|
fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent));
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster;
|
2001-07-10 00:19:33 +02:00
|
|
|
lpFcb->fcb_strtclst = Dmatch.dm_entry;
|
2000-08-06 07:50:17 +02:00
|
|
|
|
|
|
|
lpFcb->fcb_sftno = Dmatch.dm_drive;
|
2000-06-21 20:16:46 +02:00
|
|
|
#if 0
|
|
|
|
lpFcb->fcb_cublock = Dmatch.dm_entry;
|
|
|
|
lpFcb->fcb_cublock *= 0x100;
|
|
|
|
lpFcb->fcb_cublock += wAttr;
|
|
|
|
#endif
|
2000-08-06 07:50:17 +02:00
|
|
|
|
|
|
|
dta = lpPsp->ps_dta;
|
2000-05-06 21:34:20 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-11-18 00:26:45 +01:00
|
|
|
/*
|
|
|
|
* Log: fcbfns.c,v - for newer entries see "cvs log fcbfns.c"
|
|
|
|
*
|
|
|
|
* Revision 1.7 2000/03/31 05:40:09 jtabor
|
|
|
|
* Added Eric W. Biederman Patches
|
|
|
|
*
|
|
|
|
* Revision 1.6 2000/03/17 22:59:04 kernel
|
|
|
|
* Steffen Kaiser's NLS changes
|
|
|
|
*
|
|
|
|
* Revision 1.5 2000/03/09 06:07:11 kernel
|
|
|
|
* 2017f updates by James Tabor
|
|
|
|
*
|
|
|
|
* Revision 1.4 1999/09/23 04:40:46 jprice
|
|
|
|
* *** empty log message ***
|
|
|
|
*
|
|
|
|
* Revision 1.2 1999/04/04 18:51:43 jprice
|
|
|
|
* no message
|
|
|
|
*
|
|
|
|
* Revision 1.1.1.1 1999/03/29 15:42:15 jprice
|
|
|
|
* New version without IPL.SYS
|
|
|
|
*
|
|
|
|
* Revision 1.5 1999/02/09 02:54:23 jprice
|
|
|
|
* Added Pat's 1937 kernel patches
|
|
|
|
*
|
|
|
|
* Revision 1.4 1999/02/04 03:18:37 jprice
|
|
|
|
* Formating. Added comments.
|
|
|
|
*
|
|
|
|
* Revision 1.3 1999/02/01 01:43:28 jprice
|
|
|
|
* Fixed findfirst function to find volume label with Windows long filenames
|
|
|
|
*
|
|
|
|
* Revision 1.2 1999/01/22 04:15:28 jprice
|
|
|
|
* Formating
|
|
|
|
*
|
|
|
|
* Revision 1.1.1.1 1999/01/20 05:51:00 jprice
|
|
|
|
* Imported sources
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Rev 1.7 06 Dec 1998 8:44:10 patv
|
|
|
|
* Expanded fcb functions for new I/O subsystem.
|
|
|
|
*
|
|
|
|
* Rev 1.6 04 Jan 1998 23:14:38 patv
|
|
|
|
* Changed Log for strip utility
|
|
|
|
*
|
|
|
|
* Rev 1.5 03 Jan 1998 8:36:02 patv
|
|
|
|
* Converted data area to SDA format
|
|
|
|
*
|
|
|
|
* Rev 1.4 16 Jan 1997 12:46:38 patv
|
|
|
|
* pre-Release 0.92 feature additions
|
|
|
|
*
|
|
|
|
* Rev 1.3 29 May 1996 21:15:14 patv
|
|
|
|
* bug fixes for v0.91a
|
|
|
|
*
|
|
|
|
* Rev 1.2 01 Sep 1995 17:48:44 patv
|
|
|
|
* First GPL release.
|
|
|
|
*
|
|
|
|
* Rev 1.1 30 Jul 1995 20:50:26 patv
|
|
|
|
* Eliminated version strings in ipl
|
|
|
|
*
|
|
|
|
* Rev 1.0 02 Jul 1995 8:06:06 patv
|
|
|
|
* Initial revision.
|
|
|
|
*/
|