示例#1
0
char far *InitAlias( char far * inname )
/**************************************/
{
    USHORT hdl,read;
    static char b[80];
    char *bp;
    unsigned long ppos,pos;
    USHORT action;
    char far *endname;
    static char noalias = 0;

    endname = inname;
    while( *endname == ' ' ) ++endname;
    for( ;; ) {
        if( *endname == '\0' ) {
            break;
        }
        if( *endname == ' ' ) {
            *endname = '\0';
            ++endname;
            break;
        }
        ++endname;
    }
    bp = b;
    while( *bp = *inname ) {
        ++bp;
        ++inname;
    }
    action=action;
    if( DosOpen( b, &hdl, &action, 0L, 0, 1, 0x10 ,0L ) == 0 ) {
        DosChgFilePtr( hdl, 0L, 2, &ppos );
        pos = ppos;
        DosChgFilePtr( hdl, 0L, 0, &ppos );
#ifdef DOS
        {
            static int alias_seg;
            DosAllocSeg( pos + 1 + ALIAS_SLACK, &alias_seg, 0 );
            *(((int far *)&AliasList)+0) = 0;
            *(((int far *)&AliasList)+1) = alias_seg;
            AliasSize = pos + ALIAS_SLACK;
        }
#else
        AliasList = AliasArea;
        AliasSize = 2047;
#endif
        DosRead( hdl, AliasList, pos, &read );
        if( pos > 0 && AliasList[ pos-1 ] != '\n' ) {
            AliasList[ pos+0 ] = '\r';
            AliasList[ pos+1 ] = '\n';
            AliasList[ pos+2 ] = '\0';
        } else {
            AliasList[ pos ] = '\0';
        }
        DosClose( hdl );
    } else {
        AliasList = &noalias;
    }
    return( endname );
}
示例#2
0
char __far *InitAlias( char __far * inname )
/******************************************/
{
    USHORT          hdl,read;
    static char     b[80];
    char            *bp;
    unsigned long   ppos,pos;
    USHORT          action;
    char            __far *endname;
    static char     noalias = 0;
#ifndef DOS
    static char     AliasArea[2048]; /* The DLL seems to need static memory */
#endif

    endname = inname;
    while( *endname == ' ' )
        ++endname;
    for( ; *endname != '\0'; endname++ ) {
        if( *endname == ' ' ) {
            *endname++ = '\0';
            break;
        }
    }
    for( bp = b; (*bp = *inname) != '\0'; bp++ ) {
        ++inname;
    }
    action=action;
    if( DosOpen( b, &hdl, &action, 0L, 0, 1, 0x10 ,0L ) == 0 ) {
        DosChgFilePtr( hdl, 0L, 2, &ppos );
        pos = ppos;
        DosChgFilePtr( hdl, 0L, 0, &ppos );
#ifdef DOS
        {
            static int alias_seg;

            DosAllocSeg( pos + 1 + ALIAS_SLACK, &alias_seg, 0 );
            AliasList = (char __far *)MK_FP( alias_seg, 0 );
            AliasSize = pos + ALIAS_SLACK;
        }
#else
        AliasList = AliasArea;
        AliasSize = 2047;
#endif
        DosRead( hdl, AliasList, pos, &read );
        if( pos > 0 && AliasList[pos - 1] != '\n' ) {
            AliasList[pos + 0] = '\r';
            AliasList[pos + 1] = '\n';
            AliasList[pos + 2] = '\0';
        } else {
            AliasList[pos] = '\0';
        }
        DosClose( hdl );
    } else {
        AliasList = &noalias;
    }
    return( endname );
}
示例#3
0
_WCRTLINK long __lseek( int handle, long offset, int origin )
{
    long            pos;

    __handle_check( handle, -1 );

#if defined( __OS2__ )
    {
        APIRET          rc;

        rc = DosChgFilePtr( handle, offset, origin, (PULONG)&pos );
        if( rc != 0 ) {
            return( __set_errno_dos( rc ) );
        }
    }
#elif defined( __NT__ )
    pos = SetFilePointer( __getOSHandle( handle ), offset, 0, origin );
    if( pos == INVALID_SET_FILE_POINTER ) {
        return( __set_errno_nt() );
    }
#elif defined( __DOS__ ) || defined( __WINDOWS__ )
    {
        tiny_ret_t      rc;

        rc = TinyLSeek( handle, offset, origin, (u32_stk_ptr)&pos );
        if( TINY_ERROR( rc ) ) {
            return( __set_errno_dos( TINY_INFO( rc ) ) );
        }
    }
#endif
    return( pos );
}
示例#4
0
LONG loadFile (char *fn)
{
HFILE file;   /* handle */
ULONG ac;   /* action code (from DosOpen) */
APIRET rc;   /* return code (from API functions) */
ULONG rd;   /* bytes actually read */
ULONG cbSize;   /* file size in bytes */
ULONG dummy;   /* used when seeking back to beginning of file */

/* try to open existing file --  access */
rc = DosOpen (fn, &file, &ac, 0, 0,
	      OPEN_ACTION_OPEN_IF_EXISTS,
	      OPEN_FLAGS_SEQUENTIAL |
	      OPEN_SHARE_DENYNONE |
	      OPEN_ACCESS_READONLY,
	      0);
if (rc != 0)    /* failed */
   return (0);

DosChgFilePtr (file, 0L, 2, &cbSize);   /* determine file size */
if (cbSize > 30000L)
   {
   DosBeep(3700, 100);
   DosClose (file);
   return (-1);
   }

DosChgFilePtr (file, 0L, 0, &dummy);   /* reset pointer to beginning */
rc = DosAllocMem(&iobuf,               /* Allocate memory object         */
		 (INT)cbSize,          /* Size of memory object          */
		 PAG_COMMIT |          /* Commit memory immediately      */
		 PAG_READ   |          /* Allow read access              */
		 PAG_WRITE);           /* Allow write access             */

if (rc != 0)
   return (0);

/* read entire file into buffer */
DosRead (file, iobuf, cbSize, &rd);
DosClose (file);
return (LONG)cbSize;
}
示例#5
0
/*
 * SeekRead - seek to a file position, and read the data
 */
BOOL SeekRead( HFILE handle, ULONG newpos, void *ptr, USHORT size )
{
    USHORT      read;
    ULONG       pos;

    if( DosChgFilePtr( handle, newpos, 0, &pos ) != 0 ) {
        return( FALSE );
    }
    if( DosRead( handle, ptr, size, &read ) != 0 ) {
        return( FALSE );
    }
    if( read != size ) {
        return( FALSE );
    }
    return( TRUE );

} /* SeekRead */
示例#6
0
  _WCRTLINK int write( int handle, const void *buffer, unsigned len )
#endif
/**********************************************************************/
{
    unsigned    iomode_flags;
    char        *buf;
    unsigned    buf_size;
    unsigned    len_written, i, j;
#if defined(__NT__)
    HANDLE      h;
    LONG        cur_ptr_low;
    LONG        cur_ptr_high;
    DWORD       rc1;
#else
    tiny_ret_t  rc1;
#endif
    int         rc2;

    __handle_check( handle, -1 );
    iomode_flags = __GetIOMode( handle );
    if( iomode_flags == 0 ) {
#if defined(__WINDOWS__) || defined(__WINDOWS_386__)
        // How can we write to the handle if we never opened it? JBS
        return( _lwrite( handle, buffer, len ) );
#else
        __set_errno( EBADF );
        return( -1 );
#endif
    }
    if( !(iomode_flags & _WRITE) ) {
        __set_errno( EACCES );     /* changed from EBADF to EACCES 23-feb-89 */
        return( -1 );
    }

#if defined(__NT__)
    h = __getOSHandle( handle );
#endif

    // put a semaphore around our writes

    _AccessFileH( handle );
    if( (iomode_flags & _APPEND) && !(iomode_flags & _ISTTY) ) {
#if defined(__NT__)
        if( GetFileType( h ) == FILE_TYPE_DISK ) {
            cur_ptr_low = 0;
            cur_ptr_high = 0;
            rc1 = SetFilePointer( h, cur_ptr_low, &cur_ptr_high, FILE_END );
            if( rc1 == INVALID_SET_FILE_POINTER ) { // this might be OK so
                if( GetLastError() != NO_ERROR ) {
                    _ReleaseFileH( handle );
                    return( __set_errno_nt() );
                }
            }
        }
#elif defined(__OS2__)
        {
            unsigned long       dummy;
            rc1 = DosChgFilePtr( handle, 0L, SEEK_END, &dummy );
            // should we explicitly ignore ERROR_SEEK_ON_DEVICE here?
        }
#else
        rc1 = TinySeek( handle, 0L, SEEK_END );
#endif
#if !defined(__NT__)
        if( TINY_ERROR( rc1 ) ) {
            _ReleaseFileH( handle );
            return( __set_errno_dos( TINY_INFO( rc1 ) ) );
        }
#endif
    }

    len_written = 0;
    rc2 = 0;

    // Pad the file with zeros if necessary
    if( iomode_flags & _FILEEXT ) {
        // turn off file extended flag
        __SetIOMode_nogrow( handle, iomode_flags&(~_FILEEXT) );

        // It is not required to pad a file with zeroes on an NTFS file system;
        // unfortunately it is required on FAT (and probably FAT32). (JBS)
        rc2 = zero_pad( handle );
    }

    if( rc2 == 0 ) {
        if( iomode_flags & _BINARY ) {  /* if binary mode */
            rc2 = os_write( handle, buffer, len, &len_written );
            /* end of binary mode part */
        } else {    /* text mode */
            i = stackavail();
            if( i < 0x00b0 ) {
                __STKOVERFLOW();    /* not enough stack space */
            }
            buf_size = 512;
            if( i < (512 + 48) ) {
                buf_size = 128;
            }
#if defined(__AXP__) || defined(__PPC__)
            buf = alloca( buf_size );
#else
            buf = __alloca( buf_size );
#endif
            j = 0;
            for( i = 0; i < len; ) {
                if( ((const char*)buffer)[i] == '\n' ) {
                    buf[j] = '\r';
                    ++j;
                    if( j == buf_size ) {
                        rc2 = os_write( handle, buf, buf_size, &j );
                        if( rc2 == -1 )
                            break;
                        len_written += j;
                        if( rc2 == ENOSPC )
                            break;
                        len_written = i;
                        j = 0;
                    }
                }
                buf[j] = ((const char*)buffer)[i];
                ++i;
                ++j;
                if( j == buf_size ) {
                    rc2 = os_write( handle, buf, buf_size, &j );
                    if( rc2 == -1 )
                        break;
                    len_written += j;
                    if( rc2 == ENOSPC )
                        break;
                    len_written = i;
                    j = 0;
                }
            }
            if( j ) {
                rc2 = os_write( handle, buf, j, &i );
                if( rc2 == ENOSPC ) {
                    len_written += i;
                } else {
                    len_written = len;
                }
            }
            /* end of text mode part */
        }
    }
    _ReleaseFileH( handle );
    if( rc2 == -1 ) {
        return( rc2 );
    } else {
        return( len_written );
    }
}
示例#7
0
void License(int iArgCount, char *apArgument[])
    {
    WORD Error;
    HFILE hDest;
    ULONG ulCount;
    ULONG ulStatus;
    WORD wIndex;
    WORD wArgIndex = 0;
    BOOL bTriedAccess = FALSE;
    WORD wLicenseCount;

    wLicenseCount = (WORD)atoi(abyTemp);
    if (wLicenseCount > 40000)
        {
        printf("\nRequest for %u licenses denied.  The maximum allowed is 40,000.\n\n",wLicenseCount);
        return;
        }

    wIndex = 0;
    while (abyDestPath[wIndex] != 0)
        {
        abyDestPath[wIndex] = (BYTE)toupper(abyDestPath[wIndex]);
        wIndex++;
        }

    AppendPath(&abyDestPath[wDestPathLength],abyConvertFile);
//    DosSetFileMode(abyDestPath,0x0000,0L);
    if ((Error = OpenFile(abyDestPath,&hDest,&wStatus,0L,0,1,0x6192)) != 0)
        {
        printf("Cannot open %s\n to set or read license count. ",abyDestPath);
        bTriedAccess = TRUE;
        }
    DosChgFilePtr(hDest,oFileOffset + oCopyCount,0,&dwFilePosition);
    if (wLicenseCount != 0)
        {
        if ((Error = DosWrite(hDest,&(BYTE)wLicenseCount,2,&wCount)) != 0)
            {
            printf("%sWKC%04X\n",abyLicenseSourceFailed,Error | 0x8000);
            return;
            }
        if (wLicenseCount == 0xaaaa)
            printf("\nCopy protection has been disabled for\n\n%s\n\n",abyDestPath);
        else
            printf("\nThe License Count has been set to %u for\n\n%s\n\n",wLicenseCount,abyDestPath);
        }
    else
        {
        if ((Error = DosRead(hDest,&(BYTE)wLicenseCount,2,&wCount)) != 0)
            {
            printf("%sRKC%04X\n",abyLicenseSourceFailed,Error | 0x8000);
            return;
            }
        if (wLicenseCount == 0xaaaa)
            printf("\nCopy protection is disabled for\n\n%s\n\n",abyDestPath);
        else
            printf("\nThe License Count for\n\n%s = %u\n\n",abyDestPath,wLicenseCount);
        }
    DosClose(hDest);
    if (wLicenseCount == 0xaaaa)
      DosSetFileMode(abyDestPath,0x0020,0L);
    else
      DosSetFileMode(abyDestPath,0x0021,0L);
    }
示例#8
0
WORD Uninstall(CHAR szSourcePath[],CHAR szDeletePath[])
    {
    HFILE hSource;
    HFILE hDelete;
    ULONG ulCopyKey;
    ULONG ulCount;
    ULONG ulStatus;
    ULONG ulTemp;
    ULONG ulFilePosition;
    ULONG ulPathLength;

    AppendPath(&szSourcePath[strlen(szSourcePath)],szSourceFile);

//    DosSetFileMode(szSourcePath,0x0000,0L);
    if ((ulLastError = DosOpen(szSourcePath,(PHFILE)&hSource,&ulStatus,0L,0,0x01,0x61a2,0L)) != 0)
        return(SOURCE_FILE_OPEN);

    ulPathLength = strlen(szDeletePath);

    AppendPath(&szDeletePath[ulPathLength],szDeviceFile);
    /*
    **  read code key from driver to delete
    if ((wLastError = DosSetFileMode(szDeletePath,0x0000,0L)) != 0)
        return(DEST_FILE_MODE_SET);
    */

    if ((wLastError = DosOpen(szDeletePath,(PHFILE)&hDelete,&ulStatus,0L,0,0x01,0x61a2,0L)) != 0)
        return(DEST_FILE_OPEN);

    DosChgFilePtr(hDelete,oFileOffset + oCopyKey,0,&ulFilePosition);

    if ((wLastError = DosRead(hDelete,(BYTE *)&ulCopyKey,4,&ulCount)) != 0)
        return(DEST_FILE_READ);

    DosClose(hDelete);

    AppendPath(&szDeletePath[ulPathLength],szHiddenFile);

#ifdef this_junk
    if ((wLastError = DosQFileMode(szDeletePath,&ulTemp,0L)) != 0)
        return(HIDE_FILE_MODE_READ);

    if ((ulTemp & 0x0007) != 0x0007)
        return(HIDE_FILE_MODE);

    if ((wLastError = DosSetFileMode(szDeletePath,0x0000,0L)) != 0)
        return(HIDE_FILE_MODE_SET);
#endif
    if ((wLastError = DosOpen(szHiddenPath,(PHFILE)&hDelete,(PUSHORT)&ulStatus,0L,0,0x01,0x61a2,0L)) != 0)
        return(HIDE_FILE_OPEN);

    DosChgFilePtr(hDelete,20,0,&ulFilePosition);

    if ((wLastError = DosRead(hDelete,&(BYTE)stCodeKey.ulCopyKey,4,&ulCount)) != 0)
        return(HIDE_FILE_READ);

    DosClose(hDelete);

    if ((wLastError = DosDelete(szHiddenPath,0L)) != 0)
        return(HIDE_FILE_DELETE);

    AppendPath(&szDeletePath[ulPathLength],szDeviceFile);

    if ((wLastError = DosDelete(szDeletePath,0L)) != 0)
        return(DEST_FILE_DELETE);

    if (ulCopyKey != stCodeKey.ulCopyKey)
        return(BAD_CODE_KEY);
    /*
    ** read copy count from .SRC file, increment it, and write it back
    */
    DosChgFilePtr(hSource,oFileOffset + oCopyCount,0,&ulFilePosition);

    if ((wLastError = DosRead(hSource,&(BYTE)stCodeKey.wCopyCount,2,&ulCount)) != 0)
        return(CAT_SOURCE_READ);

    stCodeKey.wCopyCount++;

    DosChgFilePtr(hSource,oFileOffset + oCopyCount,0,&ulFilePosition);

    if ((wLastError = DosWrite(hSource,&(BYTE)stCodeKey.wCopyCount,2,&ulCount)) != 0)
        return(CAT_SOURCE_WRITE);

    DosClose(hSource);
    if (stCodeKey.wCopyCount > 1)
      {
      sprintf(szMessage,"There are %u %s authorized device\ndriver licenses available for installation.",
                        stCodeKey.wCopyCount,abyDeviceFile);
      MessageBox(hwndClient,szMessage)
      }
示例#9
0
WORD Install(CHAR szSourcePath[],CHAR szDestPath)
    {
    HFILE hSource;
    HFILE hDestination;
    WORD wCount;
    WORD wStatus;
    WORD wTemp;
    WORD wAttrib;
    WORD wIndex;
    DWORD dwFilePosition;
    WORD wDestPathLength;
    WORD wSourcePathLength;

    DosGetDateTime(&stDateTime);
    stCodeKey.dwCopyKey = (DWORD)stDateTime.hours;
    stCodeKey.dwCopyKey |= (DWORD)stDateTime.minutes << 4;
    stCodeKey.dwCopyKey |= (DWORD)stDateTime.seconds << 10;
    stCodeKey.dwCopyKey |= (DWORD)stDateTime.hundredths << 16;
    stCodeKey.dwCopyKey |= (DWORD)stDateTime.day << 23;
    stCodeKey.dwCopyKey |= (DWORD)stDateTime.month << 27;
    stCodeKey.dwCopyKey |= (DWORD)stDateTime.year << 31;

    wSourcePathLength = strlen(szSourthPath);
    AppendPath(&szSourcePath[wSourcePathLength)],szSourceFile);
    if (DosSetFileMode(abySourcePath,0x0000,0L));
    if ((wLastError = DosOpen(abySourcePath,(PHFILE)&hSource,(PUSHORT)&wStatus,0L,0,0x01,0x61a2,0L)) != 0)
      return(SOURCE_FILE_OPEN);

    DosChgFilePtr(hSource,oFileOffset + oCopyCount,0,&dwFilePosition);
    if ((wLastError = DosRead(hSource,&(BYTE)wTemp,2,&wCount)) != 0)
      return(SOURCE_FILE_READ);

    if (wTemp == 0)
      return(SOURCE_NO_LICENSE);

    if ((wLastError = DosQFileMode(abyDestPath,&wAttrib,0L)) != 0)
      return(SOURCE_FILE_MODE);

    if ((wAttrib & 0x0010) != 0x0010)
      return(DEST_BAD_PATH);

    wDestPathLength = strlen(szDestPath);
    AppendPath(&szDestPath[wDestPathLength],szDeviceFile);
    if (wLastError = FileCopy(szSourcePath,szDestPath) != 0)
        return(SOURCE_FILE_COPY);

    if ((wLastError = DosOpen(szDestPath,(PHFILE)&hDestination,(PUSHORT)&wStatus,0L,0,1,0x6192,0L)) != 0)
        return(DEST_FILE_OPEN);

    stCodeKey.wCopyCount = 0;
    DosChgFilePtr(hDestination,oFileOffset + oCopyKey,0,&dwFilePosition);
    if ((wLastError = DosWrite(hDestination,&(BYTE)stCodeKey.dwCopyKey,6,&wCount)) != 0)
        return(DEST_WRITE_CODE_KEY);

    DosClose(hDestination);
    DosSetFileMode(abyDestPath,0x0021,0L);
    stCodeKey.wCopyCount = wTemp;

    AppendPath(&abyDestPath[wDestPathLength],abyHiddenFile);
    AppendPath(&abySourcePath[wSourcePathLength],abyHiddenFile);

    if (wLastError = FileCopy(abySourcePath,abyDestPath) != 0)
        {
        DosClose(hSource);
        AppendPath(&abySourcePath[wSourcePathLength],abyDeviceFile);
        DosDelete(abyDestPath,0L);
        return(HIDE_FILE_COPY);
        }

    if ((wLastError = DosOpen(abyDestPath,(PHFILE)&hDestination,(PUSHORT)&wStatus,0L,0,1,0x6192,0L)) != 0)
        {
        DosClose(hSource);
        AppendPath(&abySourcePath[wSourcePathLength],abyDeviceFile);
        DosDelete(abyDestPath,0L);
        return(HIDE_FILE_COPY);
        }

    DosChgFilePtr(hDestination,20,0,&dwFilePosition);
    if ((wLastError = DosWrite(hDestination,(&(BYTE)stCodeKey.dwCopyKey),20,&wCount)) != 0)
        {
        DosClose(hDestination);
        DosClose(hSource);
        AppendPath(&abySourcePath[wSourcePathLength],abyDeviceFile);
        DosDelete(abyDestPath,0L);
        return(HIDE_FILE_WRITE);
        }

    DosClose(hDestination);

    DosSetFileMode(abySourcePath,0x0027,0L);
    DosSetFileMode(abyDestPath,0x0027,0L);

    stCodeKey.wCopyCount--;
    DosChgFilePtr(hSource,oFileOffset + oCopyCount,0,&dwFilePosition);
    if ((wLastError = DosWrite(hSource,&(BYTE)stCodeKey.wCopyCount,2,&wCount)) != 0)
        {
        DosClose(hSource);
        DosSetFileMode(abyDestPath,0x0000,0L);
        DosDelete(abyDestPath,0L);
        return(SOURCE_WRITE_CODE_KEY);
        }
    DosClose(hSource);
    AppendPath(&abyDestPath[wDestPathLength],abyDeviceFile);
    if (FixConfigFile())
        {
        printf("% successfully installed.  You must use UNINST.EXE to move the\n",abyDeviceFile);
        printf("device driver to another machine or directory\n");
        if (stCodeKey.wCopyCount != 0)
            {
            printf("\nThere are %u %s device driver licenses still\n",stCodeKey.wCopyCount,abyDeviceFile);
            printf("available for installation.\n\n");
            }
        }
    }
示例#10
0
int __qwrite( int handle, const void *buffer, unsigned len )
{
    int             atomic;
#if defined(__NT__)
    DWORD           len_written;
    HANDLE          h;
    int             error;
#elif defined(__WARP__)
    ULONG           len_written;
#elif defined(__OS2_286__)
    USHORT          len_written;
#else
    unsigned        len_written;
#endif
#if !defined(__NT__)
    tiny_ret_t      rc;
#endif

    __handle_check( handle, -1 );

#if defined(__NT__)
    h = __getOSHandle( handle );
#endif
    atomic = 0;
    if( __GetIOMode( handle ) & _APPEND ) {
        _AccessFileH( handle );
        atomic = 1;
#if defined(__NT__)
        if( SetFilePointer( h, 0, NULL, FILE_END ) == -1 ) {
            error = GetLastError();
            _ReleaseFileH( handle );
            return( __set_errno_dos( error ) );
        }
#elif defined(__OS2__)
        {
            unsigned long       dummy;
            rc = DosChgFilePtr( handle, 0L, SEEK_END, &dummy );
        }
#else
        rc = TinySeek( handle, 0L, SEEK_END );
#endif
#if !defined(__NT__)
        if( TINY_ERROR( rc ) ) {
            _ReleaseFileH( handle );
            return( __set_errno_dos( TINY_INFO( rc ) ) );
        }
#endif
    }
#ifdef DEFAULT_WINDOWING
    if( _WindowsStdout != 0 ) {
        LPWDATA res;

        res = _WindowsIsWindowedHandle( handle );
        if( res ) {
            int rt;
            rt = _WindowsStdout( res, buffer, len );
            return( rt );
        }
    }
#endif
#if defined(__NT__)
    if( !WriteFile( h, buffer, len, &len_written, NULL ) ) {
        error = GetLastError();
        if( atomic == 1 ) {
            _ReleaseFileH( handle );
        }
        return( __set_errno_dos( error ) );
    }
#elif defined(__OS2__)
    rc = DosWrite( handle, (PVOID)buffer, len, &len_written );
#elif defined(__WINDOWS_386__)
    rc = __TinyWrite( handle, buffer, len );
    len_written = TINY_LINFO( rc );
#else
    rc = TinyWrite( handle, buffer, len );
    len_written = TINY_LINFO( rc );
#endif
#if !defined(__NT__)
    if( TINY_ERROR( rc ) ) {
        if( atomic == 1 ) {
            _ReleaseFileH( handle );
        }
        return( __set_errno_dos( TINY_INFO( rc ) ) );
    }
#endif
    if( len_written != len ) {
        __set_errno( ENOSPC );
    }
    if( atomic == 1 ) {
        _ReleaseFileH( handle );
    }
    return( len_written );
}