Allow "mode" argument to open() to be passed from 6502 code.

Implements this suggestion:
https://github.com/cc65/cc65/pull/719#issuecomment-413809096
This commit is contained in:
Patrick Pelletier
2018-08-17 10:43:14 -07:00
committed by Oliver Schmidt
parent d602572bbe
commit aba320eade
4 changed files with 81 additions and 5 deletions

View File

@@ -169,7 +169,7 @@ static void PVOpen (CPURegs* Regs)
{
char Path[1024];
int OFlag = O_INITIAL;
unsigned RetVal, I = 0;
unsigned RetVal, I = 0, OMode = 0;
unsigned Mode = PopParam (Regs->YR - 4);
unsigned Flags = PopParam (2);
@@ -206,10 +206,14 @@ static void PVOpen (CPURegs* Regs)
OFlag |= O_EXCL;
}
/* Avoid gcc warning */
(void) Mode;
if (Mode & 0400) {
OMode |= S_IREAD;
}
if (Mode & 0200) {
OMode |= S_IWRITE;
}
RetVal = open (Path, OFlag, (mode_t) 0666);
RetVal = open (Path, OFlag, OMode);
SetAX (Regs, RetVal);
}