Skip to content

Commit 29a16ef

Browse files
committed
Refactor OSD_File::Append to streamline read-only mode handling
1 parent f1b9583 commit 29a16ef

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/OSD/OSD_File.cxx

+6-8
Original file line numberDiff line numberDiff line change
@@ -570,22 +570,20 @@ void OSD_File::Append(const OSD_OpenMode theMode, const OSD_Protection& theProte
570570
throw Standard_ProgramError("OSD_File::Append(): no name was given");
571571
}
572572

573-
const char* anFDOpenMode;
574-
Standard_Integer anOpenMode = O_APPEND;
573+
const char* anFDOpenMode = "r";
574+
Standard_Integer anOpenMode = O_APPEND | O_RDONLY;
575575
switch (theMode)
576576
{
577-
case OSD_ReadOnly:
578-
anOpenMode |= O_RDONLY;
579-
anFDOpenMode = "r";
580-
break;
581577
case OSD_WriteOnly:
582-
anOpenMode |= O_WRONLY;
578+
anOpenMode = O_APPEND | O_WRONLY;
583579
anFDOpenMode = "a";
584580
break;
585581
case OSD_ReadWrite:
586-
anOpenMode |= O_RDWR;
582+
anOpenMode = O_APPEND | O_RDWR;
587583
anFDOpenMode = "a+";
588584
break;
585+
case OSD_ReadOnly:
586+
break;
589587
}
590588

591589
if (!Exists())

0 commit comments

Comments
 (0)