Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: libraries/nacl-mounts/net/IOInterfaces.h

Issue 10392070: Socket subsystem implementation (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FILE_INTERFACES_H
6 #define FILE_INTERFACES_H
7
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <stdarg.h>
11 #include <string.h>
12 #include <sys/dir.h>
13 #include <sys/ioctl.h>
14 #include <sys/types.h>
15 #include <unistd.h>
16
17 #include "../base/nacl_dirent.h"
Dmitry Polukhin 2012/05/31 14:06:45 I think all path should be from root of nacl-mount
vissi 2012/06/01 09:12:57 Maybe, however, there are lots of usages like this
Dmitry Polukhin 2012/06/01 09:52:13 It is really ugly and there is no reason for doing
18
19 class FileStream {
20 public:
21 virtual ~FileStream() {}
22
23 virtual void addref() = 0;
24 virtual void release() = 0;
25
26 virtual void close() = 0;
27 virtual int read(char* buf, size_t count, size_t* nread) = 0;
28 virtual int write(const char* buf, size_t count, size_t* nwrote) = 0;
29 virtual int seek(nacl_abi_off_t offset, int whence,
30 nacl_abi_off_t* new_offset) {
31 return ESPIPE;
32 }
33 virtual int fstat(nacl_abi_stat* out) {
34 memset(out, 0, sizeof(nacl_abi_stat));
35 return 0;
36 }
37 virtual int getdents(dirent* buf, size_t count, size_t* nread) {
38 return ENOTDIR;
39 }
40
41 virtual int isatty() {
42 errno = EINVAL;
43 return 0;
44 }
45 virtual int fcntl(int cmd, va_list ap) {
46 errno = EINVAL;
47 return -1;
48 }
49 virtual int ioctl(int request, va_list ap) {
50 errno = EINVAL;
51 return -1;
52 }
53
54 virtual bool is_read_ready() {
55 return true;
56 }
57 virtual bool is_write_ready() {
58 return true;
59 }
60 virtual bool is_exception() {
61 return false;
62 }
63 };
64
65 class PathHandler {
66 public:
67 virtual ~PathHandler() {}
68
69 virtual void addref() = 0;
70 virtual void release() = 0;
71
72 virtual FileStream* open(int fd, const char* pathname, int oflag) = 0;
73 virtual int stat(const char* pathname, nacl_abi_stat* out) = 0;
74 };
75
76 #endif // FILE_INTERFACES_H
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698