]> git.tdb.fi Git - builder.git/blobdiff - source/copy.cpp
Add Id tag to all files
[builder.git] / source / copy.cpp
index 8d18ec8001279403bc827926da8203e507671f28..70f05398fbac5ae5dc885d7c91c8c33eb95da4ae 100644 (file)
@@ -1,3 +1,10 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
 #include <errno.h>
 #include <fstream>
 #include <iostream>
@@ -25,8 +32,11 @@ Copy::Copy(Builder &b, const Package &pkg, const Path::Path &s, const Path::Path
 
 int Copy::check()
 {
-       if(!worker)
+       if(!worker)  // True for dry run
+       {
+               signal_done.emit();
                return 0;
+       }
        
        if(worker->get_done())
        {
@@ -47,6 +57,7 @@ void Copy::Worker::main()
 {
        Path::mkpath(copy.dest.subpath(0, copy.dest.size()-1), 0755);
        
+       // Remove old file.  Not doing this would cause Bad Stuff when installing libraries.
        if(unlink(copy.dest.str().c_str())<0 && errno!=ENOENT)
        {
                int err=errno;
@@ -71,6 +82,7 @@ void Copy::Worker::main()
                return;
        }
 
+       // Actual transfer loop
        char buf[16384];
        while(!in.eof())
        {
@@ -78,6 +90,7 @@ void Copy::Worker::main()
                out.write(buf, in.gcount());
        }
 
+       // Preserve file permissions
        struct stat st;
        Path::stat(copy.src, st);
        chmod(copy.dest.str().c_str(), st.st_mode&0777);