mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-22 02:30:56 +00:00
add intfstream_truncate for file streams
Will return 0 for non-file streams. I didn't want to mess around with memory_stream (which could in theory have a truncate impl that sets size) because there were globals and stuff and I got nervous (also truncate might *grow* a file if the new length is longer than the old one and then I'd have to think about realloc, etc).
This commit is contained in:
parent
ab9ee963cb
commit
42f066a842
@ -88,6 +88,9 @@ int intfstream_getc(intfstream_internal_t *intf);
|
||||
int64_t intfstream_seek(intfstream_internal_t *intf,
|
||||
int64_t offset, int whence);
|
||||
|
||||
int64_t intfstream_truncate(intfstream_internal_t *intf,
|
||||
uint64_t len);
|
||||
|
||||
void intfstream_rewind(intfstream_internal_t *intf);
|
||||
|
||||
int64_t intfstream_tell(intfstream_internal_t *intf);
|
||||
|
@ -309,6 +309,34 @@ int64_t intfstream_seek(
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t intfstream_truncate(intfstream_internal_t *intf, uint64_t len)
|
||||
{
|
||||
if (!intf)
|
||||
return 0;
|
||||
|
||||
switch (intf->type)
|
||||
{
|
||||
case INTFSTREAM_FILE:
|
||||
return filestream_truncate(intf->file.fp, len);
|
||||
case INTFSTREAM_MEMORY:
|
||||
break;
|
||||
case INTFSTREAM_CHD:
|
||||
#ifdef HAVE_CHD
|
||||
break;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case INTFSTREAM_RZIP:
|
||||
#if defined(HAVE_ZLIB)
|
||||
break;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t intfstream_read(intfstream_internal_t *intf, void *s, uint64_t len)
|
||||
{
|
||||
if (!intf)
|
||||
|
Loading…
x
Reference in New Issue
Block a user