63#define MAX_STREAMS_OPEN 200
67#define DEBUG_DELETE if (0)
68#define DEBUG_STREAM_LEN if (0)
69#define DEBUG_ASSERT if (0)
73#define STREAM_TMPDIR "STREAM_DIR"
76#define BASE_NAME "STREAM"
78#define STREAM_BUFFER_SIZE (1 << 18)
188 const char *
name()
const;
238 cerr <<
"ERROR: setvbuf failed (stream " <<
path
283 cerr <<
"ERROR: setvbuf failed (stream " <<
path
387 perror(
"ERROR: AMI_STREAM::stream_len(): ftell(fp) failed ");
395 perror(
"ERROR: AMI_STREAM::stream_len(): ftell[SEEK_END] failed ");
410 perror(
"AMI_STREAM::stream_len(): fstat failed ");
419 return (
statbuf.st_size /
sizeof(T));
453 cerr <<
"ERROR: AMI_STREAM::seek bos=" <<
logical_bos
454 <<
", eos=" <<
logical_eos <<
", offset " << offset
455 <<
" out of range.\n";
511 cerr <<
"ERROR: AMI_STREAM: failed to unlink " <<
path << endl;
512 perror(
"cannot unlink: ");
541 cerr <<
"ERROR: file=" <<
path <<
":";
575 cerr <<
"ERROR: file=" <<
path <<
":";
597 if (
fwrite((
char *)(&elt),
sizeof(T), 1,
fp) < 1) {
598 cerr <<
"ERROR: AMI_STREAM::write_item failed.\n";
602 perror(
"AMI_STREAM::write_item: ");
625 cerr <<
"ERROR: AMI_STREAM::write_array failed.\n";
629 perror(
"AMI_STREAM::write_array: ");
654 static char desc[
BUFSIZ + 256];
655 snprintf(desc,
sizeof(desc),
"[AMI_STREAM %s %ld]",
path,
#define STREAM_BUFFER_SIZE
FILE * open_stream(int fd, AMI_stream_type st)
@ AMI_APPEND_WRITE_STREAM
const char * ami_str_error[]
int ami_single_temp_name(const std::string &base, char *tmp_path)
@ AMI_ERROR_END_OF_STREAM
@ AMI_ERROR_PERMISSION_DENIED
@ AMI_ERROR_NO_MAIN_MEMORY_OPERATION
@ AMI_ERROR_INSUFFICIENT_AVAILABLE_STREAMS
@ AMI_ERROR_OBJECT_INITIALIZATION
@ AMI_ERROR_INSUFFICIENT_MAIN_MEMORY
@ AMI_ERROR_ENV_UNDEFINED
static AMI_err main_memory_usage(size_t *usage, MM_stream_usage usage_type=MM_STREAM_USAGE_OVERHEAD)
AMI_err write_item(const T &elt)
AMI_err write_array(const T *data, off_t len)
AMI_err read_array(T *data, off_t len, off_t *lenp=NULL)
AMI_err new_substream(AMI_stream_type st, off_t sub_begin, off_t sub_end, AMI_STREAM< T > **sub_stream)
AMI_err seek(off_t offset)
AMI_err read_item(T **elt)
void persist(persistence p)
const char * name() const
AMI_stream_type access_mode
static unsigned int get_block_length()
unsigned int substream_level
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
off_t G_ftell(FILE *)
Get the current file position of the stream.
Header file for msvc/fcntl.c.
#define assert(condition)
@ MM_STREAM_USAGE_OVERHEAD
@ MM_STREAM_USAGE_MAXIMUM
@ MM_STREAM_USAGE_CURRENT