mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Update to add in support for AZIO.
AZIO differs in that it uses mysys methods and removes all of the malloc calls.
This commit is contained in:
48
storage/archive/archive_test.c
Normal file
48
storage/archive/archive_test.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <azlib.h>
|
||||
|
||||
#define TEST_STRING "This is a test"
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
azio_stream foo, foo1;
|
||||
char buffer[BUFFER_LEN];
|
||||
|
||||
MY_INIT(argv[0]);
|
||||
|
||||
if (!(ret= azopen(&foo, "test", O_CREAT|O_WRONLY|O_TRUNC|O_BINARY)))
|
||||
{
|
||||
printf("Could not create test file\n");
|
||||
return 0;
|
||||
}
|
||||
azwrite(&foo, TEST_STRING, sizeof(TEST_STRING));
|
||||
azflush(&foo, Z_FINISH);
|
||||
|
||||
if (!(ret= azopen(&foo1, "test", O_RDONLY|O_BINARY)))
|
||||
{
|
||||
printf("Could not open test file\n");
|
||||
return 0;
|
||||
}
|
||||
ret= azread(&foo1, buffer, BUFFER_LEN);
|
||||
printf("Read %d bytes\n", ret);
|
||||
printf("%s\n", buffer);
|
||||
azrewind(&foo1);
|
||||
azclose(&foo);
|
||||
if (!(ret= azopen(&foo, "test", O_APPEND|O_WRONLY|O_BINARY)))
|
||||
{
|
||||
printf("Could not create test file\n");
|
||||
return 0;
|
||||
}
|
||||
azwrite(&foo, TEST_STRING, sizeof(TEST_STRING));
|
||||
azflush(&foo, Z_FINISH);
|
||||
ret= azread(&foo1, buffer, BUFFER_LEN);
|
||||
printf("Read %d bytes\n", ret);
|
||||
printf("%s\n", buffer);
|
||||
azclose(&foo);
|
||||
azclose(&foo1);
|
||||
|
||||
//unlink("test");
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user