1
0
mirror of https://github.com/simh/simh.git synced 2026-01-11 23:52:58 +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

View File

@ -53,6 +53,8 @@ typedef int32 t_offset;
FILE *sim_fopen (const char *file, const char *mode);
int sim_fseek (FILE *st, t_addr offset, int whence);
int sim_fseeko (FILE *st, t_offset offset, int whence);
int sim_set_fsize (FILE *fptr, t_addr size);
int sim_set_fsizeo (FILE *fptr, t_offset size);
size_t sim_fread (void *bptr, size_t size, size_t count, FILE *fptr);
size_t sim_fwrite (void *bptr, size_t size, size_t count, FILE *fptr);
uint32 sim_fsize (FILE *fptr);