home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 6 File
/
06-File.zip
/
ramfs102.zip
/
src
/
write.c
< prev
Wrap
C/C++ Source or Header
|
2002-09-28
|
1KB
|
56 lines
#include "includes.h"
APIRET EXPENTRY FS_WRITE (
struct sffsi *psffsi,
struct sffsd *psffsd,
PCHAR pData,
PUSHORT pLen,
USHORT IOflag ) /* not used */
{
int rc;
POPENFILE pOpenfile;
ULONG cbNewPos;
FBLOCK fblkFile;
UtilEnterRamfs();
DEBUG_PRINTF2 ("FS_WRITE sfn=%d *pLen=%u", psffsi->sfi_selfsfn, *pLen);
pOpenfile = psffsd->pOpenfile;
VMRead (&fblkFile, pOpenfile->flatEntry + FIELDOFFSET(DIRENTRY,fblkFile), sizeof(FBLOCK));
#ifdef DEBUG
if (fblkFile.fSize != psffsi->sfi_size)
{
debugging = TRUE;
DEBUG_PRINTF2 ("\r\n!!! fblkFile.fSize = %lu, sfi_size = %lu\r\n",
fblkFile.fSize, psffsi->sfi_size);
INT3;
}
#endif
cbNewPos = psffsi->sfi_position + *pLen;
if (cbNewPos > psffsi->sfi_size)
{
rc = chsize_helper (&fblkFile, cbNewPos);
if (rc)
goto end;
VMWrite (pOpenfile->flatEntry + FIELDOFFSET(DIRENTRY,fblkFile), &fblkFile, sizeof(FBLOCK));
psffsi->sfi_size = cbNewPos;
}
write_fblocks(pData, &fblkFile, psffsi->sfi_position, *pLen);
psffsi->sfi_position = cbNewPos;
psffsi->sfi_tstamp |= (ST_SWRITE | ST_PWRITE);
rc = NO_ERROR;
end:
DEBUG_PRINTF1 (" => %d\r\n", rc);
UtilExitRamfs();
return rc;
}