]> git.tdb.fi Git - builder.git/blobdiff - source/copy.cpp
Adapt to changes in msppath
[builder.git] / source / copy.cpp
index eea40fcdae6eda6f63dc30f09988736fa88a7fbc..bdcd0a94a8006ec108c31ecfbea5e3ce7d4d97bc 100644 (file)
@@ -16,7 +16,7 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-Copy::Copy(Builder &b, const Package &pkg, const Path::Path &s, const Path::Path &d):
+Copy::Copy(Builder &b, const Package &pkg, const Path &s, const Path &d):
        InternalAction(b),
        src(s),
        dest(d)
@@ -38,15 +38,21 @@ Copy::Worker::Worker(Copy &c):
 
 void Copy::Worker::main()
 {
-       Path::mkpath(copy.dest.subpath(0, copy.dest.size()-1), 0755);
+       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)
+       try
        {
-               int err=errno;
-               cerr<<"Can't unlink "<<copy.dest<<": "<<strerror(err)<<'\n';
-               done=error=true;
-               return;
+               // Remove old file.  Not doing this would cause Bad Stuff when installing libraries.
+               unlink(copy.dest);
+       }
+       catch(const SystemError &e)
+       {
+               if(e.get_error_code()!=ENOENT)
+               {
+                       cerr<<e.what()<<'\n';
+                       done=error=true;
+                       return;
+               }
        }
 
        ifstream in(copy.src.str().c_str());
@@ -74,8 +80,7 @@ void Copy::Worker::main()
        }
 
        // Preserve file permissions
-       struct stat st;
-       Path::stat(copy.src, st);
+       struct stat st=stat(copy.src);
        chmod(copy.dest.str().c_str(), st.st_mode&0777);
 
        done=true;