3 #ifndef __cust_stream_H
4 #define __cust_stream_H
13 if(NULL != szStreamDir)
18 szStreamDir =
new char[strlen(dir) + 1];
19 if(NULL == szStreamDir)
21 strcpy(szStreamDir, dir);
23 if(0 != mkdir(szStreamDir, 0777))
49 if(NULL == szStreamDir)
54 char *szStreamFile =
new char[strlen(szStreamDir) + 20 + 5];
55 sprintf(szStreamFile,
"%s/%d.css", szStreamDir, ii);
57 fildes = open(szStreamFile, O_CREAT|O_RDWR, 0666);
60 delete[] szStreamFile;
61 Throw(ERROR__OPEN_FILE);
65 int mem_size = items_number(nDim, pDim) *
sizeof(T);
67 stream_put_header(fildes);
69 if(mem_size != write(fildes, pStorage, mem_size))
73 delete[] szStreamFile;
78 delete[] szStreamFile;
88 if(NULL == szStreamDir)
93 char *szStreamFile =
new char[strlen(szStreamDir) + 20 + 5];
94 sprintf(szStreamFile,
"%s/%d.css", szStreamDir, ii);
96 fildes = open(szStreamFile, O_RDONLY);
99 delete[] szStreamFile;
100 Throw(ERROR__OPEN_FILE);
104 int mem_size = items_number(nDim, pDim) *
sizeof(T);
106 stream_get_header(fildes);
108 if(mem_size != read(fildes, pStorage, mem_size))
112 delete[] szStreamFile;
117 delete[] szStreamFile;
130 memcpy(hdr.signature, CSS_SIGNATURE, strlen(CSS_SIGNATURE));
131 hdr.magic = 0x12345678;
132 memset(hdr.item_order, 0, 4);
136 hdr.item_order[0] =
'c';
139 hdr.item_order[0] =
'f';
143 hdr.item_size =
sizeof(T);
145 if(
sizeof(hdr) != write(fildes, &hdr,
sizeof(hdr)))
158 Int4 magic = 0x12345678;
160 if(
sizeof(hdr) != read(fildes, &hdr,
sizeof(hdr)))
163 if(memcmp(hdr.signature, CSS_SIGNATURE, strlen(CSS_SIGNATURE)))
165 Throw(ERROR__BAD_PARAMS);
167 if(hdr.magic != 0x12345678)
169 Throw(ERROR__BAD_PARAMS);
174 if(hdr.item_order[0] !=
'c')
176 Throw(ERROR__BAD_PARAMS);
179 if(hdr.item_order[0] !=
'f')
181 Throw(ERROR__BAD_PARAMS);
185 if(hdr.dim_num != nDim)
187 Throw(ERROR__BAD_PARAMS);
189 if(hdr.item_size !=
sizeof(T))
191 Throw(ERROR__BAD_PARAMS);
Definition: CubeStorage.H:48
virtual void stream_put(int ii)
Definition: cust_stream.H:47
const char * stream_dir() const
Definition: cust_stream.H:36
virtual void stream_get(int ii)
Definition: cust_stream.H:86