Changeset 1544 for trunk/dll/wrappers.c


Ignore:
Timestamp:
Sep 30, 2010, 3:00:59 PM (15 years ago)
Author:
Gregg Young
Message:

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/wrappers.c

    r1476 r1544  
    370370}
    371371
     372/**
     373 * Wrapper for fopen it works around DosOpenL's failure to
     374 * thunk properly so that fm2 can be loaded in high memory
     375 * It also gives the option of reporting file open errors
     376 * If fSilent is TRUE it fails silently; if FALSE it produces a
     377 * runtime error dialog. Note pszMode must be passed on the stack
     378 * to xfopen to avoid the thunking problem.
     379 */
     380
    372381FILE *xfopen(PCSZ pszFileName, PCSZ pszMode, PCSZ pszSrcFile,
    373              UINT uiLineNumber)
    374 {
    375   FILE *fp = fopen(pszFileName, pszMode);
    376 
    377   if (!fp)
     382             UINT uiLineNumber, BOOL fSilent)
     383{
     384  CHAR FileName[CCHMAXPATH];
     385  FILE *fp;
     386
     387  strcpy(FileName, pszFileName);
     388  fp = fopen(FileName, pszMode);
     389
     390  if (!fp && !fSilent)
    378391    Runtime_Error(pszSrcFile, uiLineNumber, "fopen");
    379392  return fp;
    380393}
    381394
     395/**
     396 * Wrapper for _fsopen it works around DosOpenL's failure to
     397 * thunk properly so that fm2 can be loaded in high memory
     398 * It also gives the option of reporting file open errors
     399 * If fSilent is TRUE it fails silently; if FALSE it produces a
     400 * runtime error dialog. Note pszMode must be passed on the stack
     401 * to xfopen to avoid the thunking problem
     402 */
     403
    382404FILE *xfsopen(PCSZ pszFileName, PCSZ pszMode, INT fSharemode, PCSZ pszSrcFile,
    383               UINT uiLineNumber)
    384 {
    385   FILE *fp = _fsopen(pszFileName, pszMode, fSharemode);
    386 
    387   if (!fp)
     405              UINT uiLineNumber, BOOL fSilent)
     406{
     407  CHAR FileName[CCHMAXPATH];
     408  FILE *fp;
     409
     410  strcpy(FileName, pszFileName);
     411  fp = _fsopen(FileName, pszMode, fSharemode);
     412
     413  if (!fp && !fSilent)
    388414    Runtime_Error(pszSrcFile, uiLineNumber, "_fsopen");
    389415  return fp;
Note: See TracChangeset for help on using the changeset viewer.