Skip to content

Commit

Permalink
Get information about file using fstat
Browse files Browse the repository at this point in the history
Needed for fchmod.
  • Loading branch information
martintc committed Oct 11, 2021
1 parent c759f8a commit 99a8536
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ut_assert/src/uttools.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ bool UtMem2BinFile(const void *Memory, const char *Filename, uint32 Length)

if (fp = fopen(Filename, "w")) {
int fd = fileno(fp);
fstat(fd, &dststat);
if ((fchmod(fd, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)) == 0))
{
fwrite(Memory, Length, 1, fp);
Expand Down Expand Up @@ -114,6 +115,7 @@ bool UtMem2HexFile(const void *Memory, const char *Filename, uint32 Length)
if ((fp = fopen(Filename, "w")))
{
int fd = fileno(fp);
fstat(fd, &dststat);
if ((fchmod(fd, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)) == 0))
{

Expand Down

0 comments on commit 99a8536

Please sign in to comment.