Category : OS/2 Files
Archive   : EMXLIB8F.ZIP
Filename : CHSIZE.C
#include
#include
#include
#include
int chsize (int handle, long length)
{
long n;
int i, j;
char zeros[4096];
if (handle < 0 || handle >= _nfiles || (_files[handle] & F_DEV))
{
errno = EBADF;
return (-1);
}
n = (long)__lseek (handle, 0L, SEEK_END);
if (n == -1L)
return (-1);
if (__chsize (handle, length) != 0)
return (-1);
if (n < length)
{
bzero (zeros, sizeof (zeros));
if (__lseek (handle, n, SEEK_SET) == -1)
return (-1);
while (n < length)
{
i = length - n;
if (i > sizeof (zeros))
i = sizeof (zeros);
j = __write (handle, zeros, i);
if (j == -1)
return (-1);
if (j == 0)
{
errno = ENOSPC;
return (-1);
}
n += j;
}
}
return (0);
}
/* sys/chsize.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
#include
#include
#include "syscalls.h"
int __chsize (int handle, long length)
{
ULONG rc;
rc = DosSetFileSize (handle, length);
if (rc != 0)
{
_sys_set_errno (rc);
return (-1);
}
return (0);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/