@@ -104,15 +104,20 @@ bool ExamplesManager::installDirectory(const std::string& FromPath, const std::s
104104
105105 if (!InstallTargetPathObj.isDirectory () || Force)
106106 {
107- InstallTargetPathObj.makeDirectory ();
107+ if (!InstallTargetPathObj.makeDirectory ())
108+ {
109+ openfluid::base::log::debug (" Example installation" , " Unable to create " + InstallTargetPathObj.toGeneric ());
110+ return false ;
111+ }
108112
109113 return openfluid::tools::Filesystem::copyDirectory (openfluid::tools::Filesystem::joinPath ({FromPath,DirName}),
110114 ToPath,true ,true );
111115 }
112116
113117 openfluid::base::log::debug (" Example installation" , " Unable to create " + InstallTargetPathObj.toGeneric () +
114118 " dir because it already exists and force option is set to false" );
115- return false ;
119+
120+ return !std::filesystem::is_empty (InstallTargetPathObj.stdPath ());
116121}
117122
118123
@@ -122,7 +127,7 @@ bool ExamplesManager::installDirectory(const std::string& FromPath, const std::s
122127
123128bool ExamplesManager::installProject (const std::string& ProjectDir,
124129 const std::string& ResourcesPath, const std::string& InstallPath,
125- const bool Force)
130+ const bool Force, const bool Verbose )
126131{
127132 std::string FromPath = openfluid::tools::Filesystem::joinPath ({buildRessourcesPath (ResourcesPath),
128133 openfluid::config::PROJECTS_PATH});
@@ -136,9 +141,15 @@ bool ExamplesManager::installProject(const std::string& ProjectDir,
136141 }
137142 std::string ToPath = openfluid::tools::Filesystem::joinPath ({buildInstallPath (InstallPath),
138143 openfluid::config::PROJECTS_PATH});
139- std::cout << " -- Installing project " << ProjectDir << " from " << FromPath << " to " << ToPath << " " ;
144+ if (Verbose)
145+ {
146+ std::cout << " -- Installing project " << ProjectDir << " from " << FromPath << " to " << ToPath << " " ;
147+ }
140148 bool Status = installDirectory (FromPath, ToPath, ProjectDir, Force);
141- printSuccessStatus (Status);
149+ if (Verbose)
150+ {
151+ printSuccessStatus (Status);
152+ }
142153 return Status;
143154}
144155
@@ -149,7 +160,7 @@ bool ExamplesManager::installProject(const std::string& ProjectDir,
149160
150161bool ExamplesManager::installSimulator (const std::string& SimulatorDir,
151162 const std::string& ResourcesPath, const std::string& InstallPath,
152- const bool Force)
163+ const bool Force, const bool Verbose )
153164{
154165 std::string FromPath = openfluid::tools::Filesystem::joinPath ({buildRessourcesPath (ResourcesPath),
155166 openfluid::config::WARESDEV_PATH,
@@ -165,9 +176,15 @@ bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
165176 std::string ToPath = openfluid::tools::Filesystem::joinPath ({buildInstallPath (InstallPath),
166177 openfluid::config::WARESDEV_PATH,
167178 openfluid::config::SIMULATORS_PATH});
168- std::cout << " -- Installing simulator " << SimulatorDir << " from " << FromPath << " to " << ToPath << " " ;
179+ if (Verbose)
180+ {
181+ std::cout << " -- Installing simulator " << SimulatorDir << " from " << FromPath << " to " << ToPath << " " ;
182+ }
169183 bool Status = installDirectory (FromPath,ToPath,SimulatorDir,Force);
170- printSuccessStatus (Status);
184+ if (Verbose)
185+ {
186+ printSuccessStatus (Status);
187+ }
171188 return Status;
172189}
173190
@@ -178,7 +195,7 @@ bool ExamplesManager::installSimulator(const std::string& SimulatorDir,
178195
179196bool ExamplesManager::installObserver (const std::string& ObserverDir,
180197 const std::string& ResourcesPath, const std::string& InstallPath,
181- const bool Force)
198+ const bool Force, const bool Verbose )
182199{
183200 std::string FromPath = openfluid::tools::Filesystem::joinPath ({buildRessourcesPath (ResourcesPath),
184201 openfluid::config::WARESDEV_PATH,
@@ -194,9 +211,16 @@ bool ExamplesManager::installObserver(const std::string& ObserverDir,
194211 std::string ToPath = openfluid::tools::Filesystem::joinPath ({buildInstallPath (InstallPath),
195212 openfluid::config::WARESDEV_PATH,
196213 openfluid::config::OBSERVERS_PATH});
197- std::cout << " -- Installing observer " << ObserverDir << " from " << FromPath << " to " << ToPath << " " ;
214+
215+ if (Verbose)
216+ {
217+ std::cout << " -- Installing observer " << ObserverDir << " from " << FromPath << " to " << ToPath << " " ;
218+ }
198219 bool Status = installDirectory (FromPath,ToPath,ObserverDir,Force);
199- printSuccessStatus (Status);
220+ if (Verbose)
221+ {
222+ printSuccessStatus (Status);
223+ }
200224 return Status;
201225}
202226
@@ -206,7 +230,7 @@ bool ExamplesManager::installObserver(const std::string& ObserverDir,
206230
207231
208232bool ExamplesManager::installAllProjects (const std::string& ResourcesPath, const std::string& InstallPath,
209- const bool Force)
233+ const bool Force, const bool Verbose )
210234{
211235 auto ResPath = buildRessourcesPath (ResourcesPath);
212236 auto InstPath = buildInstallPath (InstallPath);
@@ -220,7 +244,7 @@ bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const
220244 bool AllIsOK = true ;
221245 for (const auto & Prj : FoundProjects)
222246 {
223- AllIsOK &= installProject (Prj,ResPath,InstPath,Force);
247+ AllIsOK &= installProject (Prj, ResPath, InstPath, Force, Verbose );
224248 }
225249 return AllIsOK;
226250 }
@@ -238,7 +262,7 @@ bool ExamplesManager::installAllProjects(const std::string& ResourcesPath, const
238262
239263
240264bool ExamplesManager::installAllSimulators (const std::string& ResourcesPath, const std::string& InstallPath,
241- const bool Force)
265+ const bool Force, const bool Verbose )
242266{
243267 auto ResPath = buildRessourcesPath (ResourcesPath);
244268 auto InstPath = buildInstallPath (InstallPath);
@@ -254,7 +278,7 @@ bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, con
254278 bool AllIsOK = true ;
255279 for (const auto & Sim : FoundSimulators)
256280 {
257- AllIsOK &= installSimulator (Sim,ResPath,InstPath,Force);
281+ AllIsOK &= installSimulator (Sim, ResPath, InstPath, Force, Verbose );
258282 }
259283 return AllIsOK;
260284 }
@@ -272,7 +296,7 @@ bool ExamplesManager::installAllSimulators(const std::string& ResourcesPath, con
272296
273297
274298bool ExamplesManager::installAllObservers (const std::string& ResourcesPath, const std::string& InstallPath,
275- const bool Force)
299+ const bool Force, const bool Verbose )
276300{
277301 auto ResPath = buildRessourcesPath (ResourcesPath);
278302 auto InstPath = buildInstallPath (InstallPath);
@@ -288,7 +312,7 @@ bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, cons
288312 bool AllIsOK = true ;
289313 for (const auto & Obs : FoundObservers)
290314 {
291- AllIsOK &= installObserver (Obs,ResPath,InstPath,Force);
315+ AllIsOK &= installObserver (Obs, ResPath, InstPath, Force, Verbose );
292316 }
293317 return AllIsOK;
294318 }
@@ -306,11 +330,11 @@ bool ExamplesManager::installAllObservers(const std::string& ResourcesPath, cons
306330
307331
308332bool ExamplesManager::installAllWares (const std::string& ResourcesPath, const std::string& InstallPath,
309- const bool Force)
333+ const bool Force, const bool Verbose )
310334{
311335 bool AllIsOK = true ;
312- AllIsOK &= installAllSimulators (ResourcesPath,InstallPath,Force);
313- AllIsOK &= installAllObservers (ResourcesPath,InstallPath,Force);
336+ AllIsOK &= installAllSimulators (ResourcesPath,InstallPath,Force,Verbose );
337+ AllIsOK &= installAllObservers (ResourcesPath,InstallPath,Force,Verbose );
314338
315339 return AllIsOK;
316340}
@@ -320,11 +344,12 @@ bool ExamplesManager::installAllWares(const std::string& ResourcesPath, const st
320344// =====================================================================
321345
322346
323- bool ExamplesManager::installAll (const std::string& ResourcesPath, const std::string& InstallPath, const bool Force)
347+ bool ExamplesManager::installAll (const std::string& ResourcesPath, const std::string& InstallPath, const bool Force,
348+ const bool Verbose)
324349{
325350 bool AllIsOK = true ;
326- AllIsOK &= installAllProjects (ResourcesPath,InstallPath,Force);
327- AllIsOK &= installAllWares (ResourcesPath,InstallPath,Force);
351+ AllIsOK &= installAllProjects (ResourcesPath,InstallPath,Force,Verbose );
352+ AllIsOK &= installAllWares (ResourcesPath,InstallPath,Force,Verbose );
328353
329354 return AllIsOK;
330355}
0 commit comments