aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Serpell <daniel.serpell@gmail.com>2020-05-04 23:25:16 -0400
committerDaniel Serpell <daniel.serpell@gmail.com>2020-05-04 23:25:16 -0400
commit66dfbb37324b71bb9901cdf087264d941b025acc (patch)
tree2f0de780f388811f134d8ebb1cc1787e9ead922b
parentbd9966f130d9b25844f12542c0e7e8984615a788 (diff)
downloademu2-66dfbb37324b71bb9901cdf087264d941b025acc.tar.gz
Implements DOS function 5Bh, "create new file".
-rw-r--r--src/dos.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/dos.c b/src/dos.c
index 7a79054..ee06d63 100644
--- a/src/dos.c
+++ b/src/dos.c
@@ -11,6 +11,7 @@
#include "video.h"
#include <errno.h>
+#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
@@ -197,7 +198,17 @@ static void dos_open_file(int create)
}
}
debug(debug_dos, "\topen '%s', '%s', %04x ", fname, mode, h);
- handles[h] = fopen(fname, mode);
+ if(create == 2)
+ {
+ // Force exclusive access. We could use mode = "x+" in glibc.
+ int fd = open(fname, O_CREAT | O_EXCL | O_RDWR, 0666);
+ if(fd != -1)
+ handles[h] = fdopen(fd, mode);
+ else
+ handles[h] = 0;
+ }
+ else
+ handles[h] = fopen(fname, mode);
if(!handles[h])
{
if(errno != ENOENT)
@@ -1720,6 +1731,9 @@ void int21()
cpuSetAX(1);
}
}
+ case 0x5B: // CREATE NEW FILE
+ dos_open_file(2);
+ break;
case 0x62: // GET PSP SEGMENT
cpuSetBX(get_current_PSP());
break;
Un proyecto texto-plano.xyz