]> git.tdb.fi Git - builder.git/blobdiff - source/externalaction.cpp
Reorder class members
[builder.git] / source / externalaction.cpp
index 14657a04ab2c05cfa71d059be4b6c1bbad75a7ca..88c7e544e7907671daa82a6d8381f29f46257356 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-200 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -9,42 +9,13 @@ Distributed under the LGPL
 #include <iostream>
 #include <cstring>
 #include <cstdlib>
-#include <msp/path/utils.h>
+#include <msp/fs/dir.h>
 #include "builder.h"
 #include "externalaction.h"
 
 using namespace std;
 using namespace Msp;
 
-int ExternalAction::check()
-{
-       if(builder.get_dry_run())
-       {
-               signal_done.emit();
-               return 0;
-       }
-
-       if(!pid)
-               return exit_code;
-
-       int status;
-       if(waitpid(pid, &status, WNOHANG)==pid)
-       {
-               signal_done.emit();
-               if(WIFEXITED(status))
-                       exit_code=WEXITSTATUS(status);
-               else
-                       exit_code=254;
-               pid=0;
-               return exit_code;
-       }
-       else
-               return -1;
-}
-
-/**
-Starts the external program.  Fill in argv before calling this.
-*/
 void ExternalAction::launch()
 {
        if(builder.get_verbose()>=2)
@@ -73,7 +44,7 @@ void ExternalAction::launch()
                        argv_[j]=0;
 
                        if(!work_dir.empty())
-                               chdir(work_dir);
+                               FS::chdir(work_dir);
                        execvp(argv_[0], argv_);
                        cout<<"Couldn't execute "<<argv.front()<<'\n';
                        exit(1);
@@ -82,3 +53,29 @@ void ExternalAction::launch()
                        pid=0;
        }
 }
+
+int ExternalAction::check()
+{
+       if(builder.get_dry_run())
+       {
+               signal_done.emit();
+               return 0;
+       }
+
+       if(!pid)
+               return exit_code;
+
+       int status;
+       if(waitpid(pid, &status, WNOHANG)==pid)
+       {
+               signal_done.emit();
+               if(WIFEXITED(status))
+                       exit_code=WEXITSTATUS(status);
+               else
+                       exit_code=254;
+               pid=0;
+               return exit_code;
+       }
+       else
+               return -1;
+}