mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-02-02 04:11:23 +00:00
Update the access/modification times of the existing file, if there is one, in FileUtils::touch()
This changes FileUtils::touch() to match the documentation for the 'touch' tool on Unix.
This commit is contained in:
parent
d7e3cc8d63
commit
c20c452e98
1 changed files with 12 additions and 4 deletions
|
@ -258,14 +258,22 @@ void FileUtils::touch(const char* path) throw (IOException)
|
|||
{
|
||||
#ifdef PLATFORM_UNIX
|
||||
// see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html
|
||||
int fd = creat(path,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd != -1)
|
||||
if (fileExists(path))
|
||||
{
|
||||
close(fd);
|
||||
utimensat(AT_FDCWD,path,0 /* use current date/time */,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw IOException("Unable to touch file " + std::string(path));
|
||||
int fd = creat(path,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd != -1)
|
||||
{
|
||||
futimens(fd,0 /* use current date/time */);
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw IOException("Unable to touch file " + std::string(path));
|
||||
}
|
||||
}
|
||||
#else
|
||||
HANDLE result = CreateFile(path,GENERIC_WRITE,
|
||||
|
|
Loading…
Reference in a new issue