summaryrefslogtreecommitdiff
path: root/CCache/util.c
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-07 02:26:34 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-07 02:26:34 +0000
commit7c81201d28a0c4a52f0fb1523e172fedf63f953b (patch)
treea1cf6e4adb7068b2b8fdd1b3db6e56a621dbd6e5 /CCache/util.c
parente65ea565300a9c1f6f73fe1c16a9e084d7cce560 (diff)
downloadswig-7c81201d28a0c4a52f0fb1523e172fedf63f953b.tar.gz
Fix lack of error logging in some situations and fix failure to work on windows when swig is a pure Win32 (non-cygwin) compile
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11034 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'CCache/util.c')
-rw-r--r--CCache/util.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/CCache/util.c b/CCache/util.c
index f09256dfc..bba232492 100644
--- a/CCache/util.c
+++ b/CCache/util.c
@@ -349,20 +349,26 @@ int test_if_compressed(const char *filename) {
int commit_to_cache(const char *src, const char *dest, int hardlink)
{
int ret = -1;
- unlink(dest);
- if (hardlink) {
+ struct stat st;
+ if (stat(src, &st) == 0) {
+ unlink(dest);
+ if (hardlink) {
#ifdef _WIN32
- ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1;
+ ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1;
#else
- ret = link(src, dest);
+ ret = link(src, dest);
#endif
- }
- if (ret == -1) {
- ret = copy_file_to_cache(src, dest);
+ }
if (ret == -1) {
- cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno));
- stats_update(STATS_ERROR);
+ ret = copy_file_to_cache(src, dest);
+ if (ret == -1) {
+ cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno));
+ stats_update(STATS_ERROR);
+ }
}
+ } else {
+ cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno));
+ stats_update(STATS_ERROR);
}
return ret;
}