Add io_create_file, io_open_file
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include "io.h"
|
||||
|
||||
#define NUM_OPS 3
|
||||
|
||||
int main()
|
||||
{
|
||||
struct io_operation ops[100];
|
||||
@@ -8,13 +10,26 @@ int main()
|
||||
if (!io_context_init(&ioc, ops, sizeof(ops)/sizeof(ops[0])))
|
||||
return -1;
|
||||
|
||||
io_handle files[NUM_OPS];
|
||||
|
||||
for (int i = 0; i < NUM_OPS; i++) {
|
||||
char name[1<<8];
|
||||
snprintf(name, sizeof(name), "file_%d.txt", i);
|
||||
files[i] = io_create_file(&ioc, name, IO_CREATE_CANTEXIST, NULL);
|
||||
if (files[i] == IO_INVALID_HANDLE)
|
||||
fprintf(stderr, "Couldn't create '%s'\n", name);
|
||||
}
|
||||
|
||||
int started = 0;
|
||||
char msg[] = "Hello, world!\n";
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (!io_start_send(&ioc, io_get_stdout(), msg, sizeof(msg), NULL))
|
||||
for (int i = 0; i < NUM_OPS; i++) {
|
||||
if (io_start_send(&ioc, files[i], msg, sizeof(msg)-1))
|
||||
started++;
|
||||
else
|
||||
fprintf(stderr, "ERROR\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int i = 0; i < started; i++) {
|
||||
struct io_event ev;
|
||||
io_wait(&ioc, &ev);
|
||||
fprintf(stderr, "CONCLUDED\n");
|
||||
|
||||
Reference in New Issue
Block a user