/* CONFIG: */
/* It should be the divisor of all offsets/sizes written by W32 filesystems.
- * Otherwise access of non-GIOCHANNEL_BLIND_BLOCK_SIZE aligned smaller block
- * would wastefully exceed to the following block to fill GIOChannel buffer.
*/
#define GIOCHANNEL_BLIND_BLOCK_SIZE 512
(guint64)window_now,(gulong)(transfer_bottom-giochannel_blind->offset),(guint64)transfer_bottom,
(gulong)(transfer_top-transfer_bottom));
if (!giochannel_blind->giochannel_orig) {
- /* FIXME: GIOChannel alignment problems. */
- g_message("%s: Missing block at offset 0x%llX",G_STRLOC,(unsigned long long)window_now);
- /* Do not just skip over g_io_channel_read_chars() with bytes_read==0
- * as it would EOF our read while we may need to read some further block
- * which may be available.
- */
- bytes_read=transfer_top-transfer_bottom;
- memset(buf+transfer_bottom-giochannel_blind->offset,0,bytes_read);
- goto read_done;
+ g_error("%s: Missing block at offset 0x%llX",G_STRLOC,(unsigned long long)window_now);
+ g_return_val_if_reached(G_IO_STATUS_ERROR);
}
errgiostatus=g_io_channel_seek_position(
giochannel_blind->giochannel_orig, /* channel */
}
blind_block->was_read=TRUE;
}
-read_done:
maxread=transfer_bottom+bytes_read;
if (bytes_read==transfer_top-transfer_bottom)
g_return_val_if_fail(transfer_bottom+bytes_read<=giochannel_blind->size,G_IO_STATUS_ERROR);
g_return_if_fail(giochannel!=NULL);
- erriostatus=g_io_channel_set_encoding(giochannel,
- NULL, /* encoding; force binary data */
+ if (g_io_channel_get_encoding(giochannel)) {
+ if (!g_io_channel_get_buffered(giochannel)) /* Prevent: Need to have NULL encoding to set the buffering state ... */
+ g_io_channel_set_buffered(giochannel,TRUE); /* Prevent: Need to set the channel buffered before setting the encoding. */
+ erriostatus=g_io_channel_set_encoding(giochannel,
+ NULL, /* encoding; force binary data */
+ NULL); /* error */
+ g_assert(erriostatus==G_IO_STATUS_NORMAL);
+ }
+ erriostatus=g_io_channel_flush(giochannel,
NULL); /* error */
g_assert(erriostatus==G_IO_STATUS_NORMAL);
- g_io_channel_set_buffer_size(giochannel,GIOCHANNEL_BLIND_BLOCK_SIZE);
+ g_io_channel_set_buffered(giochannel,FALSE);
}