aboutsummaryrefslogtreecommitdiff
path: root/build2/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-22 17:43:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-22 17:43:09 +0200
commit8b98a6b3fae40487ac529a7118865df6a71159ee (patch)
treedcdc0a13ccec81c087ed05a9ebfe5cac3d56b955 /build2/test
parentade763571a19b5e222ac626a6b3bc10685e542a1 (diff)
Implement detection of ignorable changes (whitespaces, comments)
Diffstat (limited to 'build2/test')
-rw-r--r--build2/test/script/builtin.cxx43
1 files changed, 5 insertions, 38 deletions
diff --git a/build2/test/script/builtin.cxx b/build2/test/script/builtin.cxx
index 2a8150d..ca47ad2 100644
--- a/build2/test/script/builtin.cxx
+++ b/build2/test/script/builtin.cxx
@@ -4,12 +4,6 @@
#include <build2/test/script/builtin.hxx>
-#ifndef _WIN32
-# include <utime.h>
-#else
-# include <sys/utime.h>
-#endif
-
#include <locale>
#include <ostream>
#include <sstream>
@@ -1505,38 +1499,11 @@ namespace build2
try
{
- if (file_exists (p))
- {
- // Set the file access and modification times to the current
- // time. Note that we don't register (implicit) cleanup for an
- // existing path.
- //
-#ifndef _WIN32
- if (utime (p.string ().c_str (), nullptr) == -1)
-#else
- if (_utime (p.string ().c_str (), nullptr) == -1)
-#endif
- throw_generic_error (errno);
- }
- else if (!entry_exists (p))
- {
- // Create the file. Assume the file access and modification
- // times are set to the current time automatically.
- //
- try
- {
- fdopen (p, fdopen_mode::out | fdopen_mode::create);
- }
- catch (const io_error& e)
- {
- error () << "cannot create file '" << p << "': " << e;
- }
-
- if (cleanup)
- sp.clean ({cleanup_type::always, p}, true);
- }
- else
- error () << "'" << p << "' exists and is not a file";
+ // Note that we don't register (implicit) cleanup for an
+ // existing path.
+ //
+ if (touch_file (p) && cleanup)
+ sp.clean ({cleanup_type::always, p}, true);
}
catch (const system_error& e)
{