1
0
mirror of https://github.com/simh/simh.git synced 2026-01-28 04:48:05 +00:00

SCP: Added sim_set_fsize and sim_set_fsizeo to sim_fio to support specific expanding or truncation of files.

This commit is contained in:
Mark Pizzolato
2014-09-16 09:20:02 -07:00
parent b8dc8f01b5
commit bc3582c194
2 changed files with 21 additions and 0 deletions

View File

@@ -362,3 +362,22 @@ int sim_fseek (FILE *st, t_addr offset, int whence)
{
return sim_fseeko (st, (t_offset)offset, whence);
}
int sim_set_fsize (FILE *fptr, t_addr size)
{
return sim_set_fsizeo (fptr, (t_offset)size);
}
#if defined(_WIN32)
#include <io.h>
int sim_set_fsizeo (FILE *fptr, t_offset size)
{
return _chsize_s(_fileno(fptr), (__int64)size);
}
#else /* !defined(_WIN32) */
#include <unistd.h>
int sim_set_fsizeo (FILE *fptr, t_offset size)
{
return ftruncate(fileno(fptr), (off_t)size);
}
#endif