Browse Source

v68io: fix open mode 2, add v68_io_tell();

vampirefrog 1 year ago
parent
commit
35c76bb2a7
2 changed files with 8 additions and 3 deletions
  1. 7
    3
      v68io.c
  2. 1
    0
      v68io.h

+ 7
- 3
v68io.c View File

@@ -104,8 +104,6 @@ int v68_io_open(char *filename, int mode) {
104 104
 	char resolved[PATH_MAX];
105 105
 	v68_io_resolve_path(xlated, resolved, sizeof(resolved));
106 106
 
107
-	// printf("file %s resolved to %s -> %s\n", filename, xlated, resolved);
108
-
109 107
 	switch(mode & 0x03) {
110 108
 		case 0x00:
111 109
 			mode = O_RDONLY;
@@ -114,7 +112,7 @@ int v68_io_open(char *filename, int mode) {
114 112
 			mode = O_WRONLY | O_TRUNC;
115 113
 			break;
116 114
 		case 0x02:
117
-			mode = O_TRUNC | O_RDWR;
115
+			mode = O_RDWR;
118 116
 			break;
119 117
 	}
120 118
 	int fd = open(resolved, mode, 0644);
@@ -210,6 +208,12 @@ int v68_io_seek(int fd, off_t offset, int whence) {
210 208
 	return lseek(dosfiles[fd].fd, offset, whence);
211 209
 }
212 210
 
211
+int v68_io_tell(int fd) {
212
+	CHECKFD(fd);
213
+
214
+	return lseek(dosfiles[fd].fd, 0, SEEK_CUR);
215
+}
216
+
213 217
 int v68_io_rename(char *oldpath, char *newpath) {
214 218
 	return rename(oldpath, newpath);
215 219
 }

+ 1
- 0
v68io.h View File

@@ -11,6 +11,7 @@ int v68_io_close(int fd);
11 11
 int v68_io_read(int fd, void *buf, size_t count);
12 12
 int v68_io_write(int fd, void *buf, size_t count);
13 13
 int v68_io_seek(int fd, off_t offset, int whence);
14
+int v68_io_tell(int fd);
14 15
 int v68_io_rename(char *oldpath, char *newpath);
15 16
 int v68_io_chmod(char *pathname, mode_t mode);
16 17
 

Loading…
Cancel
Save