示例#1
0
文件: syncfile.c 项目: zostay/MoarVM
/* Get curernt position in the file. */
static MVMint64 mvm_tell(MVMThreadContext *tc, MVMOSHandle *h) {
    MVMIOFileData *data = (MVMIOFileData *)h->body.data;
    MVMint64 r;

    if (data->ds)
        return MVM_string_decodestream_tell_bytes(tc, data->ds);

    if ((r = MVM_platform_lseek(data->fd, 0, SEEK_CUR)) == -1)
        MVM_exception_throw_adhoc(tc, "Failed to tell in filehandle: %d", errno);

    return r;
}
示例#2
0
文件: syncfile.c 项目: hoelzro/MoarVM
/* Get curernt position in the file. */
static MVMint64 mvm_tell(MVMThreadContext *tc, MVMOSHandle *h) {
    MVMIOFileData *data = (MVMIOFileData *)h->body.data;
    return data->ds ? MVM_string_decodestream_tell_bytes(tc, data->ds) : 0;
}
示例#3
0
/* If we've been reading, the total number of bytes read. Otherwise, the total
 * number of bytes we've written. */
MVMint64 MVM_io_syncstream_tell(MVMThreadContext *tc, MVMOSHandle *h) {
    MVMIOSyncStreamData *data = (MVMIOSyncStreamData *)h->body.data;
    return data->ds
        ? MVM_string_decodestream_tell_bytes(tc, data->ds)
        : data->total_bytes_written;
}