Fix for problems signaled by clang static analyzer

Former-commit-id: 835f639c45509b0d55fe716e51e3285ea2a89da4
This commit is contained in:
Gawaboumga
2016-05-31 21:50:31 +02:00
parent 6a583b8231
commit db8a222f62
5 changed files with 43 additions and 26 deletions

View File

@@ -143,7 +143,18 @@ namespace Nz
return false;
}
mode_t permissions; // TODO : get permission from first file
mode_t permissions;
struct stat sb;
if (fstat(fd1, &sb) == -1) // get permission from first file
{
NazaraWarning("Could not get permissions of source file");
permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
}
else
{
permissions = sb.st_mode & ~S_IFMT; // S_IFMT: bit mask for the file type bit field -> ~S_IFMT: general permissions
}
int fd2 = open64(targetPath.GetConstBuffer(), O_WRONLY | O_TRUNC, permissions);
if (fd2 == -1)
{