sdmc_open: implement O_EXCL and O_TRUNC
This commit is contained in:
parent
93dbdfd74a
commit
60edc69d73
@ -244,7 +244,18 @@ sdmc_open(struct _reent *r,
|
|||||||
if(flags & O_CREAT)
|
if(flags & O_CREAT)
|
||||||
sdmc_flags |= FS_OPEN_CREATE;
|
sdmc_flags |= FS_OPEN_CREATE;
|
||||||
|
|
||||||
/* TODO: Test O_EXCL. */
|
/* Test O_EXCL. */
|
||||||
|
if((flags & O_CREAT) && (flags & O_EXCL))
|
||||||
|
{
|
||||||
|
rc = FSUSER_CreateFile(NULL, sdmcArchive, FS_makePath(PATH_CHAR, pathptr), 0);
|
||||||
|
if(rc != 0)
|
||||||
|
{
|
||||||
|
r->_errno = rc;
|
||||||
|
if(rc == 0x82044BE)
|
||||||
|
r->_errno = EEXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set attributes */
|
/* set attributes */
|
||||||
/*if(!(mode & S_IWUSR))
|
/*if(!(mode & S_IWUSR))
|
||||||
@ -255,6 +266,16 @@ sdmc_open(struct _reent *r,
|
|||||||
sdmc_flags, attributes);
|
sdmc_flags, attributes);
|
||||||
if(rc == 0)
|
if(rc == 0)
|
||||||
{
|
{
|
||||||
|
if((flags & O_ACCMODE) != O_RDONLY && (flags & O_TRUNC))
|
||||||
|
{
|
||||||
|
rc = FSFILE_SetSize(fd, 0);
|
||||||
|
if(rc != 0)
|
||||||
|
{
|
||||||
|
FSFILE_Close(fd);
|
||||||
|
r->_errno = rc;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
file->fd = fd;
|
file->fd = fd;
|
||||||
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
||||||
file->offset = 0;
|
file->offset = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user