Michael 'Mickey' Lauer wrote: > I found the need for open(2) and friends. Please add to posix.vapi: > > [CCode (cheader_filename = "fcntl.h")] > public const int O_ACCMODE; > [CCode (cheader_filename = "fcntl.h")] > public const int O_RDONLY; > ... > [CCode (cheader_filename = "unistd.h")] > public int open(string pathname, int flags); > > [CCode (cheader_filename = "unistd.h")] > public ssize_t read(int fd, void* buf, size_t count); > > [CCode (cheader_filename = "unistd.h")] > public ssize_t write(int fd, void* buf, size_t count); > > [CCode (cheader_filename = "unistd.h")] > public int close(int fd);
Hi, I'd suggest binding it this way: --------------------------------------------------------------------- [Flags] [CCode (cheader_filename = "fcntl.h", cprefix = "O_", cname = "int")] public enum OpenFlags { ACCMODE, RDONLY, WRONLY, RDWR, CREAT, EXCL, NOCTTY, TRUNC, APPEND, NONBLOCK, NDELAY, SYNC, FSYNC, ASYNC } [SimpleType] [CCode (cheader_filename = "unistd.h", cname = "int", free_function = "close", cprefix = "")] struct FileDescriptor { [CCode (cname = "open")] public FileDescriptor (string pathname, OpenFlags flags); public ssize_t read (void* buf, size_t count); public ssize_t write (void* buf, size_t count); } --------------------------------------------------------------------- Then the code will look more object oriented: using Posix; static int main () { var file = FileDescriptor ("data.text", OpenFlags.RDONLY); file.read (/*...*/); file.write (/*...*/); // file closed automatically return 0; } Regards, Frederik _______________________________________________ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list