mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-23 04:01:59 +00:00
Fix FileOps::touch()
creat() returns -1 on error or an fd otherwise which should be closed.
This commit is contained in:
parent
8df91a76eb
commit
96793d262b
1 changed files with 6 additions and 1 deletions
|
@ -194,7 +194,12 @@ void FileOps::touch(const char* path) throw (IOException)
|
|||
{
|
||||
#ifdef PLATFORM_UNIX
|
||||
// see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html
|
||||
if (creat(path,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) != 0)
|
||||
int fd = creat(path,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd != -1)
|
||||
{
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw IOException("Unable to touch file " + std::string(path));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue