Skip to content
Snippets Groups Projects
Commit 574e2cb6 authored by de Séréville Nicolas's avatar de Séréville Nicolas
Browse files

+ Fix bug when moving files to NPLib/Detectors/newDetDirectory

parent 26a54835
No related branches found
No related tags found
No related merge requests found
#include<iostream> // C++ headers
#include<sstream> #include <iostream>
#include <sstream>
#include<stdlib.h> #include <stdlib.h>
#include<ctime> #include <ctime>
#include"NPVDetector.h"
int main(int argc , char** argv){ // NPTool header
// Find the different path #include "NPVDetector.h"
std::string path = getenv("NPTOOL");
std::string pathNPL = path+ "/NPLib/Detectors/";
std::string pathNPS = path+"/NPSimulation/"; int main(int argc , char** argv)
std::string pwd = getenv("PWD"); {
// Find the different paths
std::string path = getenv("NPTOOL");
std::string pathNPL = path + "/NPLib/Detectors/";
std::string pathNPS = path + "/NPSimulation/";
std::string pwd = getenv("PWD");
int return_value = -1 ; int return_value = -1 ;
std::string command; std::string command;
...@@ -47,9 +52,9 @@ int main(int argc , char** argv){ ...@@ -47,9 +52,9 @@ int main(int argc , char** argv){
case 12: case 12:
month = "December"; month = "December";
} }
std::string year = NPL::itoa(now->tm_year+1900); std::string year = NPL::itoa(now->tm_year+1900);
//////////
// start nptool-wizard
bool check = true; bool check = true;
std::cout << "\r\033[1;32m" << std::endl << std::endl; std::cout << "\r\033[1;32m" << std::endl << std::endl;
std::cout << "********************************************************************************"<< std::endl; std::cout << "********************************************************************************"<< std::endl;
...@@ -57,16 +62,15 @@ int main(int argc , char** argv){ ...@@ -57,16 +62,15 @@ int main(int argc , char** argv){
std::cout << "********************************************************************************"<< std::endl; std::cout << "********************************************************************************"<< std::endl;
std::cout << " This utility will create a new detector skeleton"<< std::endl; std::cout << " This utility will create a new detector skeleton"<< std::endl;
std::cout << "\033[1;36m-> What is the detector name ? \033[0m" ; std::cout << "\033[1;36m-> What is the detector name ? \033[0m";
std::cin >> answer ; std::cin >> answer;
std::cout << "\033[1;36m-> What is your name (firstname and surname)? \033[0m" ; std::cout << "\033[1;36m-> What is your name (firstname and surname)? \033[0m";
std::cin >> author; std::cin >> author;
getline(cin, buffer); getline(cin, buffer);
istringstream oss(buffer); istringstream oss(buffer);
while(oss>> buffer) while (oss>> buffer) author += " " + buffer;
author +=" " + buffer ; std::cout << "\033[1;36m-> What is your email? \033[0m";
std::cout << "\033[1;36m-> What is your email? \033[0m" ; std::cin >> email;
std::cin >> email ;
std::cout << std::endl << std::endl; std::cout << std::endl << std::endl;
...@@ -74,23 +78,23 @@ int main(int argc , char** argv){ ...@@ -74,23 +78,23 @@ int main(int argc , char** argv){
// TODO // // TODO //
////////// //////////
// Creating the detector file name // Creating the detector files name
std::string DataFile_h = "T"+answer+"Data.h"; std::string DataFile_h = "T"+answer+"Data.h";
std::string DataFile_cxx = "T"+answer+"Data.cxx"; std::string DataFile_cxx = "T"+answer+"Data.cxx";
std::string PhysicsFile_h = "T"+answer+"Physics.h"; std::string PhysicsFile_h = "T"+answer+"Physics.h";
std::string PhysicsFile_cxx = "T"+answer+"Physics.cxx"; std::string PhysicsFile_cxx = "T"+answer+"Physics.cxx";
std::string SpectraFile_h = "T"+answer+"Spectra.h"; std::string SpectraFile_h = "T"+answer+"Spectra.h";
std::string SpectraFile_cxx = "T"+answer+"Spectra.cxx"; std::string SpectraFile_cxx = "T"+answer+"Spectra.cxx";
std::string SimFile_h = answer+".hh"; std::string SimFile_h = answer+".hh";
std::string SimFile_cxx = answer+".cc"; std::string SimFile_cxx = answer+".cc";
std::string InputFile = answer+".detector"; std::string InputFile = answer+".detector";
// Create npl folder // Create npl folder for new detector
command = "mkdir " + pathNPL + answer + " > /dev/null 2> /dev/null"; command = "mkdir " + pathNPL + answer + " > /dev/null 2> /dev/null";
return_value = system(command.c_str()); return_value = system(command.c_str());
// Add npl file // Copy template files to new detector directory
command = "cp " + pathNPL + " ressources/DetectorSkeleton/NPLib/* " command = "cp " + pathNPL + "../ressources/DetectorSkeleton/NPLib/* "
+ pathNPL + answer +"/ > /dev/null 2> /dev/null"; + pathNPL + answer +"/ > /dev/null 2> /dev/null";
return_value = system(command.c_str()); return_value = system(command.c_str());
...@@ -115,7 +119,7 @@ int main(int argc , char** argv){ ...@@ -115,7 +119,7 @@ int main(int argc , char** argv){
+ pathNPL + answer +"/* > /dev/null 2> /dev/null"; + pathNPL + answer +"/* > /dev/null 2> /dev/null";
return_value = system(command.c_str()); return_value = system(command.c_str());
// change files name
command = "mv " + pathNPL + answer +"/TDETECTORNAMEData.h " command = "mv " + pathNPL + answer +"/TDETECTORNAMEData.h "
+ pathNPL + answer + "/" + DataFile_h ; + pathNPL + answer + "/" + DataFile_h ;
return_value = system(command.c_str()); return_value = system(command.c_str());
...@@ -137,7 +141,10 @@ int main(int argc , char** argv){ ...@@ -137,7 +141,10 @@ int main(int argc , char** argv){
+ pathNPL + answer + "/" + SpectraFile_cxx ; + pathNPL + answer + "/" + SpectraFile_cxx ;
return_value = system(command.c_str()); return_value = system(command.c_str());
// Create nps folder // Create nps folder
command = "mkdir " + pathNPS + "/Detectors/" + answer + " > /dev/null 2> /dev/null";
return_value = system(command.c_str());
// Add nps file // Add nps file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment