Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSystem.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id: 8944840ba34631ec28efc779647618db43c0eee5 $
2// Author: Fons Rademakers 15/09/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TSystem
13\ingroup Base
14
15Abstract base class defining a generic interface to the underlying
16Operating System.
17This is not an ABC in the strict sense of the (C++) word. For
18every member function there is an implementation (often not more
19than a call to AbstractMethod() which prints a warning saying
20that the method should be overridden in a derived class), which
21allows a simple partial implementation for new OS'es.
22*/
23
26#include "strlcpy.h"
27#include "TSystem.h"
28#include "TApplication.h"
29#include "TException.h"
30#include "TROOT.h"
31#include "TClass.h"
32#include "TClassTable.h"
33#include "TEnv.h"
34#include "TOrdCollection.h"
35#include "TObject.h"
36#include "TInterpreter.h"
37#include "TRegexp.h"
38#include "TObjString.h"
39#include "TObjArray.h"
40#include "TError.h"
41#include "TPluginManager.h"
42#include "TUrl.h"
43#include "TVirtualMutex.h"
44#include "TVersionCheck.h"
45#include "compiledata.h"
46#include "RConfigure.h"
47#include "THashList.h"
48#include "ThreadLocalStorage.h"
49
50#include <functional>
51#include <iostream>
52#include <fstream>
53#include <memory>
54#include <sstream>
55#include <string>
56#include <sys/stat.h>
57#include <set>
58
59#ifdef WIN32
60#include <io.h>
61#include "Windows4Root.h"
62#endif
63
64const char *gRootDir = nullptr;
65const char *gProgName = nullptr;
66const char *gProgPath = nullptr;
67
68TSystem *gSystem = nullptr;
69TFileHandler *gXDisplay = nullptr; // Display server event handler, set in TGClient
70
71static Int_t *gLibraryVersion = nullptr; // Set in TVersionCheck, used in Load()
72static Int_t gLibraryVersionIdx = 0; // Set in TVersionCheck, used in Load()
74
75// Pin vtable
78
79////////////////////////////////////////////////////////////////////////////////
80/// Create async event processor timer. Delay is in milliseconds.
81
87
88////////////////////////////////////////////////////////////////////////////////
89/// Process events if timer did time out. Returns kTRUE if interrupt
90/// flag is set (by hitting a key in the canvas or selecting the
91/// Interrupt menu item in canvas or some other action).
92
94{
95 if (fTimeout) {
96 if (gSystem->ProcessEvents()) {
97 Remove();
98 return kTRUE;
99 } else {
100 Reset();
101 return kFALSE;
102 }
103 }
104 return kFALSE;
105}
106
107
108
110
112
113
114
115////////////////////////////////////////////////////////////////////////////////
116/// Strip off protocol string from specified path
117
118const char *TSystem::StripOffProto(const char *path, const char *proto)
119{
120 return !strncmp(path, proto, strlen(proto)) ? path + strlen(proto) : path;
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Create a new OS interface.
125
126TSystem::TSystem(const char *name, const char *title) : TNamed(name, title)
127{
128 if (gSystem && name[0] != '-' && strcmp(name, "Generic"))
129 Error("TSystem", "only one instance of TSystem allowed");
130
131 if (!gLibraryVersion) {
134 }
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Delete the OS interface.
139
141{
142 if (fOnExitList) {
145 }
146
147 if (fSignalHandler) {
150 }
151
152 if (fFileHandler) {
155 }
156
160 }
161
162 if (fTimers) {
163 fTimers->Delete();
165 }
166
167 if (fCompiled) {
168 fCompiled->Delete();
170 }
171
172 if (fHelpers) {
173 fHelpers->Delete();
175 }
176
177 if (gSystem == this)
178 gSystem = nullptr;
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Initialize the OS interface.
183
185{
186 fNfd = 0;
187 fMaxrfd = -1;
188 fMaxwfd = -1;
189
190 fSigcnt = 0;
191 fLevel = 0;
192
196 fTimers = new TList;
198
208 fSoExt = SOEXT;
209 fObjExt = OBJEXT;
214
215 if (gEnv && fBeepDuration == 0 && fBeepFreq == 0) {
216 fBeepDuration = gEnv->GetValue("Root.System.BeepDuration", 100);
217 fBeepFreq = gEnv->GetValue("Root.System.BeepFreq", 440);
218 }
219 if (!fName.CompareTo("Generic")) return kTRUE;
220 return kFALSE;
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Set the application name (from command line, argv[0]) and copy it in
225/// gProgName.
226
227void TSystem::SetProgname(const char *name)
228{
229 delete [] gProgName;
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Set DISPLAY environment variable based on utmp entry. Only for UNIX.
235
237{
238}
239
240////////////////////////////////////////////////////////////////////////////////
241/// Set the system error string. This string will be used by GetError().
242/// To be used in case one does not want or can use the system error
243/// string (e.g. because error is generated by a third party POSIX like
244/// library that does not use standard errno).
245
247{
248 ResetErrno(); // so GetError() uses the fLastErrorString
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Return system error string.
254
255const char *TSystem::GetError()
256{
257 if (GetErrno() == 0 && !GetLastErrorString().IsNull())
258 return GetLastErrorString().Data();
259 return Form("errno: %d", GetErrno());
260}
261
262////////////////////////////////////////////////////////////////////////////////
263/// Return cryptographic random number
264/// Fill provided buffer with random values. The number of requested random bytes must not exceed 256.
265/// Returns number of bytes written to buffer or -1 in case of error
266
268{
269 if (len < 0) {
270 return -1;
271 }
272 const auto rv = ROOT::Internal::GetCryptoRandom(buf, len);
273 return rv ? len : -1;
274}
275
276
277////////////////////////////////////////////////////////////////////////////////
278/// Static function returning system error number.
279
281{
282 return errno;
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Static function resetting system error number.
287
289{
290 errno = 0;
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Objects that should be deleted on exit of the OS interface.
295
297{
298 if (!fOnExitList)
300 if (!fOnExitList->FindObject(obj))
301 fOnExitList->Add(obj);
302}
303
304////////////////////////////////////////////////////////////////////////////////
305/// Return the system's host name.
306
307const char *TSystem::HostName()
308{
309 return "Local host";
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Hook to tell TSystem that the TApplication object has been created.
314
316{
317 // Currently needed only for WinNT interface.
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Beep for duration milliseconds with a tone of frequency freq.
322/// Defaults to printing the `\a` character to stdout.
323/// If freq or duration is <0 respectively, use default value.
324/// If setDefault is set, only set the frequency and duration as
325/// new defaults, but don't beep.
326/// If default freq or duration is <0, never beep (silence)
327
328void TSystem::Beep(Int_t freq /*=-1*/, Int_t duration /*=-1*/,
329 Bool_t setDefault /*=kFALSE*/)
330{
331 if (setDefault) {
332 fBeepFreq = freq;
334 return;
335 }
336 if (fBeepDuration < 0 || fBeepFreq < 0) return; // silence
337 if (freq < 0) freq = fBeepFreq;
340}
341
342//---- EventLoop ---------------------------------------------------------------
343
344////////////////////////////////////////////////////////////////////////////////
345/// System event loop.
346
348{
350 fDone = kFALSE;
351
353 try {
354 RETRY {
355 while (!fDone) {
357 InnerLoop();
359 }
360 } ENDTRY;
361 }
362 catch (std::exception& exc) {
364 TStdExceptionHandler* eh = nullptr;
365 while ((eh = (TStdExceptionHandler*) next())) {
366 switch (eh->Handle(exc))
367 {
369 break;
371 goto loop_entry;
372 break;
374 Warning("Run", "instructed to abort");
375 goto loop_end;
376 break;
377 }
378 }
379 throw;
380 }
381 catch (const char *str) {
382 printf("%s\n", str);
383 }
384 // handle every exception
385 catch (...) {
386 Warning("Run", "handle uncaught exception, terminating");
387 }
388
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Exit from event loop.
395
397{
398 fDone = kTRUE;
399}
400
401////////////////////////////////////////////////////////////////////////////////
402/// Inner event loop.
403
405{
406 fLevel++;
408 fLevel--;
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// Process pending events (GUI, timers, sockets). Returns the result of
413/// TROOT::IsInterrupted(). The interrupt flag (TROOT::SetInterrupt())
414/// can be set during the handling of the events. This mechanism allows
415/// macros running in tight calculating loops to be interrupted by some
416/// GUI event (depending on the interval with which this method is
417/// called). For example hitting ctrl-c in a canvas will set the
418/// interrupt flag.
419
421{
422 gROOT->SetInterrupt(kFALSE);
423
424 if (!gROOT->TestBit(TObject::kInvalidObject))
426
427 return gROOT->IsInterrupted();
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// Dispatch a single event.
432
434{
435 AbstractMethod("DispatchOneEvent");
436}
437
438////////////////////////////////////////////////////////////////////////////////
439/// Sleep milliSec milli seconds.
440
442{
443 AbstractMethod("Sleep");
444}
445
446////////////////////////////////////////////////////////////////////////////////
447/// Select on active file descriptors (called by TMonitor).
448
450{
451 AbstractMethod("Select");
452 return -1;
453}
454////////////////////////////////////////////////////////////////////////////////
455/// Select on active file descriptors (called by TMonitor).
456
458{
459 AbstractMethod("Select");
460 return -1;
461}
462
463//---- handling of system events -----------------------------------------------
464////////////////////////////////////////////////////////////////////////////////
465/// Get current time in milliseconds since 0:00 Jan 1 1995.
466
468{
469 return TTime(0);
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Add timer to list of system timers.
474
476{
477 if (ti && fTimers && (fTimers->FindObject(ti) == nullptr))
478 fTimers->Add(ti);
479}
480
481////////////////////////////////////////////////////////////////////////////////
482/// Remove timer from list of system timers. Returns removed timer or 0
483/// if timer was not active.
484
486{
487 if (fTimers) {
489 return tr;
490 }
491 return nullptr;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Time when next timer of mode (synchronous=kTRUE or
496/// asynchronous=kFALSE) will time-out (in ms).
497
499{
500 if (!fTimers) return -1;
501
502 TListIter it(fTimers);
503 TTimer *t, *to = nullptr;
504 Long64_t tt, tnow = Now();
505 Long_t timeout = -1;
506
507 while ((t = (TTimer *) it.Next())) {
508 if (t->IsSync() == mode) {
509 tt = (Long64_t)t->GetAbsTime() - tnow;
510 if (tt < 0) tt = 0;
511 if (timeout == -1) {
512 timeout = (Long_t)tt;
513 to = t;
514 }
515 if (tt < timeout) {
516 timeout = (Long_t)tt;
517 to = t;
518 }
519 }
520 }
521
522 if (to && to->IsAsync() && timeout > 0) {
523 if (to->IsInterruptingSyscalls())
525 else
527 }
528
529 return timeout;
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Add a signal handler to list of system signal handlers. Only adds
534/// the handler if it is not already in the list of signal handlers.
535
541
542////////////////////////////////////////////////////////////////////////////////
543/// Remove a signal handler from list of signal handlers. Returns
544/// the handler or 0 if the handler was not in the list of signal handlers.
545
553
554////////////////////////////////////////////////////////////////////////////////
555/// Add a file handler to the list of system file handlers. Only adds
556/// the handler if it is not already in the list of file handlers.
557
563
564////////////////////////////////////////////////////////////////////////////////
565/// Remove a file handler from the list of file handlers. Returns
566/// the handler or 0 if the handler was not in the list of file handlers.
567
569{
570 if (fFileHandler)
571 return (TFileHandler *)fFileHandler->Remove(h);
572
573 return nullptr;
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// If reset is true reset the signal handler for the specified signal
578/// to the default handler, else restore previous behaviour.
579
580void TSystem::ResetSignal(ESignals /*sig*/, Bool_t /*reset*/)
581{
582 AbstractMethod("ResetSignal");
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Reset signals handlers to previous behaviour.
587
589{
590 AbstractMethod("ResetSignals");
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// If ignore is true ignore the specified signal, else restore previous
595/// behaviour.
596
597void TSystem::IgnoreSignal(ESignals /*sig*/, Bool_t /*ignore*/)
598{
599 AbstractMethod("IgnoreSignal");
600}
601
602////////////////////////////////////////////////////////////////////////////////
603/// If ignore is true ignore the interrupt signal, else restore previous
604/// behaviour. Typically call ignore interrupt before writing to disk.
605
610
611////////////////////////////////////////////////////////////////////////////////
612/// Add an exception handler to list of system exception handlers. Only adds
613/// the handler if it is not already in the list of exception handlers.
614
620
621////////////////////////////////////////////////////////////////////////////////
622/// Remove an exception handler from list of exception handlers. Returns
623/// the handler or 0 if the handler was not in the list of exception handlers.
624
632
633////////////////////////////////////////////////////////////////////////////////
634/// Return the bitmap of conditions that trigger a floating point exception.
635
637{
638 AbstractMethod("GetFPEMask");
639 return 0;
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Set which conditions trigger a floating point exception.
644/// Return the previous set of conditions.
645
647{
648 AbstractMethod("SetFPEMask");
649 return 0;
650}
651
652//---- Processes ---------------------------------------------------------------
653
654////////////////////////////////////////////////////////////////////////////////
655/// Execute a command.
656
657int TSystem::Exec(const char *)
658{
659 AbstractMethod("Exec");
660 return -1;
661}
662
663////////////////////////////////////////////////////////////////////////////////
664/// Open a pipe.
665
666FILE *TSystem::OpenPipe(const char *, const char *)
667{
668 AbstractMethod("OpenPipe");
669 return nullptr;
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// Close the pipe.
674
676{
677 AbstractMethod("ClosePipe");
678 return -1;
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Execute command and return output in TString.
683/// @param command the command to be executed
684/// @param ret pointer to the memory where to store the returned value of the
685/// command, i.e. the result of ClosePipe (p-close stream, the status of its child).
686/// If ret is nullptr, the returned value is not stored anywhere.
687/// @param redirectStderr if true, stderr will be redirected to stdout
688/// @return the stdout of the command as TString (from the p-opened FILE stream)
689
691{
692 TString out;
694 if (redirectStderr)
695 scommand += " 2>&1";
696 FILE *pipe = OpenPipe(scommand.Data(), "r");
697 if (!pipe) {
698 SysError("GetFromPipe", "cannot run command \"%s\"", scommand.Data());
699 return out;
700 }
701
703 while (line.Gets(pipe)) {
704 if (out != "")
705 out += "\n";
706 out += line;
707 }
708
710 if (r) {
711 Error("GetFromPipe", "command \"%s\" returned %d", scommand.Data(), r);
712 }
713 if (ret) {
714 *ret = r;
715 }
716 return out;
717}
718
719////////////////////////////////////////////////////////////////////////////////
720/// Get process id.
721
723{
724 AbstractMethod("GetPid");
725 return -1;
726}
727
728////////////////////////////////////////////////////////////////////////////////
729/// Exit the application.
730
732{
733 AbstractMethod("Exit");
734 throw; // unreachable
735}
736
737////////////////////////////////////////////////////////////////////////////////
738/// Abort the application.
739
741{
742 AbstractMethod("Abort");
743 throw; // unreachable
744}
745
746////////////////////////////////////////////////////////////////////////////////
747/// Print a stack trace.
748
750{
751 AbstractMethod("StackTrace");
752}
753
754
755//---- Directories -------------------------------------------------------------
756
757////////////////////////////////////////////////////////////////////////////////
758/// Create helper TSystem to handle file and directory operations that
759/// might be special for remote file access.
760
761TSystem *TSystem::FindHelper(const char *path, void *dirptr)
762{
763 TSystem *helper = nullptr;
764 {
766
767 if (!fHelpers) {
770 }
771
772 if (path) {
773 if (!GetDirPtr()) {
774 TUrl url(path, kTRUE);
775 if (!strcmp(url.GetProtocol(), "file"))
776 return nullptr;
777 }
778 }
779
780 // look for existing helpers
781 TIter next(fHelpers);
782 while ((helper = (TSystem*) next()))
783 if (helper->ConsistentWith(path, dirptr))
784 return helper;
785
786 if (!path)
787 return nullptr;
788 }
789
790 // create new helper
791 TRegexp re("^root.*:"); // also roots, rootk, etc
792 TString pname = path;
794 if (pname.BeginsWith("xroot:") || pname.Index(re) != kNPOS) {
795 // (x)rootd daemon ...
796 if ((h = gROOT->GetPluginManager()->FindHandler("TSystem", path))) {
797 if (h->LoadPlugin() == -1)
798 return nullptr;
799 helper = (TSystem*) h->ExecPlugin(2, path, kFALSE);
800 }
801 } else if ((h = gROOT->GetPluginManager()->FindHandler("TSystem", path))) {
802 if (h->LoadPlugin() == -1)
803 return nullptr;
804 helper = (TSystem*) h->ExecPlugin(0);
805 }
806
807 if (helper) {
810 }
811
812 return helper;
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Check consistency of this helper with the one required
817/// by 'path' or 'dirptr'
818
819Bool_t TSystem::ConsistentWith(const char *path, void *dirptr)
820{
822 if (path) {
823 if (!GetDirPtr()) {
824 TUrl url(path, kTRUE);
825 if (!strncmp(url.GetProtocol(), GetName(), strlen(GetName())))
827 }
828 }
829
831 if (GetDirPtr() && GetDirPtr() == dirptr)
832 checkdir = kTRUE;
833
834 return (checkproto || checkdir);
835}
836
837////////////////////////////////////////////////////////////////////////////////
838/// Make a directory. Returns 0 in case of success and
839/// -1 if the directory could not be created (either already exists or
840/// illegal path name).
841
842int TSystem::MakeDirectory(const char *)
843{
844 AbstractMethod("MakeDirectory");
845 return 0;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Open a directory. Returns 0 if directory does not exist.
850/// \note Remember to call `TSystem::FreeDirectory(returned_pointer)` later, to prevent a memory leak
851
852void *TSystem::OpenDirectory(const char *)
853{
854 AbstractMethod("OpenDirectory");
855 return nullptr;
856}
857
858////////////////////////////////////////////////////////////////////////////////
859/// Free a directory.
860
862{
863 AbstractMethod("FreeDirectory");
864}
865
866////////////////////////////////////////////////////////////////////////////////
867/// Get a directory entry. Returns 0 if no more entries.
868
869const char *TSystem::GetDirEntry(void *)
870{
871 AbstractMethod("GetDirEntry");
872 return nullptr;
873}
874
875////////////////////////////////////////////////////////////////////////////////
876/// Change directory.
877
879{
880 AbstractMethod("ChangeDirectory");
881 return kFALSE;
882}
883
884////////////////////////////////////////////////////////////////////////////////
885/// Return working directory.
886
888{
889 return nullptr;
890}
891
892//////////////////////////////////////////////////////////////////////////////
893/// Return working directory.
894
896{
897 return std::string();
898}
899
900////////////////////////////////////////////////////////////////////////////////
901/// Return the user's home directory.
902
903const char *TSystem::HomeDirectory(const char *)
904{
905 return nullptr;
906}
907
908//////////////////////////////////////////////////////////////////////////////
909/// Return the user's home directory.
910
911std::string TSystem::GetHomeDirectory(const char *) const
912{
913 return std::string();
914}
915
916////////////////////////////////////////////////////////////////////////////////
917/// Make a file system directory. Returns 0 in case of success and
918/// -1 if the directory could not be created (either already exists or
919/// illegal path name).
920/// If 'recursive' is true, makes parent directories as needed.
921
923{
924 if (recursive) {
925 TString safeName = name; // local copy in case 'name' is output from
926 // TSystem::DirName as it uses static buffers
928 if (dirname.IsNull()) {
929 // well we should not have to make the root of the file system!
930 // (and this avoid infinite recursions!)
931 return -1;
932 }
933 if (AccessPathName(dirname.Data(), kFileExists)) {
934 int res = mkdir(dirname.Data(), kTRUE);
935 if (res) return res;
936 }
937 if (!AccessPathName(safeName.Data(), kFileExists)) {
938 return -1;
939 }
940 }
941
942 return MakeDirectory(name);
943}
944
945//---- Paths & Files -----------------------------------------------------------
946
947////////////////////////////////////////////////////////////////////////////////
948/// Base name of a file name. Base name of /user/root is root.
949
950const char *TSystem::BaseName(const char *name)
951{
952 if (name) {
953 if (name[0] == '/' && name[1] == '\0')
954 return name;
955 char *cp;
956 if ((cp = (char *)strrchr(name, '/')))
957 return ++cp;
958 return name;
959 }
960 Error("BaseName", "name = 0");
961 return nullptr;
962}
963
964////////////////////////////////////////////////////////////////////////////////
965/// Return true if dir is an absolute pathname.
966
968{
969 if (dir)
970 return dir[0] == '/';
971 return kFALSE;
972}
973
974////////////////////////////////////////////////////////////////////////////////
975/// Return true if 'name' is a file that can be found in the ROOT include
976/// path or the current directory.
977/// If 'name' contains any ACLiC style information (e.g. trailing +[+][g|O]),
978/// it will be striped off 'name'.
979/// If fullpath is != 0, the full path to the file is returned in *fullpath,
980/// which must be deleted by the caller.
981
983{
984 if (!name || !name[0]) return kFALSE;
985
987 TString arguments;
988 TString io;
990
992
993 TString incPath = gSystem->GetIncludePath(); // of the form -Idir1 -Idir2 -Idir3
994 incPath.Append(":").Prepend(" ");
995 incPath.ReplaceAll(" -I",":"); // of form :dir1 :dir2:dir3
996 while ( incPath.Index(" :") != -1 ) {
997 incPath.ReplaceAll(" :",":");
998 }
999 // Remove double quotes around path expressions.
1000 incPath.ReplaceAll("\":", ":");
1001 incPath.ReplaceAll(":\"", ":");
1002
1003 incPath.Prepend(fileLocation+":.:");
1004
1005 char *actual = Which(incPath,realname);
1006
1007 if (!actual) {
1008 return kFALSE;
1009 } else {
1010 if (fullpath)
1011 *fullpath = actual;
1012 else
1013 delete [] actual;
1014 return kTRUE;
1015 }
1016}
1017
1018////////////////////////////////////////////////////////////////////////////////
1019/// Return the directory name in pathname. DirName of /user/root is /user.
1020/// In case no dirname is specified "." is returned.
1021
1022const char *TSystem::DirName(const char *pathname)
1023{
1024 auto res = GetDirName(pathname);
1025 if (res.IsNull() || (res == "."))
1026 return ".";
1027
1029
1030 TTHREAD_TLS(Ssiz_t) len = 0;
1031 TTHREAD_TLS(char*) buf = nullptr;
1032 if (res.Length() >= len) {
1033 if (buf) delete [] buf;
1034 len = res.Length() + 50;
1035 buf = new char [len];
1036 }
1037 if (buf)
1038 strncpy(buf, res.Data(), len);
1039 return buf;
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Return the directory name in pathname.
1044/// DirName of /user/root is /user.
1045/// DirName of /user/root/ is also /user.
1046/// In case no dirname is specified "." is returned.
1047
1049{
1050 if (!pathname || !strchr(pathname, '/'))
1051 return ".";
1052
1053 auto pathlen = strlen(pathname);
1054
1055 const char *r = pathname + pathlen - 1;
1056 // First skip the trailing '/'
1057 while ((r > pathname) && (*r == '/'))
1058 --r;
1059 // Then find the next non slash
1060 while ((r > pathname) && (*r != '/'))
1061 --r;
1062
1063 // Then skip duplicate slashes
1064 // Note the 'r>buf' is a strict comparison to allows '/topdir' to return '/'
1065 while ((r > pathname) && (*r == '/'))
1066 --r;
1067 // If all was cut away, we encountered a rel. path like 'subdir/'
1068 // and ended up at '.'.
1069 if ((r == pathname) && (*r != '/'))
1070 return ".";
1071
1072 return TString(pathname, r + 1 - pathname);
1073}
1074
1075////////////////////////////////////////////////////////////////////////////////
1076/// Convert from a local pathname to a Unix pathname. E.g. from `\user\root` to
1077/// `/user/root`.
1078
1079const char *TSystem::UnixPathName(const char *name)
1080{
1081 return name;
1082}
1083
1084////////////////////////////////////////////////////////////////////////////////
1085/// Concatenate a directory and a file name. User must delete returned string.
1086
1087char *TSystem::ConcatFileName(const char *dir, const char *name)
1088{
1091 return StrDup(nameString.Data());
1092}
1093
1094////////////////////////////////////////////////////////////////////////////////
1095/// Concatenate a directory and a file name.
1096
1097const char *TSystem::PrependPathName(const char *, TString&)
1098{
1099 AbstractMethod("PrependPathName");
1100 return nullptr;
1101}
1102
1103
1104//---- Paths & Files -----------------------------------------------------------
1105
1106////////////////////////////////////////////////////////////////////////////////
1107/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1108/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1109/// environment variables in a pathname. If compatibility is not an issue
1110/// you can use on Unix directly $XXX. This is a protected function called
1111/// from the OS specific system classes, like TUnixSystem and TWinNTSystem.
1112/// Returns the expanded filename or 0 in case of error.
1113
1114const char *TSystem::ExpandFileName(const char *fname)
1115{
1116 const int kBufSize = kMAXPATHLEN;
1118
1120 if (res)
1121 return nullptr;
1122 else
1123 return xname;
1124}
1125
1126//////////////////////////////////////////////////////////////////////////////
1127/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1128/// This function is analogous to ExpandFileName(const char *), except that
1129/// it receives a TString reference of the pathname to be expanded.
1130/// Returns kTRUE in case of error and kFALSE otherwise.
1131
1133{
1134 const int kBufSize = kMAXPATHLEN;
1135 char xname[kBufSize];
1136
1137 Bool_t res = ExpandFileName(fname.Data(), xname, kBufSize);
1138 if (!res)
1139 fname = xname;
1140
1141 return res;
1142}
1143
1144////////////////////////////////////////////////////////////////////////////
1145/// Private method for pathname expansion.
1146/// Returns kTRUE in case of error and kFALSE otherwise.
1147
1148Bool_t TSystem::ExpandFileName(const char *fname, char *xname, const int kBufSize)
1149{
1150 int n, ier, iter, lx, ncopy;
1151 char *inp, *out, *x, *t, *buff;
1152 const char *b, *c, *e;
1153 const char *p;
1154 buff = new char[kBufSize * 4];
1155
1156 iter = 0; xname[0] = 0; inp = buff + kBufSize; out = inp + kBufSize;
1157 inp[-1] = ' '; inp[0] = 0; out[-1] = ' ';
1158 c = fname + strspn(fname, " \t\f\r");
1159 //VP if (isalnum(c[0])) { strcpy(inp, WorkingDirectory()); strcat(inp, "/"); } // add $cwd
1160
1161 strlcat(inp, c, kBufSize);
1162
1163again:
1164 iter++; c = inp; ier = 0;
1165 x = out; x[0] = 0;
1166
1167 p = nullptr; e = nullptr;
1168 if (c[0] == '~' && c[1] == '/') { // ~/ case
1169 std::string hd = GetHomeDirectory();
1170 p = hd.c_str();
1171 e = c + 1;
1172 if (p) { // we have smth to copy
1173 strlcpy(x, p, kBufSize);
1174 x += strlen(p);
1175 c = e;
1176 } else {
1177 ++ier;
1178 ++c;
1179 }
1180 } else if (c[0] == '~' && c[1] != '/') { // ~user case
1181 n = strcspn(c+1, "/ ");
1182 assert((n+1) < kBufSize && "This should have been prevented by the truncation 'strlcat(inp, c, kBufSize)'");
1183 // There is no overlap here as the buffer is segment in 4 strings of at most kBufSize
1184 (void)strlcpy(buff, c+1, n+1); // strlcpy copy 'size-1' characters.
1185 std::string hd = GetHomeDirectory(buff);
1186 e = c+1+n;
1187 if (!hd.empty()) { // we have smth to copy
1188 p = hd.c_str();
1189 strlcpy(x, p, kBufSize);
1190 x += strlen(p);
1191 c = e;
1192 } else {
1193 x++[0] = c[0];
1194 //++ier;
1195 ++c;
1196 }
1197 }
1198
1199 for ( ; c[0]; c++) {
1200
1201 p = nullptr; e = nullptr;
1202
1203 if (c[0] == '.' && c[1] == '/' && c[-1] == ' ') { // $cwd
1204 std::string wd = GetWorkingDirectory();
1205 strlcpy(buff, wd.c_str(), kBufSize);
1206 p = buff;
1207 e = c + 1;
1208 }
1209 if (p) { // we have smth to copy */
1210 strlcpy(x, p, kBufSize); x += strlen(p); c = e-1; continue;
1211 }
1212
1213 if (c[0] != '$') { // not $, simple copy
1214 x++[0] = c[0];
1215 } else { // we have a $
1216 b = c+1;
1217 if (c[1] == '(') b++;
1218 if (c[1] == '{') b++;
1219 if (b[0] == '$')
1220 e = b+1;
1221 else
1222 for (e = b; isalnum(e[0]) || e[0] == '_'; e++) ;
1223 buff[0] = 0; strncat(buff, b, e-b);
1224 p = Getenv(buff);
1225 if (!p) { // too bad, try UPPER case
1226 for (t = buff; (t[0] = toupper(t[0])); t++) ;
1227 p = Getenv(buff);
1228 }
1229 if (!p) { // too bad, try Lower case
1230 for (t = buff; (t[0] = tolower(t[0])); t++) ;
1231 p = Getenv(buff);
1232 }
1233 if (!p && !strcmp(buff, "cwd")) { // it is $cwd
1234 std::string wd = GetWorkingDirectory();
1235 strlcpy(buff, wd.c_str(), kBufSize);
1236 p = buff;
1237 }
1238 if (!p && !strcmp(buff, "$")) { // it is $$ (replace by GetPid())
1239 snprintf(buff,kBufSize*4, "%d", GetPid());
1240 p = buff;
1241 }
1242 if (!p) { // too bad, nothing can help
1243#ifdef WIN32
1244 // if we're on windows, we can have \\SomeMachine\C$ - don't
1245 // complain about that, if '$' is followed by nothing or a
1246 // path delimiter.
1247 if (c[1] && c[1]!='\\' && c[1]!=';' && c[1]!='/')
1248 ier++;
1249#else
1250 ier++;
1251#endif
1252 x++[0] = c[0];
1253 } else { // It is OK, copy result
1254 int lp = strlen(p);
1255 if (lp >= kBufSize) {
1256 // make sure lx will be >= kBufSize (see below)
1257 strlcpy(x, p, kBufSize);
1258 x += kBufSize;
1259 break;
1260 }
1261 strcpy(x,p);
1262 x += lp;
1263 c = (b==c+1) ? e-1 : e;
1264 }
1265 }
1266 }
1267
1268 x[0] = 0; lx = x - out;
1269 if (ier && iter < 3) { strlcpy(inp, out, kBufSize); goto again; }
1270 ncopy = (lx >= kBufSize) ? kBufSize-1 : lx;
1271 xname[0] = 0; strncat(xname, out, ncopy);
1272
1273 delete[] buff;
1274
1275 if (ier || ncopy != lx) {
1276 ::Error("TSystem::ExpandFileName", "input: %s, output: %s", fname, xname);
1277 return kTRUE;
1278 }
1279
1280 return kFALSE;
1281}
1282
1283
1284////////////////////////////////////////////////////////////////////////////////
1285/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1286/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1287/// environment variables in a pathname. If compatibility is not an issue
1288/// you can use on Unix directly $XXX.
1289
1294
1295////////////////////////////////////////////////////////////////////////////////
1296/// Expand a pathname getting rid of special shell characters like ~.$, etc.
1297/// For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
1298/// environment variables in a pathname. If compatibility is not an issue
1299/// you can use on Unix directly $XXX. The user must delete returned string.
1300
1301char *TSystem::ExpandPathName(const char *)
1302{
1303 return nullptr;
1304}
1305
1306////////////////////////////////////////////////////////////////////////////////
1307/// Returns FALSE if one can access a file using the specified access mode.
1308/// The file name must not contain any special shell characters line ~ or $,
1309/// in those cases first call ExpandPathName().
1310/// Attention, bizarre convention of return value!!
1311
1313{
1314 return kFALSE;
1315}
1316
1317////////////////////////////////////////////////////////////////////////////////
1318/// Returns TRUE if the url in 'path' points to the local file system.
1319/// This is used to avoid going through the NIC card for local operations.
1320
1322{
1324
1325 TUrl url(path);
1326 if (strlen(url.GetHost()) > 0) {
1327 // Check locality
1328 localPath = kFALSE;
1329 TInetAddress a(gSystem->GetHostByName(url.GetHost()));
1331 if (!strcmp(a.GetHostName(), b.GetHostName()) ||
1332 !strcmp(a.GetHostAddress(), b.GetHostAddress())) {
1333 // Host OK
1334 localPath = kTRUE;
1335 // Check the user if specified
1336 if (strlen(url.GetUser()) > 0) {
1338 if (u) {
1339 if (strcmp(u->fUser, url.GetUser()))
1340 // Requested a different user
1341 localPath = kFALSE;
1342 delete u;
1343 }
1344 }
1345 }
1346 }
1347 // Done
1348 return localPath;
1349}
1350
1351////////////////////////////////////////////////////////////////////////////////
1352/// Copy a file. If overwrite is true and file already exists the
1353/// file will be overwritten. Returns 0 when successful, -1 in case
1354/// of file open failure, -2 in case the file already exists and overwrite
1355/// was false and -3 in case of error during copy.
1356
1357int TSystem::CopyFile(const char *, const char *, Bool_t)
1358{
1359 AbstractMethod("CopyFile");
1360 return -1;
1361}
1362
1363////////////////////////////////////////////////////////////////////////////////
1364/// Rename a file.
1365
1366int TSystem::Rename(const char *, const char *)
1367{
1368 AbstractMethod("Rename");
1369 return -1;
1370}
1371
1372////////////////////////////////////////////////////////////////////////////////
1373/// Create a link from file1 to file2.
1374
1375int TSystem::Link(const char *, const char *)
1376{
1377 AbstractMethod("Link");
1378 return -1;
1379}
1380
1381////////////////////////////////////////////////////////////////////////////////
1382/// Create a symbolic link from file1 to file2.
1383
1384int TSystem::Symlink(const char *, const char *)
1385{
1386 AbstractMethod("Symlink");
1387 return -1;
1388}
1389
1390////////////////////////////////////////////////////////////////////////////////
1391/// Unlink, i.e. remove, a file.
1392///
1393/// If the file is currently open by the current or another process, the behavior of this function is
1394/// implementation-defined (in particular, POSIX systems unlink the file name, while Windows does not allow the
1395/// file to be deleted and the operation is a no-op).
1396
1397int TSystem::Unlink(const char *)
1398{
1399 AbstractMethod("Unlink");
1400 return -1;
1401}
1402
1403////////////////////////////////////////////////////////////////////////////////
1404/// Get info about a file: id, size, flags, modification time.
1405/// - Id is (statbuf.st_dev << 24) + statbuf.st_ino
1406/// - Size is the file size
1407/// - Flags is file type: 0 is regular file, bit 0 set executable,
1408/// bit 1 set directory, bit 2 set special file
1409/// (socket, fifo, pipe, etc.)
1410/// Modtime is modification time.
1411/// The function returns 0 in case of success and 1 if the file could
1412/// not be stat'ed.
1413
1414int TSystem::GetPathInfo(const char *path, Long_t *id, Long_t *size,
1415 Long_t *flags, Long_t *modtime)
1416{
1418
1419 int res = GetPathInfo(path, id, &lsize, flags, modtime);
1420
1421 if (res == 0 && size) {
1422 if (sizeof(Long_t) == 4 && lsize > kMaxInt) {
1423 Error("GetPathInfo", "file %s > 2 GB, use GetPathInfo() with Long64_t size", path);
1424 *size = kMaxInt;
1425 } else {
1426 *size = (Long_t)lsize;
1427 }
1428 }
1429
1430 return res;
1431}
1432
1433////////////////////////////////////////////////////////////////////////////////
1434/// Get info about a file: id, size, flags, modification time.
1435/// - Id is (statbuf.st_dev << 24) + statbuf.st_ino
1436/// - Size is the file size
1437/// - Flags is file type: 0 is regular file, bit 0 set executable,
1438/// bit 1 set directory, bit 2 set special file
1439/// (socket, fifo, pipe, etc.)
1440/// Modtime is modification time.
1441/// The function returns 0 in case of success and 1 if the file could
1442/// not be stat'ed.
1443
1444int TSystem::GetPathInfo(const char *path, Long_t *id, Long64_t *size,
1445 Long_t *flags, Long_t *modtime)
1446{
1447 FileStat_t buf;
1448
1449 int res = GetPathInfo(path, buf);
1450
1451 if (res == 0) {
1452 if (id)
1453 *id = (buf.fDev << 24) + buf.fIno;
1454 if (size)
1455 *size = buf.fSize;
1456 if (modtime)
1457 *modtime = buf.fMtime;
1458 if (flags) {
1459 *flags = 0;
1460 if (buf.fMode & (kS_IXUSR|kS_IXGRP|kS_IXOTH))
1461 *flags |= 1;
1462 if (R_ISDIR(buf.fMode))
1463 *flags |= 2;
1464 if (!R_ISREG(buf.fMode) && !R_ISDIR(buf.fMode))
1465 *flags |= 4;
1466 }
1467 }
1468
1469 return res;
1470}
1471
1472////////////////////////////////////////////////////////////////////////////////
1473/// Get info about a file. Info is returned in the form of a FileStat_t
1474/// structure (see TSystem.h).
1475/// The function returns 0 in case of success and 1 if the file could
1476/// not be stat'ed.
1477
1479{
1480 AbstractMethod("GetPathInfo(const char *, FileStat_t&)");
1481 return 1;
1482}
1483
1484////////////////////////////////////////////////////////////////////////////////
1485/// Get info about a file system: fs type, block size, number of blocks,
1486/// number of free blocks.
1487
1488int TSystem::GetFsInfo(const char *, Long_t *, Long_t *, Long_t *, Long_t *)
1489{
1490 AbstractMethod("GetFsInfo");
1491 return 1;
1492}
1493
1494////////////////////////////////////////////////////////////////////////////////
1495/// Return a user configured or systemwide directory to create
1496/// temporary files in.
1497
1498const char *TSystem::TempDirectory() const
1499{
1500 AbstractMethod("TempDirectory");
1501 return nullptr;
1502}
1503
1504////////////////////////////////////////////////////////////////////////////////
1505/// Create a secure temporary file by appending a unique
1506/// 6 letter string to base. The file will be created in
1507/// a standard (system) directory or in the directory
1508/// provided in dir. Optionally one can provide suffix
1509/// append to the final name - like extension ".txt" or ".html".
1510/// The full filename is returned in base
1511/// and a filepointer is returned for safely writing to the file
1512/// (this avoids certain security problems). Returns 0 in case
1513/// of error.
1514
1515FILE *TSystem::TempFileName(TString &, const char *, const char *)
1516{
1517 AbstractMethod("TempFileName");
1518 return nullptr;
1519}
1520
1521////////////////////////////////////////////////////////////////////////////////
1522/// Set the file permission bits. Returns -1 in case or error, 0 otherwise.
1523
1524int TSystem::Chmod(const char *, UInt_t)
1525{
1526 AbstractMethod("Chmod");
1527 return -1;
1528}
1529
1530////////////////////////////////////////////////////////////////////////////////
1531/// Set the process file creation mode mask.
1532
1534{
1535 AbstractMethod("Umask");
1536 return -1;
1537}
1538
1539////////////////////////////////////////////////////////////////////////////////
1540/// Set the a files modification and access times. If actime = 0 it will be
1541/// set to the modtime. Returns 0 on success and -1 in case of error.
1542
1543int TSystem::Utime(const char *, Long_t, Long_t)
1544{
1545 AbstractMethod("Utime");
1546 return -1;
1547}
1548
1549////////////////////////////////////////////////////////////////////////////////
1550/// Find location of file in a search path. Return value points to TString for
1551/// compatibility with Which(const char *, const char *, EAccessMode).
1552/// Returns 0 in case file is not found.
1553
1554const char *TSystem::FindFile(const char *, TString&, EAccessMode)
1555{
1556 AbstractMethod("FindFile");
1557 return nullptr;
1558}
1559
1560////////////////////////////////////////////////////////////////////////////////
1561/// Find location of file in a search path. User must delete returned string.
1562/// Returns 0 in case file is not found.
1563
1564char *TSystem::Which(const char *search, const char *wfil, EAccessMode mode)
1565{
1568 if (wfilString.IsNull())
1569 return nullptr;
1570 return StrDup(wfilString.Data());
1571}
1572
1573//---- Users & Groups ----------------------------------------------------------
1574
1575////////////////////////////////////////////////////////////////////////////////
1576/// Returns the user's id. If user = 0, returns current user's id.
1577
1578Int_t TSystem::GetUid(const char * /*user*/)
1579{
1580 AbstractMethod("GetUid");
1581 return 0;
1582}
1583
1584////////////////////////////////////////////////////////////////////////////////
1585/// Returns the effective user id. The effective id corresponds to the
1586/// set id bit on the file being executed.
1587
1589{
1590 AbstractMethod("GetEffectiveUid");
1591 return 0;
1592}
1593
1594////////////////////////////////////////////////////////////////////////////////
1595/// Returns the group's id. If group = 0, returns current user's group.
1596
1597Int_t TSystem::GetGid(const char * /*group*/)
1598{
1599 AbstractMethod("GetGid");
1600 return 0;
1601}
1602
1603////////////////////////////////////////////////////////////////////////////////
1604/// Returns the effective group id. The effective group id corresponds
1605/// to the set id bit on the file being executed.
1606
1608{
1609 AbstractMethod("GetEffectiveGid");
1610 return 0;
1611}
1612
1613////////////////////////////////////////////////////////////////////////////////
1614/// Returns all user info in the UserGroup_t structure. The returned
1615/// structure must be deleted by the user. In case of error 0 is returned.
1616
1618{
1619 AbstractMethod("GetUserInfo");
1620 return nullptr;
1621}
1622
1623////////////////////////////////////////////////////////////////////////////////
1624/// Returns all user info in the UserGroup_t structure. If user = 0, returns
1625/// current user's id info. The returned structure must be deleted by the
1626/// user. In case of error 0 is returned.
1627
1628UserGroup_t *TSystem::GetUserInfo(const char * /*user*/)
1629{
1630 AbstractMethod("GetUserInfo");
1631 return nullptr;
1632}
1633
1634////////////////////////////////////////////////////////////////////////////////
1635/// Returns all group info in the UserGroup_t structure. The only active
1636/// fields in the UserGroup_t structure for this call are:
1637/// - fGid and fGroup
1638/// The returned structure must be deleted by the user. In case of
1639/// error 0 is returned.
1640
1642{
1643 AbstractMethod("GetGroupInfo");
1644 return nullptr;
1645}
1646
1647////////////////////////////////////////////////////////////////////////////////
1648/// Returns all group info in the UserGroup_t structure. The only active
1649/// fields in the UserGroup_t structure for this call are:
1650/// - fGid and fGroup
1651/// If group = 0, returns current user's group. The returned structure
1652/// must be deleted by the user. In case of error 0 is returned.
1653
1654UserGroup_t *TSystem::GetGroupInfo(const char * /*group*/)
1655{
1656 AbstractMethod("GetGroupInfo");
1657 return nullptr;
1658}
1659
1660//---- environment manipulation ------------------------------------------------
1661
1662////////////////////////////////////////////////////////////////////////////////
1663/// Set environment variable.
1664
1665void TSystem::Setenv(const char *, const char *)
1666{
1667 AbstractMethod("Setenv");
1668}
1669
1670////////////////////////////////////////////////////////////////////////////////
1671/// Unset environment variable.
1672
1673void TSystem::Unsetenv(const char *name)
1674{
1675 Setenv(name, "");
1676}
1677
1678////////////////////////////////////////////////////////////////////////////////
1679/// Get environment variable.
1680
1681const char *TSystem::Getenv(const char *)
1682{
1683 AbstractMethod("Getenv");
1684 return nullptr;
1685}
1686
1687//---- System Logging ----------------------------------------------------------
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Open connection to system log daemon. For the use of the options and
1691/// facility see the Unix openlog man page.
1692
1694{
1695 AbstractMethod("Openlog");
1696}
1697
1698////////////////////////////////////////////////////////////////////////////////
1699/// Send mess to syslog daemon. Level is the logging level and mess the
1700/// message that will be written on the log.
1701
1702void TSystem::Syslog(ELogLevel, const char *)
1703{
1704 AbstractMethod("Syslog");
1705}
1706
1707////////////////////////////////////////////////////////////////////////////////
1708/// Close connection to system log daemon.
1709
1711{
1712 AbstractMethod("Closelog");
1713}
1714
1715//---- Standard output redirection ---------------------------------------------
1716
1717////////////////////////////////////////////////////////////////////////////////
1718/// Redirect standard output (stdout, stderr) to the specified file.
1719/// If the file argument is 0 the output is set again to stderr, stdout.
1720/// The second argument specifies whether the output should be added to the
1721/// file ("a", default) or the file be truncated before ("w").
1722/// The implementations of this function save internally the current state into
1723/// a static structure.
1724///
1725/// The call can be made reentrant by specifying the opaque structure pointed
1726/// by 'h', which is filled with the relevant information. The handle 'h'
1727/// obtained on the first call must then be used in any subsequent call,
1728/// included ShowOutput, to display the redirected output.
1729/// Returns 0 on success, -1 in case of error.
1730
1731Int_t TSystem::RedirectOutput(const char *, const char *, RedirectHandle_t *)
1732{
1733 AbstractMethod("RedirectOutput");
1734 return -1;
1735}
1736
1737////////////////////////////////////////////////////////////////////////////////
1738/// Display the content associated with the redirection described by the
1739/// opaque handle 'h'.
1740
1742{
1743 // Check input ...
1744 if (!h) {
1745 Error("ShowOutput", "handle not specified");
1746 return;
1747 }
1748
1749 // ... and file access
1750 if (gSystem->AccessPathName(h->fFile, kReadPermission)) {
1751 Error("ShowOutput", "file '%s' cannot be read", h->fFile.Data());
1752 return;
1753 }
1754
1755 // Open the file
1756 FILE *f = nullptr;
1757 if (!(f = fopen(h->fFile.Data(), "r"))) {
1758 Error("ShowOutput", "file '%s' cannot be open", h->fFile.Data());
1759 return;
1760 }
1761
1762 // Determine the number of bytes to be read from the file.
1763 off_t ltot = lseek(fileno(f), (off_t) 0, SEEK_END);
1764 Int_t begin = (h->fReadOffSet > 0 && h->fReadOffSet < ltot) ? h->fReadOffSet : 0;
1765 lseek(fileno(f), (off_t) begin, SEEK_SET);
1766 Int_t left = ltot - begin;
1767
1768 // Now readout from file
1769 const Int_t kMAXBUF = 16384;
1770 char buf[kMAXBUF];
1771 Int_t wanted = (left > kMAXBUF-1) ? kMAXBUF-1 : left;
1772 Int_t len;
1773 do {
1774 while ((len = read(fileno(f), buf, wanted)) < 0 &&
1777
1778 if (len < 0) {
1779 SysError("ShowOutput", "error reading log file");
1780 break;
1781 }
1782
1783 // Null-terminate
1784 buf[len] = 0;
1785 fprintf(stderr,"%s", buf);
1786
1787 // Update counters
1788 left -= len;
1789 wanted = (left > kMAXBUF) ? kMAXBUF : left;
1790
1791 } while (len > 0 && left > 0);
1792
1793 // Do not display twice the same thing
1794 h->fReadOffSet = ltot;
1795 fclose(f);
1796}
1797
1798//---- Dynamic Loading ---------------------------------------------------------
1799
1800////////////////////////////////////////////////////////////////////////////////
1801/// Add a new directory to the dynamic path.
1802
1803void TSystem::AddDynamicPath(const char *)
1804{
1805 AbstractMethod("AddDynamicPath");
1806}
1807
1808////////////////////////////////////////////////////////////////////////////////
1809/// Return the dynamic path (used to find shared libraries).
1810
1812{
1813 AbstractMethod("GetDynamicPath");
1814 return nullptr;
1815}
1816
1817////////////////////////////////////////////////////////////////////////////////
1818/// Set the dynamic path to a new value.
1819/// If the value of 'path' is zero, the dynamic path is reset to its
1820/// default value.
1821
1822void TSystem::SetDynamicPath(const char *)
1823{
1824 AbstractMethod("SetDynamicPath");
1825}
1826
1827
1828////////////////////////////////////////////////////////////////////////////////
1829/// Figure out if left and right points to the same
1830/// object in the file system.
1831
1832static bool R__MatchFilename(const char *left, const char *right)
1833{
1834 if (left == right) return kTRUE;
1835
1836 if (left==nullptr || right==nullptr) return kFALSE;
1837
1838 if ( (strcmp(right,left)==0) ) {
1839 return kTRUE;
1840 }
1841
1842#ifdef G__WIN32
1843
1844 char leftname[_MAX_PATH];
1845 char rightname[_MAX_PATH];
1846 _fullpath( leftname, left, _MAX_PATH );
1847 _fullpath( rightname, right, _MAX_PATH );
1848 return ((stricmp(leftname, rightname)==0));
1849#else
1850 struct stat rightBuf;
1851 struct stat leftBuf;
1852 return ( ( 0 == stat( left, & leftBuf ) )
1853 && ( 0 == stat( right, & rightBuf ) )
1854 && ( leftBuf.st_dev == rightBuf.st_dev ) // Files on same device
1855 && ( leftBuf.st_ino == rightBuf.st_ino ) // Files on same inode (but this is not unique on AFS so we need the next 2 test
1856 && ( leftBuf.st_size == rightBuf.st_size ) // Files of same size
1857 && ( leftBuf.st_mtime == rightBuf.st_mtime ) // Files modified at the same time
1858 );
1859#endif
1860}
1861
1862
1863////////////////////////////////////////////////////////////////////////////////
1864/// Load a shared library. Returns 0 on successful loading, 1 in
1865/// case lib was already loaded, -1 in case lib does not exist
1866/// or in case of error and -2 in case of version mismatch.
1867/// When entry is specified the loaded lib is
1868/// searched for this entry point (return -1 when entry does not exist,
1869/// 0 otherwise). When the system flag is kTRUE, the library is considered
1870/// a permanent system library that should not be unloaded during the
1871/// course of the session.
1872
1873int TSystem::Load(const char *module, const char *entry, Bool_t system)
1874{
1875 // don't load libraries that have already been loaded
1878
1879 Ssiz_t idx = l.Last('.');
1880 if (idx != kNPOS) {
1881 l.Remove(idx+1);
1882 }
1883 for (idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1884 // The libs contains the sub-string 'l', let's make sure it is
1885 // not just part of a larger name.
1886 if (idx == 0 || libs[idx-1] == '/' || libs[idx-1] == '\\') {
1887 Ssiz_t len = libs.Length();
1888 idx += l.Length();
1889 if (!l.EndsWith(".") && libs[idx]=='.')
1890 idx++;
1891 // Skip the soversion.
1892 while (idx < len && isdigit(libs[idx])) {
1893 ++idx;
1894 // No need to test for len here, at worse idx==len and lib[idx]=='\0'
1895 if (libs[idx] == '.') {
1896 ++idx;
1897 }
1898 }
1899 while (idx < len && libs[idx] != '.') {
1900 if (libs[idx] == ' ' || idx+1 == len) {
1901 return 1;
1902 }
1903 ++idx;
1904 }
1905 }
1906 }
1907 if (l[l.Length()-1] == '.') {
1908 l.Remove(l.Length()-1);
1909 }
1910 if (l.BeginsWith("lib")) {
1911 l.Replace(0, 3, "-l");
1912 for(idx = libs.Index(l); idx != kNPOS; idx = libs.Index(l,idx+1)) {
1913 if ((idx == 0 || libs[idx-1] == ' ') &&
1914 (libs[idx+l.Length()] == ' ' || libs[idx+l.Length()] == 0)) {
1915 return 1;
1916 }
1917 }
1918 }
1919
1920 char *path = DynamicPathName(module);
1921
1922 int ret = -1;
1923 if (path) {
1924 // load any dependent libraries
1925 TString deplibs = gInterpreter->GetSharedLibDeps(path);
1926 if (!deplibs.IsNull()) {
1927 TString delim(" ");
1928 TObjArray *tokens = deplibs.Tokenize(delim);
1929 for (Int_t i = tokens->GetEntriesFast()-1; i > 0; i--) {
1930 const char *deplib = ((TObjString*)tokens->At(i))->GetName();
1931 if (strcmp(module,deplib)==0) {
1932 continue;
1933 }
1934 if (gDebug > 0)
1935 Info("Load", "loading dependent library %s for library %s",
1936 deplib, ((TObjString*)tokens->At(0))->GetName());
1937 if ((ret = Load(deplib, "", system)) < 0) {
1938 delete tokens;
1939 delete [] path;
1940 return ret;
1941 }
1942 }
1943 delete tokens;
1944 }
1945 if (!system) {
1946 // Mark the library in $ROOTSYS/lib as system.
1947 TString dirname = GetDirName(path);
1949
1950 if (!system) {
1952 }
1953 }
1954
1957 gLibraryVersionMax *= 2;
1959 }
1960 ret = gInterpreter->Load(path, system);
1961 if (ret < 0) ret = -1;
1962 if (gDebug > 0)
1963 Info("Load", "loaded library %s, status %d", path, ret);
1964 if (ret == 0 && gLibraryVersion[gLibraryVersionIdx]) {
1966 Error("Load", "version mismatch, %s = %d, ROOT = %d",
1967 path, v, gROOT->GetVersionInt());
1968 ret = -2;
1970 }
1972 delete [] path;
1973 }
1974
1975 if (!entry || !entry[0] || ret < 0) return ret;
1976
1978 if (f) return 0;
1979 return -1;
1980}
1981
1982///////////////////////////////////////////////////////////////////////////////
1983/// Load all libraries known to ROOT via the rootmap system.
1984/// Returns the number of top level libraries successfully loaded.
1985
1987{
1988 UInt_t nlibs = 0;
1989
1990 TEnv* mapfile = gInterpreter->GetMapfile();
1991 if (!mapfile || !mapfile->GetTable()) return 0;
1992
1993 std::set<std::string> loadedlibs;
1994 std::set<std::string> failedlibs;
1995
1996 TEnvRec* rec = nullptr;
1997 TIter iEnvRec(mapfile->GetTable());
1998 while ((rec = (TEnvRec*) iEnvRec())) {
1999 TString libs = rec->GetValue();
2000 TString lib;
2001 Ssiz_t pos = 0;
2002 while (libs.Tokenize(lib, pos)) {
2003 // check that none of the libs failed to load
2004 if (failedlibs.find(lib.Data()) != failedlibs.end()) {
2005 // don't load it or any of its dependencies
2006 libs = "";
2007 break;
2008 }
2009 }
2010 pos = 0;
2011 while (libs.Tokenize(lib, pos)) {
2012 // ignore libCore - it's already loaded
2013 if (lib.BeginsWith("libCore"))
2014 continue;
2015
2016 if (loadedlibs.find(lib.Data()) == loadedlibs.end()) {
2017 // just load the first library - TSystem will do the rest.
2018 auto res = gSystem->Load(lib);
2019 if (res >=0) {
2020 if (res == 0) ++nlibs;
2021 loadedlibs.insert(lib.Data());
2022 } else {
2023 failedlibs.insert(lib.Data());
2024 }
2025 }
2026 }
2027 }
2028 return nlibs;
2029}
2030
2031////////////////////////////////////////////////////////////////////////////////
2032/// Find a dynamic library called lib using the system search paths.
2033/// Appends known extensions if needed. Returned string must be deleted
2034/// by the user!
2035
2036char *TSystem::DynamicPathName(const char *lib, Bool_t quiet /*=kFALSE*/)
2037{
2038 TString sLib(lib);
2040 return StrDup(sLib);
2041 return nullptr;
2042}
2043
2044////////////////////////////////////////////////////////////////////////////////
2045/// Find a dynamic library using the system search paths. lib will be updated
2046/// to contain the absolute filename if found. Returns lib if found, or NULL
2047/// if a library called lib was not found.
2048/// This function does not open the library.
2049
2051{
2052 AbstractMethod("FindDynamicLibrary");
2053 return nullptr;
2054}
2055
2056////////////////////////////////////////////////////////////////////////////////
2057/// Find specific entry point in specified library. Specify "*" for lib
2058/// to search in all libraries.
2059
2060Func_t TSystem::DynFindSymbol(const char * /*lib*/, const char *entry)
2061{
2062 return (Func_t) gInterpreter->FindSym(entry);
2063}
2064
2065////////////////////////////////////////////////////////////////////////////////
2066/// Unload a shared library.
2067
2068void TSystem::Unload(const char *module)
2069{
2070 char *path;
2071 if ((path = DynamicPathName(module))) {
2072 gInterpreter->UnloadFile(path);
2073 delete [] path;
2074 }
2075}
2076
2077////////////////////////////////////////////////////////////////////////////////
2078/// List symbols in a shared library.
2079
2080void TSystem::ListSymbols(const char *, const char *)
2081{
2082 AbstractMethod("ListSymbols");
2083}
2084
2085////////////////////////////////////////////////////////////////////////////////
2086/// List the loaded shared libraries.
2087/// `regexp` is a regular expression allowing to filter the list.
2088///
2089/// Examples:
2090///
2091/// The following line lists all the libraries currently loaded:
2092/// ~~~ {.cpp}
2093/// gSystem->ListLibraries()
2094/// ~~~
2095///
2096/// The following line lists all the libraries currently loaded having "RIO" in their names:
2097/// ~~~ {.cpp}
2098/// gSystem->ListLibraries(".*RIO.*")
2099/// ~~~
2100
2101void TSystem::ListLibraries(const char *regexp) {
2102 if (!(regexp && regexp[0]))
2103 regexp = ".*";
2104 TRegexp pat(regexp, kFALSE);
2106 TString tok;
2107 Ssiz_t from = 0, ext;
2108 while (libs.Tokenize(tok, from, " ")) {
2109 if ((tok.Index(pat, &ext) != 0) || (ext != tok.Length()))
2110 continue;
2111 std::cout << tok << "\n";
2112 }
2113}
2114
2115////////////////////////////////////////////////////////////////////////////////
2116/// Return the thread local storage for the custom last error message
2117
2123
2124////////////////////////////////////////////////////////////////////////////////
2125/// Return the thread local storage for the custom last error message
2126
2128{
2129 return const_cast<TSystem*>(this)->GetLastErrorString();
2130}
2131
2132////////////////////////////////////////////////////////////////////////////////
2133/// Get list of shared libraries loaded at the start of the executable.
2134/// Returns 0 in case list cannot be obtained or in case of error.
2135
2137{
2138 return nullptr;
2139}
2140
2141////////////////////////////////////////////////////////////////////////////////
2142/// Return a space separated list of loaded shared libraries.
2143/// Regexp is a wildcard expression, see TRegexp::MakeWildcard.
2144/// This list is of a format suitable for a linker, i.e it may contain
2145/// -Lpathname and/or -lNameOfLib.
2146/// Option can be any of:
2147/// - S: shared libraries loaded at the start of the executable, because
2148/// they were specified on the link line.
2149/// - D: shared libraries dynamically loaded after the start of the program.
2150/// - L: this option is ignored, and available for backward compatibility.
2151
2152const char *TSystem::GetLibraries(const char *regexp, const char *options,
2154{
2155 fListLibs.Clear();
2156
2157 TString libs;
2158 TString opt(options);
2159 Bool_t so2dylib = (opt.First('L') != kNPOS);
2160 if (so2dylib)
2161 opt.ReplaceAll("L", "");
2162
2163 if (opt.IsNull() || opt.First('D') != kNPOS)
2164 libs += gInterpreter->GetSharedLibs();
2165
2166 // Cint currently register all libraries that
2167 // are loaded and have a dictionary in them, this
2168 // includes all the libraries that are included
2169 // in the list of (hard) linked libraries.
2170
2172 const char *linked;
2173 if ((linked = GetLinkedLibraries())) {
2174 if (fLinkedLibs != LINKEDLIBS) {
2175 // This is not the default value, we need to keep the custom part.
2177 custom.ReplaceAll(LINKEDLIBS,linked);
2178 if (custom == fLinkedLibs) {
2179 // no replacement done, let's append linked
2180 slinked.Append(linked);
2181 slinked.Append(" ");
2182 }
2183 slinked.Append(custom);
2184 } else {
2185 slinked.Append(linked);
2186 }
2187 } else {
2188 slinked.Append(fLinkedLibs);
2189 }
2190
2191 if (opt.IsNull() || opt.First('S') != kNPOS) {
2192 // We are done, the statically linked libraries are already included.
2193 if (libs.Length() == 0) {
2194 libs = slinked;
2195 } else {
2196 // We need to add the missing linked library
2197
2198 static TString lastLinked;
2199 static TString lastAddMissing;
2200 if ( lastLinked != slinked ) {
2201 // Recalculate only if there was a change.
2202 static TRegexp separator("[^ \\t\\s]+");
2204 lastAddMissing.Clear();
2205
2206 Ssiz_t start, index, end;
2207 start = index = end = 0;
2208
2209 while ((start < slinked.Length()) && (index != kNPOS)) {
2210 index = slinked.Index(separator,&end,start);
2211 if (index >= 0) {
2212 TString sub = slinked(index,end);
2213 if (sub[0]=='-' && sub[1]=='L') {
2214 lastAddMissing.Prepend(" ");
2215 lastAddMissing.Prepend(sub);
2216 } else {
2217 if (libs.Index(sub) == kNPOS) {
2218 lastAddMissing.Prepend(" ");
2219 lastAddMissing.Prepend(sub);
2220 }
2221 }
2222 }
2223 start += end+1;
2224 }
2225 }
2226 libs.Prepend(lastAddMissing);
2227 }
2228 } else if (libs.Length() != 0) {
2229 // Let remove the statically linked library
2230 // from the list.
2231 static TRegexp separator("[^ \\t\\s]+");
2232 Ssiz_t start, index, end;
2233 start = index = end = 0;
2234
2235 while ((start < slinked.Length()) && (index != kNPOS)) {
2236 index = slinked.Index(separator,&end,start);
2237 if (index >= 0) {
2238 TString sub = slinked(index,end);
2239 if (sub[0]!='-' && sub[1]!='L') {
2240 libs.ReplaceAll(sub,"");
2241 }
2242 }
2243 start += end+1;
2244 }
2245 libs = libs.Strip(TString::kBoth);
2246 }
2247
2248 // Select according to regexp
2249 if (regexp && *regexp) {
2250 static TRegexp separator("[^ \\t\\s]+");
2251 TRegexp user_re(regexp, kTRUE);
2252 TString s;
2253 Ssiz_t start, index, end;
2254 start = index = end = 0;
2255
2256 while ((start < libs.Length()) && (index != kNPOS)) {
2257 index = libs.Index(separator,&end,start);
2258 if (index >= 0) {
2259 s = libs(index,end);
2260 if ((isRegexp && s.Index(user_re) != kNPOS) ||
2261 (!isRegexp && s.Index(regexp) != kNPOS)) {
2262 if (!fListLibs.IsNull())
2263 fListLibs.Append(" ");
2264 fListLibs.Append(s);
2265 }
2266 }
2267 start += end+1;
2268 }
2269 } else
2270 fListLibs = libs;
2271
2272#if defined(R__MACOSX)
2273// We need to remove the libraries that are dynamically loaded and not linked
2274{
2277
2278 static TRegexp separator("[^ \\t\\s]+");
2279 static TRegexp dynload("/lib-dynload/");
2280
2281 Ssiz_t start, index, end;
2282 start = index = end = 0;
2283
2284 while ((start < libs2.Length()) && (index != kNPOS)) {
2285 index = libs2.Index(separator, &end, start);
2286 if (index >= 0) {
2287 TString s = libs2(index, end);
2288 if (s.Index(dynload) == kNPOS) {
2289 if (!maclibs.IsNull()) maclibs.Append(" ");
2290 maclibs.Append(s);
2291 }
2292 }
2293 start += end+1;
2294 }
2296}
2297#endif
2298
2299 return fListLibs.Data();
2300}
2301
2302//---- RPC ---------------------------------------------------------------------
2303
2304////////////////////////////////////////////////////////////////////////////////
2305/// Get Internet Protocol (IP) address of host.
2306
2308{
2309 AbstractMethod("GetHostByName");
2310 return TInetAddress();
2311}
2312
2313////////////////////////////////////////////////////////////////////////////////
2314/// Get Internet Protocol (IP) address of remote host and port #.
2315
2317{
2318 AbstractMethod("GetPeerName");
2319 return TInetAddress();
2320}
2321
2322////////////////////////////////////////////////////////////////////////////////
2323/// Get Internet Protocol (IP) address of host and port #.
2324
2326{
2327 AbstractMethod("GetSockName");
2328 return TInetAddress();
2329}
2330
2331////////////////////////////////////////////////////////////////////////////////
2332/// Get port # of internet service.
2333
2335{
2336 AbstractMethod("GetServiceByName");
2337 return -1;
2338}
2339
2340////////////////////////////////////////////////////////////////////////////////
2341/// Get name of internet service.
2342
2344{
2345 AbstractMethod("GetServiceByPort");
2346 return nullptr;
2347}
2348
2349////////////////////////////////////////////////////////////////////////////////
2350/// Open a connection to another host.
2351
2352int TSystem::OpenConnection(const char *, int, int, const char *)
2353{
2354 AbstractMethod("OpenConnection");
2355 return -1;
2356}
2357
2358////////////////////////////////////////////////////////////////////////////////
2359/// Announce TCP/IP service.
2360
2362{
2363 AbstractMethod("AnnounceTcpService");
2364 return -1;
2365}
2366
2367////////////////////////////////////////////////////////////////////////////////
2368/// Announce UDP service.
2369
2371{
2372 AbstractMethod("AnnounceUdpService");
2373 return -1;
2374}
2375
2376////////////////////////////////////////////////////////////////////////////////
2377/// Announce unix domain service.
2378
2380{
2381 AbstractMethod("AnnounceUnixService");
2382 return -1;
2383}
2384
2385////////////////////////////////////////////////////////////////////////////////
2386/// Announce unix domain service.
2387
2388int TSystem::AnnounceUnixService(const char *, int)
2389{
2390 AbstractMethod("AnnounceUnixService");
2391 return -1;
2392}
2393
2394////////////////////////////////////////////////////////////////////////////////
2395/// Accept a connection.
2396
2398{
2399 AbstractMethod("AcceptConnection");
2400 return -1;
2401}
2402
2403////////////////////////////////////////////////////////////////////////////////
2404/// Close socket connection.
2405
2407{
2408 AbstractMethod("CloseConnection");
2409}
2410
2411////////////////////////////////////////////////////////////////////////////////
2412/// Receive exactly length bytes into buffer. Use opt to receive out-of-band
2413/// data or to have a peek at what is in the buffer (see TSocket).
2414
2415int TSystem::RecvRaw(int, void *, int, int)
2416{
2417 AbstractMethod("RecvRaw");
2418 return -1;
2419}
2420
2421////////////////////////////////////////////////////////////////////////////////
2422/// Send exactly length bytes from buffer. Use opt to send out-of-band
2423/// data (see TSocket).
2424
2425int TSystem::SendRaw(int, const void *, int, int)
2426{
2427 AbstractMethod("SendRaw");
2428 return -1;
2429}
2430
2431////////////////////////////////////////////////////////////////////////////////
2432/// Receive a buffer headed by a length indicator.
2433
2434int TSystem::RecvBuf(int, void *, int)
2435{
2436 AbstractMethod("RecvBuf");
2437 return -1;
2438}
2439
2440////////////////////////////////////////////////////////////////////////////////
2441/// Send a buffer headed by a length indicator.
2442
2443int TSystem::SendBuf(int, const void *, int)
2444{
2445 AbstractMethod("SendBuf");
2446 return -1;
2447}
2448
2449////////////////////////////////////////////////////////////////////////////////
2450/// Set socket option.
2451
2452int TSystem::SetSockOpt(int, int, int)
2453{
2454 AbstractMethod("SetSockOpt");
2455 return -1;
2456}
2457
2458////////////////////////////////////////////////////////////////////////////////
2459/// Get socket option.
2460
2461int TSystem::GetSockOpt(int, int, int*)
2462{
2463 AbstractMethod("GetSockOpt");
2464 return -1;
2465}
2466
2467//---- System, CPU and Memory info ---------------------------------------------
2468
2469////////////////////////////////////////////////////////////////////////////////
2470/// Returns static system info, like OS type, CPU type, number of CPUs
2471/// RAM size, etc into the SysInfo_t structure. Returns -1 in case of error,
2472/// 0 otherwise.
2473
2475{
2476 AbstractMethod("GetSysInfo");
2477 return -1;
2478}
2479
2480////////////////////////////////////////////////////////////////////////////////
2481/// Returns cpu load average and load info into the CpuInfo_t structure.
2482/// Returns -1 in case of error, 0 otherwise. Use sampleTime to set the
2483/// interval over which the CPU load will be measured, in ms (default 1000).
2484
2486{
2487 AbstractMethod("GetCpuInfo");
2488 return -1;
2489}
2490
2491////////////////////////////////////////////////////////////////////////////////
2492/// Returns ram and swap memory usage info into the MemInfo_t structure.
2493/// Returns -1 in case of error, 0 otherwise.
2494
2496{
2497 AbstractMethod("GetMemInfo");
2498 return -1;
2499}
2500
2501////////////////////////////////////////////////////////////////////////////////
2502/// Returns cpu and memory used by this process into the ProcInfo_t structure.
2503/// Returns -1 in case of error, 0 otherwise.
2504
2506{
2507 AbstractMethod("GetProcInfo");
2508 return -1;
2509}
2510
2511//---- Script Compiler ---------------------------------------------------------
2512
2514{
2515 // Assign the char* value to the TString and then delete it.
2516
2518 delete [] tobedeleted;
2519}
2520
2521#ifdef WIN32
2522
2523static TString R__Exec(const char *cmd)
2524{
2525 // Execute a command and return the stdout in a string.
2526
2527 FILE * f = gSystem->OpenPipe(cmd,"r");
2528 if (!f) {
2529 return "";
2530 }
2532
2533 char x;
2534 while ((x = fgetc(f))!=EOF ) {
2535 if (x=='\n' || x=='\r') break;
2536 result += x;
2537 }
2538
2539 fclose(f);
2540 return result;
2541}
2542
2543static void R__FixLink(TString &cmd)
2544{
2545 // Replace the call to 'link' by a full path name call based on where cl.exe is.
2546 // This prevents us from using inadvertently the link.exe provided by cygwin.
2547
2548 // check if link is the microsoft one...
2549 TString res = R__Exec("link 2>&1");
2550 if (res.Length()) {
2551 if (res.Contains("Microsoft (R) Incremental Linker"))
2552 return;
2553 }
2554 // else check availability of cygpath...
2555 res = R__Exec("cygpath . 2>&1");
2556 if (res.Length()) {
2557 if (res != ".")
2558 return;
2559 }
2560
2561 res = R__Exec("which cl.exe 2>&1|grep cl|sed 's,cl\\.exe$,link\\.exe,' 2>&1");
2562 if (res.Length()) {
2563 res = R__Exec(Form("cygpath -w '%s' 2>&1",res.Data()));
2564 if (res.Length()) {
2565 cmd.ReplaceAll(" link ",Form(" \"%s\" ",res.Data()));
2566 }
2567 }
2568}
2569#endif
2570
2571#if defined(__CYGWIN__)
2572static void R__AddPath(TString &target, const TString &path) {
2573 if (path.Length() > 2 && path[1]==':') {
2574 target += TString::Format("/cygdrive/%c",path[0]) + path(2,path.Length()-2);
2575 } else {
2576 target += path;
2577 }
2578}
2579#else
2580static void R__AddPath(TString &target, const TString &path) {
2581 target += path;
2582}
2583#endif
2584
2586 const TString &extension, const char *version_var_prefix, const TString &includes, const TString &defines, const TString &incPath)
2587{
2588 // Generate the dependency via standard output, not searching the
2589 // standard include directories,
2590
2591#ifndef WIN32
2592 const char * stderrfile = "/dev/null";
2593#else
2596#endif
2598
2599#ifdef WIN32
2600 TString touch = "echo # > "; touch += "\"" + depfilename + "\"";
2601#else
2602 TString touch = "echo > "; touch += "\"" + depfilename + "\"";
2603#endif
2604 TString builddep = "rmkdepend";
2606 builddep += " \"-f";
2608 builddep += "\" -o_" + extension + "." + gSystem->GetSoExt() + " ";
2609 if (build_loc.BeginsWith(gSystem->WorkingDirectory())) {
2611 if ( build_loc.Length() > (len+1) ) {
2612 builddep += " \"-p";
2613 if (build_loc[len] == '/' || build_loc[len+1] != '\\' ) {
2614 // Since the path is now ran through TSystem::ExpandPathName the single \ is also possible.
2615 R__AddPath(builddep, build_loc.Data() + len + 1 );
2616 } else {
2617 // Case of dir\\name
2618 R__AddPath(builddep, build_loc.Data() + len + 2 );
2619 }
2620 builddep += "/\" ";
2621 }
2622 } else {
2623 builddep += " \"-p";
2625 builddep += "/\" ";
2626 }
2627 builddep += " -Y -- ";
2629 builddep += " \"-I"+rootsysInclude+"\" "; // cflags
2630 builddep += includes;
2631 builddep += defines;
2632 builddep += " -- \"";
2633 builddep += filename;
2634 builddep += "\" ";
2636 if (library.BeginsWith(gSystem->WorkingDirectory())) {
2638 if ( library.Length() > (len+1) ) {
2639 if (library[len] == '/' || library[len+1] != '\\' ) {
2640 targetname = library.Data() + len + 1;
2641 } else {
2642 targetname = library.Data() + len + 2;
2643 }
2644 } else {
2646 }
2647 } else {
2649 }
2650 builddep += " \"";
2651 builddep += "-t";
2653 builddep += "\" > ";
2655 builddep += " 2>&1 ";
2656
2657 TString adddictdep = "echo ";
2659 adddictdep += ": ";
2660#if defined(R__HAS_CLING_DICTVERSION)
2661 {
2662 char *clingdictversion = gSystem->Which(incPath,"clingdictversion.h");
2663 if (clingdictversion) {
2665 adddictdep += " ";
2666 delete [] clingdictversion;
2667 } else {
2668 R__AddPath(adddictdep,rootsysInclude+"/clingdictversion.h ");
2669 }
2670 }
2671#endif
2672 {
2673 const char *dictHeaders[] = { "RVersion.h", "ROOT/RConfig.hxx", "TClass.h",
2674 "TDictAttributeMap.h","TInterpreter.h","TROOT.h","TBuffer.h",
2675 "TMemberInspector.h","TError.h","RtypesImp.h","TIsAProxy.h",
2676 "TFileMergeInfo.h","TCollectionProxyInfo.h"};
2677
2678 for (unsigned int h=0; h < sizeof(dictHeaders)/sizeof(dictHeaders[0]); ++h)
2679 {
2681 if (rootVersion) {
2683 delete [] rootVersion;
2684 } else {
2686 }
2687 adddictdep += " ";
2688 }
2689 }
2690 {
2691 // Add dependency on rootcling.
2692 char *rootCling = gSystem->Which(gSystem->Getenv("PATH"),"rootcling");
2693 if (rootCling) {
2695 adddictdep += " ";
2696 delete [] rootCling;
2697 }
2698 }
2699 adddictdep += " >> \""+depfilename+"\"";
2700
2701 TString addversiondep( "echo ");
2702 addversiondep += libname + version_var_prefix + " \"" + ROOT_RELEASE + "\" >> \""+depfilename+"\"";
2703
2704 if (gDebug > 4) {
2705 ::Info("ACLiC", "%s", touch.Data());
2706 ::Info("ACLiC", "%s", builddep.Data());
2707 ::Info("ACLiC", "%s", adddictdep.Data());
2708 }
2709
2714
2715 if (!depbuilt) {
2716 ::Warning("ACLiC","Failed to generate the dependency file for %s",
2717 library.Data());
2718 } else {
2719#ifdef WIN32
2721#endif
2723 }
2724}
2725
2726////////////////////////////////////////////////////////////////////////////////
2727/// This method compiles and loads a shared library containing
2728/// the code from the file "filename".
2729///
2730/// The return value is true (1) in case of success and false (0)
2731/// in case of error.
2732///
2733/// The possible options are:
2734/// - k : keep the shared library after the session end.
2735/// - f : force recompilation.
2736/// - g : compile with debug symbol
2737/// - O : optimized the code
2738/// - c : compile only, do not attempt to load the library.
2739/// - s : silence all informational output
2740/// - v : output all information output
2741/// - d : debug ACLiC, keep all the output files.
2742/// - - : if buildir is set, use a flat structure (see buildir below)
2743///
2744/// If library_specified is specified, CompileMacro generates the file
2745/// "library_specified".soext where soext is the shared library extension for
2746/// the current platform.
2747///
2748/// If build_dir is specified, it is used as an alternative 'root' for the
2749/// generation of the shared library. The library is stored in a sub-directories
2750/// of 'build_dir' including the full pathname of the script unless a flat
2751/// directory structure is requested ('-' option). With the '-' option the libraries
2752/// are created directly in the directory 'build_dir'; in particular this means that
2753/// 2 scripts with the same name in different source directory will over-write each
2754/// other's library.
2755/// See also TSystem::SetBuildDir.
2756///
2757/// If dirmode is not zero and we need to create the target directory, the
2758/// file mode bit will be change to 'dirmode' using chmod.
2759///
2760/// If library_specified is not specified, CompileMacro generate a default name
2761/// for library by taking the name of the file "filename" but replacing the
2762/// dot before the extension by an underscore and by adding the shared
2763/// library extension for the current platform.
2764/// For example on most platform, hsimple.cxx will generate hsimple_cxx.so
2765///
2766/// It uses the directive fMakeSharedLibs to create a shared library.
2767/// If loading the shared library fails, it tries to output a list of missing
2768/// symbols by creating an executable (on some platforms like OSF, this does
2769/// not HAVE to be an executable) containing the script. It uses the
2770/// directive fMakeExe to do so.
2771/// For both directives, before passing them to TSystem::Exec, it expands the
2772/// variables $SourceFiles, $SharedLib, $LibName, $IncludePath, $LinkedLibs,
2773/// $DepLibs, $ExeName and $ObjectFiles. See SetMakeSharedLib() for more
2774/// information on those variables.
2775///
2776/// This method is used to implement the following feature:
2777///
2778/// Synopsis:
2779///
2780/// The purpose of this addition is to allow the user to use an external
2781/// compiler to create a shared library from its C++ macro (scripts).
2782/// Currently in order to execute a script, a user has to type at the root
2783/// prompt
2784/// ~~~ {.cpp}
2785/// .X myfunc.C(arg1,arg2)
2786/// ~~~
2787/// We allow them to type:
2788/// ~~~ {.cpp}
2789/// .X myfunc.C++(arg1,arg2)
2790/// ~~~
2791/// or
2792/// ~~~ {.cpp}
2793/// .X myfunc.C+(arg1,arg2)
2794/// ~~~
2795/// In which case an external compiler will be called to create a shared
2796/// library. This shared library will then be loaded and the function
2797/// myfunc will be called with the two arguments. With '++' the shared library
2798/// is always recompiled. With '+' the shared library is recompiled only
2799/// if it does not exist yet or the macro file is newer than the shared
2800/// library.
2801///
2802/// Of course the + and ++ notation is supported in similar way for .x and .L.
2803///
2804/// Through the function TSystem::SetMakeSharedLib(), the user will be able to
2805/// indicate, with shell commands, how to build a shared library (a good
2806/// default will be provided). The most common change, namely where to find
2807/// header files, will be available through the function
2808/// TSystem::SetIncludePath().
2809/// A good default will be provided so that a typical user session should be at
2810/// most:
2811/// ~~~ {.cpp}
2812/// root[1] gSystem->SetIncludePath("-I$ROOTSYS/include
2813/// -I$HOME/mypackage/include");
2814/// root[2] .x myfunc.C++(10,20);
2815/// ~~~
2816/// The user may sometimes try to compile a script before it has loaded all the
2817/// needed shared libraries. In this case we want to be helpful and output a
2818/// list of the unresolved symbols. So if the loading of the created shared
2819/// library fails, we will try to build a executable that contains the
2820/// script. The linker should then output a list of missing symbols.
2821///
2822/// To support this we provide a TSystem::SetMakeExe() function, that sets the
2823/// directive telling how to create an executable. The loader will need
2824/// to be informed of all the libraries available. The information about
2825/// the libraries that has been loaded by .L and TSystem::Load() is accessible
2826/// to the script compiler. However, the information about
2827/// the libraries that have been selected at link time by the application
2828/// builder (like the root libraries for root.exe) are not available and need
2829/// to be explicitly listed in fLinkedLibs (either by default or by a call to
2830/// TSystem::SetLinkedLibs()).
2831///
2832/// To simplify customization we could also add to the .rootrc support for the
2833/// variables
2834/// ~~~ {.cpp}
2835/// Unix.*.Root.IncludePath: -I$ROOTSYS/include
2836/// WinNT.*.Root.IncludePath: -I%ROOTSYS%/include
2837///
2838/// Unix.*.Root.LinkedLibs: -L$ROOTSYS/lib -lBase ....
2839/// WinNT.*.Root.LinkedLibs: %ROOTSYS%/lib/*.lib msvcrt.lib ....
2840/// ~~~
2841/// And also support for MakeSharedLibs() and MakeExe().
2842///
2843/// (the ... have to be replaced by the actual values and are here only to
2844/// shorten this comment).
2845///
2846/// Note that the default behavior is to remove libraries when closing ROOT,
2847/// ie TSystem::CleanCompiledMacros() is called in the TROOT destructor.
2848/// The default behavior of .L script.C+ is the opposite one, leaving things
2849/// after closing, without removing. In other words, .L always passes the 'k'
2850/// option behind the scenes.
2851
2853 const char *library_specified,
2854 const char *build_dir,
2856{
2857 static const char *version_var_prefix = "__ROOTBUILDVERSION=";
2858
2859 // ======= Analyze the options
2860 Bool_t keep = kFALSE;
2862 int mode = fAclicMode;
2865 Bool_t verbose = kFALSE;
2867 if (opt) {
2868 keep = (strchr(opt,'k')!=nullptr);
2869 recompile = (strchr(opt,'f')!=nullptr);
2870 if (strchr(opt,'O')!=nullptr) {
2871 mode |= kOpt;
2872 }
2873 if (strchr(opt,'g')!=nullptr) {
2874 mode |= kDebug;
2875 }
2876 if (strchr(opt,'c')!=nullptr) {
2877 loadLib = kFALSE;
2878 }
2879 withInfo = strchr(opt, 's') == nullptr;
2880 verbose = strchr(opt, 'v') != nullptr;
2881 internalDebug = strchr(opt, 'd') != nullptr;
2882 }
2883 if (mode==kDefault) {
2885 if (rootbuild.Index("debug",0,TString::kIgnoreCase)==kNPOS) {
2886 mode = kOpt;
2887 } else {
2888 mode = kDebug;
2889 }
2890 }
2891 UInt_t verboseLevel = verbose ? 7 : gDebug;
2892 Bool_t flatBuildDir = (fAclicProperties & kFlatBuildDir) || (opt && strchr(opt,'-')!=nullptr);
2893
2894 // if non-zero, build_loc indicates where to build the shared library.
2897 if (build_loc == ".") {
2899 } else if (build_loc.Length() && (!IsAbsoluteFileName(build_loc)) ) {
2901 }
2902
2903 // Get the include directory list in the dir1:dir2:dir3 format
2904 // [Used for generating the .d file and to look for header files for
2905 // the linkdef file]
2906 TString incPath = GetIncludePath(); // of the form -Idir1 -Idir2 -Idir3
2907 incPath.Append(":").Prepend(" ");
2908 if (gEnv) {
2909 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
2910 incPath.Append(fromConfig);
2911 }
2912 incPath.ReplaceAll(" -I",":"); // of form :dir1 :dir2:dir3
2913 auto posISysRoot = incPath.Index(" -isysroot \"");
2914 if (posISysRoot != kNPOS) {
2915 auto posISysRootEnd = incPath.Index('"', posISysRoot + 12);
2916 if (posISysRootEnd != kNPOS) {
2917 // NOTE: should probably just skip isysroot for dependency analysis.
2918 // (And will, in the future - once we rely on compiler-generated .d files.)
2919 incPath.Insert(posISysRootEnd - 1, "/usr/include/");
2920 incPath.Replace(posISysRoot, 12, ":\"");
2921 }
2922 }
2923 while ( incPath.Index(" :") != -1 ) {
2924 incPath.ReplaceAll(" :",":");
2925 }
2926 incPath.Prepend(":.:");
2927 incPath.Prepend(WorkingDirectory());
2928
2929 // ======= Get the right file names for the dictionary and the shared library
2935 {
2936 const char *whichlibrary = Which(incPath,library);
2937 if (whichlibrary) {
2939 delete [] whichlibrary;
2940 } else {
2941 ::Error("ACLiC","The file %s can not be found in the include path: %s",filename,incPath.Data());
2942 return kFALSE;
2943 }
2944 } else {
2946 ::Error("ACLiC","The file %s can not be found.",filename);
2947 return kFALSE;
2948 }
2949 }
2950 { // Remove multiple '/' characters, rootcling treats them as comments.
2951 Ssiz_t pos = 0;
2952 while ((pos = library.Index("//", 2, pos, TString::kExact)) != kNPOS) {
2953 library.Remove(pos, 1);
2954 }
2955 }
2958
2960 // For some probably good reason, DirName on Windows returns the 'name' of
2961 // the directory, omitting the drive letter (even if there was one). In
2962 // consequence the result is not usable as a 'root directory', we need to
2963 // add the drive letter if there was one..
2964 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
2965 file_dirname.Prepend(library(0,2));
2966 }
2967 TString file_location( file_dirname ); // Location of the script.
2968 incPath.Prepend( file_location + ":" );
2969
2970 Ssiz_t dot_pos = library.Last('.');
2972 if (dot_pos >= 0) {
2973 libname_noext.Remove(dot_pos);
2974 extension = library(dot_pos+1, library.Length()-dot_pos-1);
2975 }
2976
2977 // Extension of shared library is platform dependent!!
2978 TString suffix = TString("_") + extension + "." + fSoExt;
2979 if (dot_pos >= 0)
2980 library.Replace( dot_pos, library.Length()-dot_pos, suffix);
2981 else
2982 library.Append(suffix);
2983
2985 libname.Append("_").Append(extension);
2986
2988 // Use the specified name instead of the default
2992 if (! IsAbsoluteFileName(library) ) {
2994 }
2996 library = TString(library) + "." + fSoExt;
2997 }
2999
3001 libname_ext += "." + fSoExt;
3002
3004 // For some probably good reason, DirName on Windows returns the 'name' of
3005 // the directory, omitting the drive letter (even if there was one). In
3006 // consequence the result is not useable as a 'root directory', we need to
3007 // add the drive letter if there was one..
3008 if (library.Length()>1 && isalpha(library[0]) && library[1]==':') {
3009 lib_dirname.Prepend(library(0,2));
3010 }
3011 // Strip potential, somewhat redundant '/.' from the pathname ...
3012 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "/.", 2) == 0 ) {
3013 lib_dirname.Remove(lib_dirname.Length()-2);
3014 }
3015 if ( strncmp( &(lib_dirname[lib_dirname.Length()-2]), "\\.", 2) == 0 ) {
3016 lib_dirname.Remove(lib_dirname.Length()-2);
3017 }
3020
3021 if (build_loc.Length()==0) {
3023 } else {
3024 // Removes an existing disk specification from the names
3025 TRegexp disk_finder ("[A-z]:");
3026 Int_t pos = library.Index( disk_finder );
3027 if (pos==0) library.Remove(pos,3);
3028 pos = lib_location.Index( disk_finder );
3029 if (pos==0) lib_location.Remove(pos,3);
3030
3031 if (flatBuildDir) {
3033 } else {
3035 }
3036
3039 if (!flatBuildDir) {
3041 }
3042
3044 mkdirFailed = (0 != mkdir(build_loc, true));
3046 // The mkdir failed __and__ we can not write to the target directory,
3047 // let make sure the error message will be about the target directory
3050 } else if (!mkdirFailed && dirmode!=0) {
3052 }
3053 }
3054 }
3056
3057 // ======= Check if the library need to loaded or compiled
3058 if (!gInterpreter->IsLibraryLoaded(library) && gInterpreter->IsLoaded(expFileName)) {
3059 // the script has already been loaded in interpreted mode
3060 // Let's warn the user and unload it.
3061
3062 if (withInfo) {
3063 ::Info("ACLiC","script has already been loaded in interpreted mode");
3064 ::Info("ACLiC","unloading %s and compiling it", filename);
3065 }
3066
3067 if ( gInterpreter->UnloadFile( expFileName ) != 0 ) {
3068 // We can not unload it.
3069 return kFALSE;
3070 }
3071 }
3072
3073 // Calculate the -I lines
3075 includes.ReplaceAll("-I ", "-I");
3076 includes.Prepend(' ');
3077
3078 {
3079 // I need to replace the -Isomerelativepath by -I../ (or -I..\ on NT)
3080 TRegexp rel_inc(" -I[^\"/\\\\$\\%-][^:\\s]+");
3081 Int_t len,pos;
3082 pos = rel_inc.Index(includes,&len);
3083 while( len != 0 ) {
3084 TString sub = includes(pos,len);
3085 sub.Remove(0,3); // Remove ' -I'
3087 sub.Prepend(" -I\"");
3088 if (sub.EndsWith(" "))
3089 sub.Chop(); // Remove trailing space (i.e between the -Is ...
3090 sub.Append("\" ");
3091 includes.Replace(pos,len,sub);
3092 pos = rel_inc.Index(includes,&len);
3093 }
3094 }
3095 {
3096 // I need to replace the -I"somerelativepath" by -I"$cwd/ (or -I"$cwd\ on NT)
3097 TRegexp rel_inc(" -I\"[^/\\\\$\\%-][^:\\s]+");
3098 Int_t len,pos;
3099 pos = rel_inc.Index(includes,&len);
3100 while( len != 0 ) {
3101 TString sub = includes(pos,len);
3102 sub.Remove(0,4); // Remove ' -I"'
3104 sub.Prepend(" -I\"");
3105 includes.Replace(pos,len,sub);
3106 pos = rel_inc.Index(includes,&len);
3107 }
3108 }
3109 //includes += " -I\"" + build_loc;
3110 //includes += "\" -I\"";
3111 //includes += WorkingDirectory();
3112// if (includes[includes.Length()-1] == '\\') {
3113// // The current directory is (most likely) the root of a windows drive and
3114// // has a trailing \ which would espace the quote if left by itself.
3115// includes += '\\';
3116// }
3117// includes += "\"";
3118 if (gEnv) {
3119 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3120 includes.Append(" ").Append(fromConfig).Append(" ");
3121 }
3122
3123 // Extract the -D for the dependency generation.
3124 TString defines = " ";
3125 {
3127 TRegexp rel_def("-D[^\\s\\t\\n\\r]*");
3128 Int_t len,pos;
3129 pos = rel_def.Index(cmd,&len);
3130 while( len != 0 ) {
3131 defines += cmd(pos,len);
3132 defines += " ";
3133 pos = rel_def.Index(cmd,&len,pos+1);
3134 }
3135
3136 }
3137
3139 {
3141 if (ug) {
3143 delete ug;
3144 } else {
3146 }
3147 }
3148
3150
3152
3153 // Generate the dependency filename
3157 depfilename += "_" + extension + ".d";
3158
3159 if ( !recompile ) {
3160
3162
3163 if ((gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) != 0) ||
3164 (gSystem->GetPathInfo( expFileName, nullptr, (Long_t*)nullptr, nullptr, &file_time ) == 0 &&
3165 (lib_time < file_time))) {
3166
3167 // the library does not exist or is older than the script.
3168 recompile = kTRUE;
3169 modified = kTRUE;
3170
3171 } else {
3172
3173 if ( gSystem->GetPathInfo( depfilename, nullptr,(Long_t*) nullptr, nullptr, &file_time ) != 0 ) {
3174 if (!canWrite) {
3177 depfilename += "_" + extension + ".d";
3178 }
3180 }
3181 }
3182
3183 if (!modified) {
3184
3185 // We need to check the dependencies
3186 FILE * depfile = fopen(depfilename.Data(),"r");
3187 if (depfile==nullptr) {
3188 // there is no accessible dependency file, let's assume the library has been
3189 // modified
3190 modified = kTRUE;
3191 recompile = kTRUE;
3192
3193 } else {
3194
3196
3197 Int_t sz = 256;
3198 char *line = new char[sz];
3199 line[0] = 0;
3200
3201 int c;
3202 Int_t current = 0;
3203 Int_t nested = 0;
3204 Bool_t hasversion = false;
3205
3206 while ((c = fgetc(depfile)) != EOF) {
3207 if (c=='#') {
3208 // skip comment
3209 while ((c = fgetc(depfile)) != EOF) {
3210 if (c=='\n') {
3211 break;
3212 }
3213 }
3214 continue;
3215 }
3216 if (current && line[current-1]=='=' && strncmp(version_var.Data(),line,current)==0) {
3217
3218 // The next word will be the version number.
3219 hasversion = kTRUE;
3220 line[0] = 0;
3221 current = 0;
3222 } else if (isspace(c) && !nested) {
3223 if (current) {
3224 if (line[current-1]!=':') {
3225 // ignore target
3226 line[current] = 0;
3227
3229 if (hasversion) {
3232 } else if ( gSystem->GetPathInfo( line, nullptr, (Long_t*)nullptr, nullptr, &filetime ) == 0 ) {
3233 modified |= ( lib_time <= filetime );
3234 }
3235 }
3236 }
3237 current = 0;
3238 line[0] = 0;
3239 } else {
3240 if (current==sz-1) {
3241 sz = 2*sz;
3242 char *newline = new char[sz];
3243 memcpy(newline,line, current);
3244 delete [] line;
3245 line = newline;
3246 }
3247 if (c=='"') nested = !nested;
3248 else {
3249 line[current] = c;
3250 current++;
3251 }
3252 }
3253 }
3254 delete [] line;
3255 fclose(depfile);
3257
3258 }
3259
3260 }
3261 }
3262
3263 if ( gInterpreter->IsLibraryLoaded(library)
3264 || strlen(GetLibraries(library,"D",kFALSE)) != 0 ) {
3265 // The library has already been built and loaded.
3266
3267 Bool_t reload = kFALSE;
3269 if (libinfo) {
3270 Long_t load_time = libinfo->GetUniqueID();
3272 if ( gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time ) == 0
3273 && (lib_time>load_time)) {
3274 reload = kTRUE;
3275 }
3276 }
3277
3278 if ( !recompile && reload ) {
3279
3280 if (withInfo) {
3281 ::Info("ACLiC","%s has been modified and will be reloaded",
3282 libname.Data());
3283 }
3284 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3285 // The library is being used. We can not unload it.
3286 return kFALSE;
3287 }
3288 if (libinfo) {
3290 delete libinfo;
3291 libinfo = nullptr;
3292 }
3293 TNamed *k = new TNamed(library,library);
3295 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3297 if (!keep) k->SetBit(kMustCleanup);
3298 fCompiled->Add(k);
3299
3300 return !gSystem->Load(library);
3301 }
3302
3303 if (withInfo) {
3304 ::Info("ACLiC","%s script has already been compiled and loaded",
3305 modified ? "modified" : "unmodified");
3306 }
3307
3308 if ( !recompile ) {
3309 return kTRUE;
3310 } else {
3311 if (withInfo) {
3312 ::Info("ACLiC","it will be regenerated and reloaded!");
3313 }
3314 if ( gInterpreter->UnloadFile( library.Data() ) != 0 ) {
3315 // The library is being used. We can not unload it.
3316 return kFALSE;
3317 }
3318 if (libinfo) {
3320 delete libinfo;
3321 libinfo = nullptr;
3322 }
3323 Unlink(library);
3324 }
3325
3326 }
3327
3330 libmapfilename += ".rootmap";
3331#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5)) || defined(R__WIN32)
3333#else
3335#endif
3337 if (gEnv) {
3338#if (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5))
3339 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",2);
3340#elif defined(R__WIN32)
3341 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",3);
3342#else
3343 Int_t linkLibs = gEnv->GetValue("ACLiC.LinkLibs",1);
3344#endif
3345 produceRootmap = linkLibs & 0x2;
3346 linkDepLibraries = linkLibs & 0x1;
3347 }
3348
3349 // FIXME: Triggers clang false positive warning -Wunused-lambda-capture.
3350 /*constexpr const*/ bool useCxxModules =
3351#ifdef R__USE_CXXMODULES
3352 true;
3353#else
3354 false;
3355#endif
3356
3357 // FIXME: Switch to generic polymorphic when we make c++14 default.
3358 auto ForeachSharedLibDep = [](const char *lib, std::function<bool(const char *)> f) {
3359 using std::string, std::vector, std::istringstream, std::istream_iterator;
3360 string deps = gInterpreter->GetSharedLibDeps(lib, /*tryDyld*/ true);
3361 istringstream iss(deps);
3363 // Skip the first element: it is a relative path to `lib`.
3364 for (auto I = libs.begin() + 1, E = libs.end(); I != E; ++I)
3365 if (!f(I->c_str()))
3366 break;
3367 };
3369 // We have no rootmap files or modules to construct `-l` flags enabling
3370 // explicit linking. We have to resolve the dependencies by ourselves
3371 // taking the job of the dyld.
3372 // FIXME: This is a rare case where we have rootcling running with
3373 // modules disabled. Remove this code once we fully switch to modules,
3374 // or implement a special flag in rootcling which selective enables
3375 // modules for dependent libraries and does not produce a module for
3376 // the ACLiC library.
3377 if (useCxxModules && !produceRootmap) {
3378 std::function<bool(const char *)> LoadLibF = [](const char *dep) {
3379 return gInterpreter->Load(dep, /*skipReload*/ true) >= 0;
3380 };
3382 }
3383 return !gSystem->Load(lib);
3384 };
3385
3386 if (!recompile) {
3387 // The library already exist, let's just load it.
3388 if (loadLib) {
3389 TNamed *k = new TNamed(library,library);
3391 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3393 if (!keep) k->SetBit(kMustCleanup);
3394 fCompiled->Add(k);
3395
3396 gInterpreter->GetSharedLibDeps(library);
3397
3398 return LoadLibrary(library);
3399 }
3400 else return kTRUE;
3401 }
3402
3403 if (!canWrite && recompile) {
3404
3405 if (mkdirFailed) {
3406 ::Warning("ACLiC","Could not create the directory: %s",
3407 build_loc.Data());
3408 } else {
3409 ::Warning("ACLiC","%s is not writable!",
3410 build_loc.Data());
3411 }
3412 if (emergency_loc == build_dir ) {
3413 ::Error("ACLiC","%s is the last resort location (i.e. temp location)",build_loc.Data());
3414 return kFALSE;
3415 }
3416 ::Warning("ACLiC","Output will be written to %s",
3417 emergency_loc.Data());
3419 }
3420
3421 if (withInfo) {
3422 Info("ACLiC","creating shared library %s",library.Data());
3423 }
3424
3426
3427 // ======= Select the dictionary name
3428 TString dict = libname + "_ACLiC_dict";
3429
3430 // the file name end up in the file produced
3431 // by rootcling as a variable name so all character need to be valid!
3432 static const int maxforbidden = 27;
3433 static const char *forbidden_chars[maxforbidden] =
3434 { "+","-","*","/","&","%","|","^",">","<",
3435 "=","~",".","(",")","[","]","!",",","$",
3436 " ",":","'","#","@","\\","\"" };
3437 for( int ic = 0; ic < maxforbidden; ic++ ) {
3438 dict.ReplaceAll( forbidden_chars[ic],"_" );
3439 }
3440 if ( dict.Last('.')!=dict.Length()-1 ) dict.Append(".");
3441 AssignAndDelete( dict, ConcatFileName( build_loc, dict ) );
3442 TString dicth = dict;
3443 TString dictObj = dict;
3444 dict += "cxx"; //no need to keep the extension of the original file, any extension will do
3445 dicth += "h";
3446 dictObj += fObjExt;
3447
3448 // ======= Generate a linkdef file
3449
3452 linkdef += "_ACLiC_linkdef.h";
3453 std::ofstream linkdefFile( linkdef, std::ios::out );
3454 linkdefFile << "// File Automatically generated by the ROOT Script Compiler "
3455 << std::endl;
3456 linkdefFile << std::endl;
3457 linkdefFile << "#ifdef __CINT__" << std::endl;
3458 linkdefFile << std::endl;
3459 linkdefFile << "#pragma link C++ nestedclasses;" << std::endl;
3460 linkdefFile << "#pragma link C++ nestedtypedefs;" << std::endl;
3461 linkdefFile << std::endl;
3462
3463 // We want to look for a header file that has the same name as the macro
3464
3465 const char * extensions[] = { ".h", ".hh", ".hpp", ".hxx", ".hPP", ".hXX" };
3466
3467 int i;
3468 for (i = 0; i < 6; i++ ) {
3469 char * name;
3472 extra_linkdef.Append(extensions[i]);
3474 if (name) {
3475 if (verboseLevel>4 && withInfo) {
3476 Info("ACLiC","including extra linkdef file: %s",name);
3477 }
3478 linkdefFile << "#include \"" << name << "\"" << std::endl;
3479 delete [] name;
3480 }
3481 }
3482
3483 if (verboseLevel>5 && withInfo) {
3484 Info("ACLiC","looking for header in: %s",incPath.Data());
3485 }
3486 for (i = 0; i < 6; i++ ) {
3487 char * name;
3488 TString lookup = BaseName( libname_noext );
3489 lookup.Append(extensions[i]);
3490 name = Which(incPath,lookup);
3491 if (name) {
3492 linkdefFile << "#pragma link C++ defined_in "<<gSystem->UnixPathName(name)<<";"<< std::endl;
3493 delete [] name;
3494 }
3495 }
3496 linkdefFile << "#pragma link C++ defined_in \""<<filename_fullpath << "\";" << std::endl;
3497 linkdefFile << std::endl;
3498 linkdefFile << "#endif" << std::endl;
3499 linkdefFile.close();
3500 // ======= Generate the list of rootmap files to be looked at
3501
3504 mapfile += "_ACLiC_map";
3505 TString mapfilein = mapfile + ".in";
3506 TString mapfileout = mapfile + ".out";
3507
3509 if (!useCxxModules) {
3510 if (gInterpreter->GetSharedLibDeps(library) != nullptr) {
3511 gInterpreter->UnloadLibraryMap(libname);
3513 }
3514 }
3515
3516 std::ofstream mapfileStream( mapfilein, std::ios::out );
3517 {
3518 TString name = ".rootmap";
3519 TString sname = "system.rootmap";
3520 TString file;
3522 if (gSystem->AccessPathName(file)) {
3523 // for backward compatibility check also $ROOTSYS/system<name> if
3524 // $ROOTSYS/etc/system<name> does not exist
3526 if (gSystem->AccessPathName(file)) {
3527 // for backward compatibility check also $ROOTSYS/<name> if
3528 // $ROOTSYS/system<name> does not exist
3530 }
3531 }
3532 mapfileStream << file << std::endl;
3534 mapfileStream << file << std::endl;
3535 mapfileStream << name << std::endl;
3536 if (gInterpreter->GetRootMapFiles()) {
3537 for (i = 0; i < gInterpreter->GetRootMapFiles()->GetEntriesFast(); i++) {
3538 mapfileStream << ((TNamed*)gInterpreter->GetRootMapFiles()->At(i))->GetTitle() << std::endl;
3539 }
3540 }
3541 }
3542 mapfileStream.close();
3543
3544 // ======= Generate the rootcling command line
3545 TString rcling = "rootcling";
3547 rcling += " \"--lib-list-prefix=";
3548 rcling += mapfile;
3549 rcling += "\" -f \"";
3550 rcling.Append(dict).Append("\" ");
3551
3552 if (produceRootmap && !useCxxModules) {
3553 rcling += " -rml " + libname + " -rmf \"" + libmapfilename + "\" ";
3554 rcling.Append("-DR__ACLIC_ROOTMAP ");
3555 }
3556 rcling.Append(GetIncludePath()).Append(" -D__ACLIC__ ");
3557 if (gEnv) {
3558 TString fromConfig = gEnv->GetValue("ACLiC.IncludePaths","");
3559 rcling.Append(fromConfig);
3560 TString extraFlags = gEnv->GetValue("ACLiC.ExtraRootclingFlags","");
3561 if (!extraFlags.IsNull()) {
3562 extraFlags.Prepend(" ");
3563 extraFlags.Append(" ");
3564 rcling.Append(extraFlags);
3565 }
3566 }
3567
3568 // Create a modulemap
3569 // FIXME: Merge the modulemap generation from cmake and here in rootcling.
3571 rcling += " -cxxmodule ";
3572 // TString moduleMapFileName = file_dirname + "/" + libname + ".modulemap";
3573 TString moduleName = libname + "_ACLiC_dict";
3574 if (moduleName.BeginsWith("lib"))
3575 moduleName = moduleName.Remove(0, 3);
3576 TString moduleMapName = moduleName + ".modulemap";
3578 // A modulemap may exist from previous runs, overwrite it.
3580 ::Info("ACLiC", "File %s already exists!", moduleMapFullPath.Data());
3581
3584 std::ofstream moduleMapFile(moduleMapFullPath, std::ios::out);
3585 moduleMapFile << "module \"" << moduleName << "\" {" << std::endl;
3586 moduleMapFile << " header \"" << relative_path << "\"" << std::endl;
3587 moduleMapFile << " export *" << std::endl;
3588 moduleMapFile << " link \"" << libname_ext << "\"" << std::endl;
3589 moduleMapFile << "}" << std::endl;
3590 moduleMapFile.close();
3591 gInterpreter->RegisterPrebuiltModulePath(build_loc.Data(), moduleMapName.Data());
3592 rcling.Append(" \"-moduleMapFile=" + moduleMapFullPath + "\" ");
3593 }
3594
3595 rcling.Append(" \"").Append(filename_fullpath).Append("\" ");
3596 rcling.Append("\"").Append(linkdef).Append("\"");
3597
3598 // ======= Run rootcling
3599 if (withInfo) {
3600 if (verboseLevel>3) {
3601 ::Info("ACLiC","creating the dictionary files");
3602 if (verboseLevel>4) ::Info("ACLiC", "%s", rcling.Data());
3603 }
3604 }
3605
3606 ///\returns true on success.
3607 auto ExecAndReport = [](TString cmd) -> bool {
3609 if (result) {
3610 if (result == 139)
3611 ::Error("ACLiC", "Executing '%s' failed with a core dump!", cmd.Data());
3612 else
3613 ::Error("ACLiC", "Executing '%s' failed!", cmd.Data());
3614 }
3615 return !result;
3616 };
3617
3620
3621 // ======= Load the library the script might depend on
3622 if (result) {
3623 TString linkedlibs = GetLibraries("", "S");
3626 std::ifstream liblist(mapfileout);
3627
3628 while ( liblist >> libtoload ) {
3629 // Load the needed library except for the library we are currently building!
3630 if (libtoload == "#") {
3631 // The comment terminates the list of libraries.
3632 std::string toskipcomment;
3633 std::getline(liblist,toskipcomment);
3634 break;
3635 }
3637 if (produceRootmap) {
3638 if (loadLib || linkDepLibraries /* For GetLibraries to Work */) {
3639 result = gROOT->LoadClass("", libtoload) >= 0;
3640 if (!result) {
3641 // We failed to load one of the dependency.
3642 break;
3643 }
3644 }
3645 if (!linkedlibs.Contains(libtoload)) {
3646 all_libtoload.Append(" ").Append(libtoload);
3647 depLibraries.Append(" ");
3649 depLibraries = depLibraries.Strip(); // Remove any trailing spaces.
3650 }
3651 } else {
3652 gROOT->LoadClass("", libtoload);
3653 }
3654 }
3655 unsigned char c = liblist.peek();
3656 if (c=='\n' || c=='\r') {
3657 // Consume the character
3658 liblist.get();
3659 break;
3660 }
3661 }
3662
3663// depLibraries = all_libtoload;
3664// depLibraries.ReplaceAll(" lib"," -l");
3665// depLibraries.ReplaceAll(TString::Format(".%s",fSoExt.Data()),"");
3666 }
3667
3668 // ======= Calculate the libraries for linking:
3670 /*
3671 this is intentionally disabled until it can become useful
3672 if (gEnv) {
3673 linkLibraries = gEnv->GetValue("ACLiC.Libraries","");
3674 linkLibraries.Prepend(" ");
3675 }
3676 */
3678 // We need to enclose the single paths in quotes to account for paths with spaces
3682 std::unique_ptr<TObjArray> tokens( linkLibrariesNoQuotes.Tokenize(" ") );
3683 for (auto tokenObj : *tokens) {
3684 singleLibrary = ((TObjString*)tokenObj)->GetString();
3685 if (singleLibrary[0]=='-' || !AccessPathName(singleLibrary)) {
3687 librariesWithQuotes.Chop();
3688 librariesWithQuotes += "\" \"" + singleLibrary + "\"";
3690 } else {
3691 librariesWithQuotes += " \"" + singleLibrary + "\"";
3692 }
3693 } else {
3696 } else {
3698 librariesWithQuotes += " \"" + singleLibrary + " ";
3699 }
3700 }
3701 }
3702
3703#ifdef _MSC_VER
3705#else
3707#endif
3708
3709 // ======= Generate the build command lines
3711 // we do not add filename because it is already included via the dictionary(in dicth) !
3712 // dict.Append(" ").Append(filename);
3713 cmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3714 cmd.ReplaceAll("$SourceFiles",dict);
3715 cmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3716 cmd.ReplaceAll("$ObjectFiles",dictObj);
3717 cmd.ReplaceAll("$IncludePath",includes);
3718 cmd.ReplaceAll("$SharedLib","\"$SharedLib\"");
3719 cmd.ReplaceAll("$SharedLib",library);
3720 if (linkDepLibraries) {
3721 if (produceRootmap) {
3722 cmd.ReplaceAll("$DepLibs",depLibraries);
3723 } else {
3724 cmd.ReplaceAll("$DepLibs",linkLibraries);
3725 }
3726 }
3727 cmd.ReplaceAll("$LinkedLibs",linkLibraries);
3728 cmd.ReplaceAll("$LibName",libname);
3729 cmd.ReplaceAll("\"$BuildDir","$BuildDir");
3730 cmd.ReplaceAll("$BuildDir","\"$BuildDir\"");
3731 cmd.ReplaceAll("$BuildDir",build_loc);
3733 if (mode & kDebug)
3734 optdebFlags = fFlagsDebug + " ";
3735 if (mode & kOpt)
3737 cmd.ReplaceAll("$Opt", optdebFlags);
3738#ifdef WIN32
3739 R__FixLink(cmd);
3740 cmd.ReplaceAll("-std=", "-std:");
3741#endif
3742
3746 fakeMain += "_ACLiC_main";
3748 std::ofstream fakeMainFile( fakeMain, std::ios::out );
3749 fakeMainFile << "// File Automatically generated by the ROOT Script Compiler "
3750 << std::endl;
3751 fakeMainFile << "int main(char*argc,char**argvv) {};" << std::endl;
3752 fakeMainFile.close();
3753 // We could append this fake main routine to the compilation line.
3754 // But in this case compiler may output the name of the dictionary file
3755 // and of the fakeMain file while it compiles it. (this would be useless
3756 // confusing output).
3757 // We could also the fake main routine to the end of the dictionary file
3758 // however compilation would fail if a main is already there
3759 // (like stress.cxx)
3760 // dict.Append(" ").Append(fakeMain);
3761 TString exec;
3763 exec += "_ACLiC_exec";
3764 testcmd.ReplaceAll("$SourceFiles","-D__ACLIC__ \"$SourceFiles\"");
3765 testcmd.ReplaceAll("$SourceFiles",dict);
3766 testcmd.ReplaceAll("$ObjectFiles","\"$ObjectFiles\"");
3767 testcmd.ReplaceAll("$ObjectFiles",dictObj);
3768 testcmd.ReplaceAll("$IncludePath",includes);
3769 testcmd.ReplaceAll("$ExeName",exec);
3770 testcmd.ReplaceAll("$LinkedLibs",linkLibraries);
3771 testcmd.ReplaceAll("$BuildDir",build_loc);
3772 if (mode==kDebug)
3773 testcmd.ReplaceAll("$Opt",fFlagsDebug);
3774 else
3775 testcmd.ReplaceAll("$Opt",fFlagsOpt);
3776
3777#ifdef WIN32
3779 testcmd.ReplaceAll("-std=", "-std:");
3780#endif
3781
3782 // ======= Build the library
3783 if (result) {
3785#ifdef R__MACOSX
3786 // Allow linking to succeed despite the missing symbols.
3787 cmdAllowUnresolved.ReplaceAll("-dynamiclib", "-dynamiclib -Wl,-w -Wl,-undefined,dynamic_lookup");
3788#endif
3789 if (verboseLevel > 3 && withInfo) {
3790 ::Info("ACLiC","compiling the dictionary and script files");
3791 if (verboseLevel>4)
3792 ::Info("ACLiC", "%s", cmdAllowUnresolved.Data());
3793 }
3795 if (!success) {
3796 if (produceRootmap) {
3798 }
3799 }
3800 result = success;
3801 }
3802
3803 if ( result ) {
3804 if (linkDepLibraries) {
3805 // We may have unresolved symbols. Use dyld to resolve the dependent
3806 // libraries and relink.
3807 // FIXME: We will likely have duplicated libraries as we are appending
3808 // FIXME: This likely makes rootcling --lib-list-prefix redundant.
3810 std::function<bool(const char *)> CollectF = [&depLibsFullPaths](const char *dep) {
3812 if (!gSystem->FindDynamicLibrary(LibFullPath, /*quiet=*/true)) {
3813 ::Error("TSystem::CompileMacro", "Cannot find library '%s'", dep);
3814 return false; // abort
3815 }
3817 return true;
3818 };
3820
3823 if (verboseLevel > 3 && withInfo) {
3824 ::Info("ACLiC", "relinking against all dependencies");
3825 if (verboseLevel > 4)
3826 ::Info("ACLiC", "%s", relink_cmd.Data());
3827 }
3829 }
3830
3831 TNamed *k = new TNamed(library,library);
3833 gSystem->GetPathInfo( library, nullptr, (Long_t*)nullptr, nullptr, &lib_time );
3835 if (!keep) k->SetBit(kMustCleanup);
3836 fCompiled->Add(k);
3837
3838 if (needLoadMap) {
3839 gInterpreter->LoadLibraryMap(libmapfilename);
3840 }
3841 if (verboseLevel>3 && withInfo) ::Info("ACLiC","loading the shared library");
3842 if (loadLib)
3844 else
3845 result = kTRUE;
3846
3847 if ( !result ) {
3848 if (verboseLevel>3 && withInfo) {
3849 ::Info("ACLiC","testing for missing symbols:");
3850 if (verboseLevel>4) ::Info("ACLiC", "%s", testcmd.Data());
3851 }
3853 gSystem->Unlink( exec );
3854 }
3855
3856 };
3857
3858 if (verboseLevel<=5 && !internalDebug) {
3859 gSystem->Unlink( dict );
3860 gSystem->Unlink( dicth );
3866 gSystem->Unlink( exec );
3867 }
3868 if (verboseLevel>6) {
3869 rcling.Prepend("echo ");
3870 cmd.Prepend("echo \" ").Append(" \" ");
3871 testcmd.Prepend("echo \" ").Append(" \" ");
3873 gSystem->Exec( cmd );
3875 }
3876
3877 return result;
3878}
3879
3880////////////////////////////////////////////////////////////////////////////////
3881/// Return the ACLiC properties field. See EAclicProperties for details
3882/// on the semantic of each bit.
3883
3885{
3886 return fAclicProperties;
3887}
3888
3889////////////////////////////////////////////////////////////////////////////////
3890/// Return the build architecture.
3891
3892const char *TSystem::GetBuildArch() const
3893{
3894 return fBuildArch;
3895}
3896
3897////////////////////////////////////////////////////////////////////////////////
3898/// Return the build compiler
3899
3900const char *TSystem::GetBuildCompiler() const
3901{
3902 return fBuildCompiler;
3903}
3904
3905////////////////////////////////////////////////////////////////////////////////
3906/// Return the build compiler version
3907
3909{
3910 return fBuildCompilerVersion;
3911}
3912
3913////////////////////////////////////////////////////////////////////////////////
3914/// Return the build compiler version identifier string
3915
3917{
3919}
3920
3921////////////////////////////////////////////////////////////////////////////////
3922/// Return the build node name.
3923
3924const char *TSystem::GetBuildNode() const
3925{
3926 return fBuildNode;
3927}
3928
3929////////////////////////////////////////////////////////////////////////////////
3930/// Return the path of the build directory.
3931
3932const char *TSystem::GetBuildDir() const
3933{
3934 if (fBuildDir.Length()==0) {
3935 if (!gEnv) return "";
3936 const_cast<TSystem*>(this)->fBuildDir = gEnv->GetValue("ACLiC.BuildDir","");
3937 }
3938 return fBuildDir;
3939}
3940
3941////////////////////////////////////////////////////////////////////////////////
3942/// Return the debug flags.
3943
3944const char *TSystem::GetFlagsDebug() const
3945{
3946 return fFlagsDebug;
3947}
3948
3949////////////////////////////////////////////////////////////////////////////////
3950/// Return the optimization flags.
3951
3952const char *TSystem::GetFlagsOpt() const
3953{
3954 return fFlagsOpt;
3955}
3956
3957////////////////////////////////////////////////////////////////////////////////
3958/// AclicMode indicates whether the library should be built in
3959/// debug mode or optimized. The values are:
3960/// - TSystem::kDefault : compile the same as the current ROOT
3961/// - TSystem::kDebug : compiled in debug mode
3962/// - TSystem::kOpt : optimized the library
3963
3968
3969////////////////////////////////////////////////////////////////////////////////
3970/// Return the command line use to make a shared library.
3971/// See TSystem::CompileMacro for more details.
3972
3973const char *TSystem::GetMakeSharedLib() const
3974{
3975 return fMakeSharedLib;
3976}
3977
3978////////////////////////////////////////////////////////////////////////////////
3979/// Return the command line use to make an executable.
3980/// See TSystem::CompileMacro for more details.
3981
3982const char *TSystem::GetMakeExe() const
3983{
3984 return fMakeExe;
3985}
3986
3987////////////////////////////////////////////////////////////////////////////////
3988/// Get the list of include path.
3989
3991{
3993#ifndef _MSC_VER
3994 // FIXME: This is a temporary fix for the following error with ACLiC
3995 // (and this is apparently not needed anyway):
3996 // 48: input_line_12:8:38: error: use of undeclared identifier 'IC'
3997 // 48: "C:/Users/bellenot/build/debug/etc" -IC:/Users/bellenot/build/debug/etc//cling -IC:/Users/bellenot/build/debug/include"",
3998 // 48: ^
3999 // 48: Error in <ACLiC>: Dictionary generation failed!
4000 fListPaths.Append(" ").Append(gInterpreter->GetIncludePath());
4001#endif
4002 return fListPaths;
4003}
4004
4005////////////////////////////////////////////////////////////////////////////////
4006/// Return the list of library linked to this executable.
4007/// See TSystem::CompileMacro for more details.
4008
4009const char *TSystem::GetLinkedLibs() const
4010{
4011 return fLinkedLibs;
4012}
4013
4014////////////////////////////////////////////////////////////////////////////////
4015/// Return the linkdef suffix chosen by the user for ACLiC.
4016/// See TSystem::CompileMacro for more details.
4017
4018const char *TSystem::GetLinkdefSuffix() const
4019{
4020 if (fLinkdefSuffix.Length()==0) {
4021 if (!gEnv) return "_linkdef";
4022 const_cast<TSystem*>(this)->fLinkdefSuffix = gEnv->GetValue("ACLiC.Linkdef","_linkdef");
4023 }
4024 return fLinkdefSuffix;
4025}
4026
4027////////////////////////////////////////////////////////////////////////////////
4028/// Get the shared library extension.
4029
4030const char *TSystem::GetSoExt() const
4031{
4032 return fSoExt;
4033}
4034
4035////////////////////////////////////////////////////////////////////////////////
4036/// Get the object file extension.
4037
4038const char *TSystem::GetObjExt() const
4039{
4040 return fObjExt;
4041}
4042
4043////////////////////////////////////////////////////////////////////////////////
4044/// Set the location where ACLiC will create libraries and use as
4045/// a scratch area. If unset, libraries will be created at the same
4046/// location than the script.
4047///
4048/// \param build_dir the name of the build directory
4049/// \param isflat If false (default), then the libraries are actually stored
4050/// in sub-directories of 'build_dir' including the full pathname
4051/// of the script. If the script is located at `/full/path/name/macro.C`
4052/// the library will be located at `build_dir+/full/path/name/macro_C.so`
4053/// If 'isflat' is true, then no subdirectory is created and the library
4054/// is created directly in the directory 'build_dir'. Note that in this
4055/// mode there is a risk than 2 script of the same in different source
4056/// directory will over-write each other.
4057/// \note This `build_dir` can also be controlled via `ACLiC.BuildDir` in
4058/// your `.rootrc`.
4059
4061{
4063 if (isflat)
4065 else
4067}
4068
4069////////////////////////////////////////////////////////////////////////////////
4070/// FlagsDebug should contain the options to pass to the C++ compiler
4071/// in order to compile the library in debug mode.
4072
4073void TSystem::SetFlagsDebug(const char *flags)
4074{
4075 fFlagsDebug = flags;
4076}
4077
4078////////////////////////////////////////////////////////////////////////////////
4079/// FlagsOpt should contain the options to pass to the C++ compiler
4080/// in order to compile the library in optimized mode.
4081
4082void TSystem::SetFlagsOpt(const char *flags)
4083{
4084 fFlagsOpt = flags;
4085}
4086
4087////////////////////////////////////////////////////////////////////////////////
4088/// AclicMode indicates whether the library should be built in
4089/// debug mode or optimized. The values are:
4090/// - TSystem::kDefault : compile the same as the current ROOT
4091/// - TSystem::kDebug : compiled in debug mode
4092/// - TSystem::kOpt : optimized the library
4093
4098
4099////////////////////////////////////////////////////////////////////////////////
4100/// Directives has the same syntax as the argument of SetMakeSharedLib but is
4101/// used to create an executable. This creation is used as a means to output
4102/// a list of unresolved symbols, when loading a shared library has failed.
4103/// The required variable is $ExeName rather than $SharedLib, e.g.:
4104/// ~~~ {.cpp}
4105/// gSystem->SetMakeExe(
4106/// "g++ -Wall -fPIC $IncludePath $SourceFiles
4107/// -o $ExeName $LinkedLibs -L/usr/X11R6/lib -lX11 -lm -ldl -rdynamic");
4108/// ~~~
4109
4111{
4113 // NOTE: add verification that the directives has the required variables
4114}
4115
4116////////////////////////////////////////////////////////////////////////////////
4117/// Directives should contain the description on how to compile and link a
4118/// shared lib. This description can be any valid shell command, including
4119/// the use of ';' to separate several instructions. However, shell specific
4120/// construct should be avoided. In particular this description can contain
4121/// environment variables, like $ROOTSYS (or %ROOTSYS% on windows).
4122/// ~~~ {.cpp}
4123/// Five special variables will be expanded before execution:
4124/// Variable name Expands to
4125/// ------------- ----------
4126/// $SourceFiles Name of source files to be compiled
4127/// $SharedLib Name of the shared library being created
4128/// $LibName Name of shared library without extension
4129/// $BuildDir Directory where the files will be created
4130/// $IncludePath value of fIncludePath
4131/// $LinkedLibs value of fLinkedLibs
4132/// $DepLibs libraries on which this library depends on
4133/// $ObjectFiles Name of source files to be compiler with
4134/// their extension changed to .o or .obj
4135/// $Opt location of the optimization/debug options
4136/// set fFlagsDebug and fFlagsOpt
4137/// ~~~
4138/// e.g.:
4139/// ~~~ {.cpp}
4140/// gSystem->SetMakeSharedLib(
4141/// "KCC -n32 --strict $IncludePath -K0 \$Opt $SourceFile
4142/// --no_exceptions --signed_chars --display_error_number
4143/// --diag_suppress 68 -o $SharedLib");
4144///
4145/// gSystem->setMakeSharedLib(
4146/// "Cxx $IncludePath -c $SourceFile;
4147/// ld -L/usr/lib/cmplrs/cxx -rpath /usr/lib/cmplrs/cxx -expect_unresolved
4148/// \$Opt -shared /usr/lib/cmplrs/cc/crt0.o /usr/lib/cmplrs/cxx/_main.o
4149/// -o $SharedLib $ObjectFile -lcxxstd -lcxx -lexc -lots -lc"
4150///
4151/// gSystem->SetMakeSharedLib(
4152/// "$HOME/mygcc/bin/g++ \$Opt -Wall -fPIC $IncludePath $SourceFile
4153/// -shared -o $SharedLib");
4154///
4155/// gSystem->SetMakeSharedLib(
4156/// "cl -DWIN32 -D_WIN32 -D_MT -D_DLL -MD /O2 /G5 /MD -DWIN32
4157/// -D_WINDOWS $IncludePath $SourceFile
4158/// /link -PDB:NONE /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO
4159/// $LinkedLibs -entry:_DllMainCRTStartup@12 -dll /out:$SharedLib")
4160/// ~~~
4161
4163{
4165 // NOTE: add verification that the directives has the required variables
4166}
4167
4168////////////////////////////////////////////////////////////////////////////////
4169/// \brief Add a directory to the already set include path.
4170/// \param[in] includePath The path to the directory.
4171/// \note This interface is mostly relevant for ACLiC and it does *not* inform
4172/// gInterpreter for this include path. If the TInterpreter needs to know
4173/// about the include path please use TInterpreter::AddIncludePath() .
4174/// \warning The path should start with the \c -I prefix, i.e.
4175/// <tt>gSystem->AddIncludePath("-I /path/to/my/includes")</tt>.
4177{
4178 if (includePath) {
4179 fIncludePath += " ";
4181 }
4182}
4183
4184////////////////////////////////////////////////////////////////////////////////
4185/// Add linkedLib to already set linked libs.
4186
4188{
4189 if (linkedLib) {
4190 fLinkedLibs += " ";
4192 }
4193}
4194
4195////////////////////////////////////////////////////////////////////////////////
4196/// IncludePath should contain the list of compiler flags to indicate where
4197/// to find user defined header files. It is used to expand $IncludePath in
4198/// the directives given to SetMakeSharedLib() and SetMakeExe(), e.g.:
4199/// ~~~ {.cpp}
4200/// gSystem->SetInclude("-I$ROOTSYS/include -Imydirectory/include");
4201/// ~~~
4202/// the default value of IncludePath on Unix is:
4203/// ~~~ {.cpp}
4204/// "-I$ROOTSYS/include "
4205/// ~~~
4206/// and on Windows:
4207/// ~~~ {.cpp}
4208/// "/I%ROOTSYS%/include "
4209/// ~~~
4210
4212{
4214}
4215
4216////////////////////////////////////////////////////////////////////////////////
4217/// LinkedLibs should contain the library directory and list of libraries
4218/// needed to recreate the current executable. It is used to expand $LinkedLibs
4219/// in the directives given to SetMakeSharedLib() and SetMakeExe()
4220/// The default value on Unix is: `root-config --glibs`
4221
4223{
4225}
4226
4227////////////////////////////////////////////////////////////////////////////////
4228/// The 'suffix' will be appended to the name of a script loaded by ACLiC
4229/// and used to locate any eventual additional linkdef information that
4230/// ACLiC should used to produce the dictionary.
4231///
4232/// So by default, when doing .L MyScript.cxx, ACLiC will look
4233/// for a file name MyScript_linkdef and having one of the .h (.hpp,
4234/// etc.) extensions. If such a file exist, it will be added to
4235/// the end of the linkdef file used to created the ACLiC dictionary.
4236/// This effectively enable the full customization of the creation
4237/// of the dictionary. It should be noted that the file is intended
4238/// as a linkdef `fragment`, so usually you would not list the
4239/// typical:
4240/// ~~~ {.cpp}
4241/// #pragma link off ....
4242/// ~~~
4243
4245{
4247}
4248
4249
4250////////////////////////////////////////////////////////////////////////////////
4251/// Set shared library extension, should be either .so, .sl, .a, .dll, etc.
4252
4253void TSystem::SetSoExt(const char *SoExt)
4254{
4255 fSoExt = SoExt;
4256}
4257
4258////////////////////////////////////////////////////////////////////////////////
4259/// Set object files extension, should be either .o, .obj, etc.
4260
4262{
4263 fObjExt = ObjExt;
4264}
4265
4266////////////////////////////////////////////////////////////////////////////////
4267/// This method split a filename of the form:
4268/// ~~~ {.cpp}
4269/// [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)].
4270/// ~~~
4271/// It stores the ACliC mode [+|++[options]] in 'mode',
4272/// the arguments (including parenthesis) in arg
4273/// and the I/O indirection in io
4274
4276 TString &arguments, TString &io) const
4277{
4278 char *fname = Strip(filename);
4280 filenameCopy = filenameCopy.Strip();
4281
4282 if (filenameCopy.EndsWith(";")) {
4283 filenameCopy.Remove(filenameCopy.Length() - 1);
4284 filenameCopy = filenameCopy.Strip();
4285 }
4286 if (filenameCopy.EndsWith(")")) {
4287 Ssiz_t posArgEnd = filenameCopy.Length() - 1;
4288 // There is an argument; find its start!
4289 int parenNestCount = 1;
4290 bool inString = false;
4292 for (; parenNestCount && posArgBegin >= 0; --posArgBegin) {
4293 // Escaped if the previous character is a `\` - but not if it
4294 // itself is preceded by a `\`!
4295 if (posArgBegin > 0 && filenameCopy[posArgBegin] == '\\' &&
4296 (posArgBegin == 1 || filenameCopy[posArgBegin - 1] != '\\')) {
4297 // skip escape.
4298 --posArgBegin;
4299 continue;
4300 }
4301 switch (filenameCopy[posArgBegin]) {
4302 case ')':
4303 if (!inString)
4305 break;
4306 case '(':
4307 if (!inString)
4309 break;
4310 case '"': inString = !inString; break;
4311 }
4312 }
4313 if (parenNestCount || inString) {
4314 Error("SplitAclicMode", "Cannot parse argument in %s", filename);
4315 } else {
4316 arguments = filenameCopy(posArgBegin + 1, posArgEnd - 1);
4317 fname[posArgBegin + 1] = 0;
4318 }
4319 }
4320
4321 // strip off I/O redirect tokens from filename
4322 {
4323 char *s2 = nullptr;
4324 char *s3;
4325 s2 = strstr(fname, ">>");
4326 if (!s2) s2 = strstr(fname, "2>");
4327 if (!s2) s2 = strchr(fname, '>');
4328 s3 = strchr(fname, '<');
4329 if (s2 && s3) s2 = s2<s3 ? s2 : s3;
4330 if (s3 && !s2) s2 = s3;
4331 if (s2==fname) {
4332 io = fname;
4333 aclicMode = "";
4334 arguments = "";
4335 delete []fname;
4336 return "";
4337 } else if (s2) {
4338 if (s2 > fname) {
4339 // Skip/trim spaces
4340 s2--;
4341 while (s2 > fname && *s2 == ' ') s2--;
4342 s2++;
4343 }
4344 io = s2; // ssave = *s2;
4345 *s2 = 0;
4346 } else
4347 io = "";
4348 }
4349
4350 // remove the possible ACLiC + or ++ and g or O etc
4351 aclicMode.Clear();
4352 int len = strlen(fname);
4353 TString mode;
4354 while (len > 1) {
4355 if (strchr("kfgOcsdv-", fname[len - 1])) {
4356 mode += fname[len - 1];
4357 --len;
4358 } else {
4359 break;
4360 }
4361 }
4362 Bool_t compile = len && fname[len - 1] == '+';
4363 Bool_t remove = compile && len > 1 && fname[len - 2] == '+';
4364 if (compile) {
4365 if (mode.Length()) {
4366 fname[len] = 0;
4367 }
4368 if (remove) {
4369 fname[strlen(fname)-2] = 0;
4370 aclicMode = "++";
4371 } else {
4372 fname[strlen(fname)-1] = 0;
4373 aclicMode = "+";
4374 }
4375 if (mode.Length())
4376 aclicMode += mode;
4377 }
4378
4380
4381 delete []fname;
4382 return resFilename;
4383}
4384
4385////////////////////////////////////////////////////////////////////////////////
4386/// Remove the shared libs produced by the CompileMacro() function, together
4387/// with their rootmaps, linkdefs, and pcms (and some more on Windows).
4388
4390{
4391 TIter next(fCompiled);
4392 TNamed *lib;
4393 const char *extensions[] = {".lib", ".exp", ".d", ".def", ".rootmap", "_ACLiC_linkdef.h", "_ACLiC_dict_rdict.pcm"};
4394 while ((lib = (TNamed*)next())) {
4395 if (lib->TestBit(kMustCleanup)) {
4396 TString libname = lib->GetTitle();
4397#ifdef WIN32
4398 // On Windows, we need to unload the dll before deleting it
4399 if (gInterpreter->IsLibraryLoaded(libname))
4401#endif
4402 Unlink(libname);
4403 TString target, soExt = "." + fSoExt;
4404 libname.ReplaceAll(soExt, "");
4405 for (const char *ext : extensions) {
4406 target = libname + ext;
4407 Unlink(target);
4408 }
4409 }
4410 }
4411}
4412
4413////////////////////////////////////////////////////////////////////////////////
4414/// Register version of plugin library.
4415
The file contains utilities which are foundational and could be used across the core component of ROO...
#define SafeDelete(p)
Definition RConfig.hxx:538
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
#define ROOT_RELEASE
Definition RVersion.hxx:44
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
constexpr Int_t kMaxInt
Definition RtypesCore.h:105
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
@ kMAXPATHLEN
Definition Rtypes.h:60
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
#define ENDTRY
Definition TException.h:64
#define RETRY
Definition TException.h:44
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
#define gInterpreter
Int_t gDebug
Definition TROOT.cxx:622
#define gROOT
Definition TROOT.h:414
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition TString.cxx:2521
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
ESignals
@ kSigInterrupt
TSystem * gSystem
Definition TSystem.cxx:68
static Int_t gLibraryVersionIdx
Definition TSystem.cxx:72
TVirtualMutex * gSystemMutex
Definition TSystem.cxx:111
void AssignAndDelete(TString &target, char *tobedeleted)
Definition TSystem.cxx:2513
static void R__WriteDependencyFile(const TString &build_loc, const TString &depfilename, const TString &filename, const TString &library, const TString &libname, const TString &extension, const char *version_var_prefix, const TString &includes, const TString &defines, const TString &incPath)
Definition TSystem.cxx:2585
static bool R__MatchFilename(const char *left, const char *right)
Figure out if left and right points to the same object in the file system.
Definition TSystem.cxx:1832
static void R__AddPath(TString &target, const TString &path)
Definition TSystem.cxx:2580
static Int_t * gLibraryVersion
Definition TSystem.cxx:71
const char * gRootDir
Definition TSystem.cxx:64
static Int_t gLibraryVersionMax
Definition TSystem.cxx:73
TFileHandler * gXDisplay
Definition TSystem.cxx:69
const char * gProgPath
Definition TSystem.cxx:66
const char * gProgName
Definition TSystem.cxx:65
R__EXTERN const char * gProgName
Definition TSystem.h:252
R__EXTERN TVirtualMutex * gSystemMutex
Definition TSystem.h:254
void(* Func_t)()
Definition TSystem.h:249
EAccessMode
Definition TSystem.h:51
@ kFileExists
Definition TSystem.h:52
@ kReadPermission
Definition TSystem.h:55
@ kWritePermission
Definition TSystem.h:54
Bool_t R_ISREG(Int_t mode)
Definition TSystem.h:126
ELogFacility
Definition TSystem.h:74
ESocketBindOption
Options for binging the sockets created.
Definition TSystem.h:46
ELogLevel
Definition TSystem.h:63
Bool_t R_ISDIR(Int_t mode)
Definition TSystem.h:123
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
@ kS_IXOTH
Definition TSystem.h:120
@ kS_IXUSR
Definition TSystem.h:112
@ kS_IXGRP
Definition TSystem.h:116
#define R__LOCKGUARD2(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
const char * extension
Definition civetweb.c:8025
#define snprintf
Definition civetweb.c:1540
const_iterator begin() const
const_iterator end() const
virtual void StopIdleing()
Called when system stops idleing.
virtual void StartIdleing()
Called when system starts idleing.
virtual TObject * Remove(TObject *obj)=0
virtual bool UseRWLock(Bool_t enable=true)
Set this collection to use a RW lock upon access, making it thread safe.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Delete(Option_t *option="") override=0
Delete this object.
Definition TEnv.h:86
The TEnv class reads config files, by default named .rootrc.
Definition TEnv.h:124
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
This class represents an Internet Protocol (IP) address.
Iterator of linked list.
Definition TList.h:191
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
Definition TList.cxx:1112
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TNamed()
Definition TNamed.h:38
TString fName
Definition TNamed.h:32
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
void AbstractMethod(const char *method) const
Call this function within a function that you don't want to define as purely virtual,...
Definition TObject.cxx:1122
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:205
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1085
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:875
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:78
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:70
Ordered collection.
TProcessEventTimer(Long_t delay)
Create async event processor timer. Delay is in milliseconds.
Definition TSystem.cxx:82
Bool_t ProcessEvents()
Process events if timer did time out.
Definition TSystem.cxx:93
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:3019
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition TROOT.cxx:3072
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition TROOT.cxx:2952
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition TROOT.cxx:3009
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition TROOT.cxx:2971
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3082
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Definition TROOT.cxx:3040
Regular expression class.
Definition TRegexp.h:31
void Add(TObject *obj) override
static Int_t * ReAllocInt(Int_t *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition TStorage.cxx:258
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:457
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1235
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:538
const char * Data() const
Definition TString.h:376
TString & Chop()
Definition TString.h:691
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
@ kTrailing
Definition TString.h:276
@ kBoth
Definition TString.h:276
@ kIgnoreCase
Definition TString.h:277
@ kExact
Definition TString.h:277
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition TString.cxx:931
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:623
TString & Prepend(const char *cs)
Definition TString.h:673
Bool_t IsNull() const
Definition TString.h:414
TString & Remove(Ssiz_t pos)
Definition TString.h:685
TString & Append(const char *cs)
Definition TString.h:572
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:276
TString fListPaths
Definition TSystem.h:320
virtual void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
Definition TSystem.cxx:315
virtual const char * GetBuildNode() const
Return the build node name.
Definition TSystem.cxx:3924
virtual int Umask(Int_t mask)
Set the process file creation mode mask.
Definition TSystem.cxx:1533
virtual int SendBuf(int sock, const void *buffer, int length)
Send a buffer headed by a length indicator.
Definition TSystem.cxx:2443
virtual int GetServiceByName(const char *service)
Get port # of internet service.
Definition TSystem.cxx:2334
virtual Bool_t IsFileInIncludePath(const char *name, char **fullpath=nullptr)
Return true if 'name' is a file that can be found in the ROOT include path or the current directory.
Definition TSystem.cxx:982
virtual void Unload(const char *module)
Unload a shared library.
Definition TSystem.cxx:2068
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
Definition TSystem.cxx:1515
virtual const char * GetMakeSharedLib() const
Return the command line use to make a shared library.
Definition TSystem.cxx:3973
Bool_t fInControl
Definition TSystem.h:300
TSeqCollection * fFileHandler
Definition TSystem.h:306
Int_t fAclicProperties
Definition TSystem.h:329
Int_t fMaxrfd
Definition TSystem.h:291
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
Definition TSystem.cxx:558
TString & GetLastErrorString()
Return the thread local storage for the custom last error message.
Definition TSystem.cxx:2118
virtual void AddLinkedLibs(const char *linkedLib)
Add linkedLib to already set linked libs.
Definition TSystem.cxx:4187
virtual Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=nullptr)
Redirect standard output (stdout, stderr) to the specified file.
Definition TSystem.cxx:1731
virtual const char * GetBuildCompilerVersion() const
Return the build compiler version.
Definition TSystem.cxx:3908
virtual void ResetSignal(ESignals sig, Bool_t reset=kTRUE)
If reset is true reset the signal handler for the specified signal to the default handler,...
Definition TSystem.cxx:580
virtual TInetAddress GetSockName(int sock)
Get Internet Protocol (IP) address of host and port #.
Definition TSystem.cxx:2325
virtual int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: fs type, block size, number of blocks, number of free blocks.
Definition TSystem.cxx:1488
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition TSystem.cxx:2060
virtual const char * GetLinkedLibs() const
Return the list of library linked to this executable.
Definition TSystem.cxx:4009
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
Definition TSystem.cxx:328
Int_t fBeepDuration
Definition TSystem.h:298
virtual void IgnoreInterrupt(Bool_t ignore=kTRUE)
If ignore is true ignore the interrupt signal, else restore previous behaviour.
Definition TSystem.cxx:606
virtual void Syslog(ELogLevel level, const char *mess)
Send mess to syslog daemon.
Definition TSystem.cxx:1702
virtual int Symlink(const char *from, const char *to)
Create a symbolic link from file1 to file2.
Definition TSystem.cxx:1384
virtual void SetAclicMode(EAclicMode mode)
AclicMode indicates whether the library should be built in debug mode or optimized.
Definition TSystem.cxx:4094
static void ResetErrno()
Static function resetting system error number.
Definition TSystem.cxx:288
virtual UInt_t LoadAllLibraries()
Load all libraries known to ROOT via the rootmap system.
Definition TSystem.cxx:1986
virtual void * GetDirPtr() const
Definition TSystem.h:426
virtual void SetObjExt(const char *objExt)
Set object files extension, should be either .o, .obj, etc.
Definition TSystem.cxx:4261
virtual void SetLinkdefSuffix(const char *suffix)
The 'suffix' will be appended to the name of a script loaded by ACLiC and used to locate any eventual...
Definition TSystem.cxx:4244
TSeqCollection * fHelpers
Definition TSystem.h:331
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1290
virtual const char * GetBuildDir() const
Return the path of the build directory.
Definition TSystem.cxx:3932
virtual void Openlog(const char *name, Int_t options, ELogFacility facility)
Open connection to system log daemon.
Definition TSystem.cxx:1693
static Int_t GetErrno()
Static function returning system error number.
Definition TSystem.cxx:280
virtual void AddIncludePath(const char *includePath)
Add a directory to the already set include path.
Definition TSystem.cxx:4176
virtual int Chmod(const char *file, UInt_t mode)
Set the file permission bits. Returns -1 in case or error, 0 otherwise.
Definition TSystem.cxx:1524
virtual Int_t GetEffectiveGid()
Returns the effective group id.
Definition TSystem.cxx:1607
@ kDefault
Definition TSystem.h:279
@ kDebug
Definition TSystem.h:279
virtual ~TSystem()
Delete the OS interface.
Definition TSystem.cxx:140
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition TSystem.cxx:236
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1022
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition TSystem.cxx:861
virtual void SetFlagsOpt(const char *)
FlagsOpt should contain the options to pass to the C++ compiler in order to compile the library in op...
Definition TSystem.cxx:4082
void RemoveOnExit(TObject *obj)
Objects that should be deleted on exit of the OS interface.
Definition TSystem.cxx:296
TSeqCollection * fStdExceptionHandler
Definition TSystem.h:307
virtual char * GetServiceByPort(int port)
Get name of internet service.
Definition TSystem.cxx:2343
virtual void * OpenDirectory(const char *name)
Open a directory.
Definition TSystem.cxx:852
virtual int GetPid()
Get process id.
Definition TSystem.cxx:722
virtual int RecvBuf(int sock, void *buffer, int length)
Receive a buffer headed by a length indicator.
Definition TSystem.cxx:2434
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
Copy a file.
Definition TSystem.cxx:1357
virtual Long_t NextTimeOut(Bool_t mode)
Time when next timer of mode (synchronous=kTRUE or asynchronous=kFALSE) will time-out (in ms).
Definition TSystem.cxx:498
virtual int SetSockOpt(int sock, int kind, int val)
Set socket option.
Definition TSystem.cxx:2452
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1681
virtual TStdExceptionHandler * RemoveStdExceptionHandler(TStdExceptionHandler *eh)
Remove an exception handler from list of exception handlers.
Definition TSystem.cxx:625
virtual const char * GetIncludePath()
Get the list of include path.
Definition TSystem.cxx:3990
virtual int AcceptConnection(int sock)
Accept a connection.
Definition TSystem.cxx:2397
virtual Int_t GetAclicProperties() const
Return the ACLiC properties field.
Definition TSystem.cxx:3884
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition TSystem.cxx:4275
TString fListLibs
Definition TSystem.h:310
virtual void ShowOutput(RedirectHandle_t *h)
Display the content associated with the redirection described by the opaque handle 'h'.
Definition TSystem.cxx:1741
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition TSystem.cxx:1087
virtual UserGroup_t * GetGroupInfo(Int_t gid)
Returns all group info in the UserGroup_t structure.
Definition TSystem.cxx:1641
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function, together with their rootmaps,...
Definition TSystem.cxx:4389
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
Definition TSystem.cxx:1321
TString fMakeExe
Definition TSystem.h:327
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1554
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
Definition TSystem.cxx:922
virtual int MakeDirectory(const char *name)
Make a directory.
Definition TSystem.cxx:842
TString fBuildCompilerVersionStr
Definition TSystem.h:315
virtual const char * ExpandFileName(const char *fname)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1114
TSystem(const TSystem &)=delete
EAclicMode fAclicMode
Definition TSystem.h:325
virtual TInetAddress GetPeerName(int sock)
Get Internet Protocol (IP) address of remote host and port #.
Definition TSystem.cxx:2316
virtual TTime Now()
Get current time in milliseconds since 0:00 Jan 1 1995.
Definition TSystem.cxx:467
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:657
virtual int GetSysInfo(SysInfo_t *info) const
Returns static system info, like OS type, CPU type, number of CPUs RAM size, etc into the SysInfo_t s...
Definition TSystem.cxx:2474
TString fFlagsOpt
Definition TSystem.h:319
virtual int GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
Definition TSystem.cxx:2495
virtual EAclicMode GetAclicMode() const
AclicMode indicates whether the library should be built in debug mode or optimized.
Definition TSystem.cxx:3964
virtual const char * GetLinkedLibraries()
Get list of shared libraries loaded at the start of the executable.
Definition TSystem.cxx:2136
virtual void SetIncludePath(const char *includePath)
IncludePath should contain the list of compiler flags to indicate where to find user defined header f...
Definition TSystem.cxx:4211
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
Definition TSystem.cxx:568
TString fLinkedLibs
Definition TSystem.h:322
Int_t fSigcnt
Definition TSystem.h:293
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1873
virtual void ListSymbols(const char *module, const char *re="")
List symbols in a shared library.
Definition TSystem.cxx:2080
virtual void DoBeep(Int_t=-1, Int_t=-1) const
Definition TSystem.h:342
TString fObjExt
Definition TSystem.h:324
TString fLinkdefSuffix
Definition TSystem.h:328
Int_t fBeepFreq
Definition TSystem.h:297
virtual int GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const
Returns cpu load average and load info into the CpuInfo_t structure.
Definition TSystem.cxx:2485
@ kFlatBuildDir
Definition TSystem.h:281
virtual void ListLibraries(const char *regexp="")
List the loaded shared libraries.
Definition TSystem.cxx:2101
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
Definition TSystem.cxx:666
virtual void SetMakeSharedLib(const char *directives)
Directives should contain the description on how to compile and link a shared lib.
Definition TSystem.cxx:4162
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition TSystem.cxx:1414
virtual void InnerLoop()
Inner event loop.
Definition TSystem.cxx:404
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1097
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1312
virtual int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp")
Open a connection to another host.
Definition TSystem.cxx:2352
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition TSystem.cxx:869
virtual void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
Definition TSystem.cxx:597
virtual void Run()
System event loop.
Definition TSystem.cxx:347
virtual int GetSockOpt(int sock, int kind, int *val)
Get socket option.
Definition TSystem.cxx:2461
virtual void ExitLoop()
Exit from event loop.
Definition TSystem.cxx:396
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:878
virtual std::string GetHomeDirectory(const char *userName=nullptr) const
Return the user's home directory.
Definition TSystem.cxx:911
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1079
virtual int RecvRaw(int sock, void *buffer, int length, int flag)
Receive exactly length bytes into buffer.
Definition TSystem.cxx:2415
virtual Bool_t Init()
Initialize the OS interface.
Definition TSystem.cxx:184
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:475
virtual int GetProcInfo(ProcInfo_t *info) const
Returns cpu and memory used by this process into the ProcInfo_t structure.
Definition TSystem.cxx:2505
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
Definition TSystem.cxx:3916
static Int_t GetCryptoRandom(void *buf, Int_t len)
Return cryptographic random number Fill provided buffer with random values.
Definition TSystem.cxx:267
virtual void DispatchOneEvent(Bool_t pendingOnly=kFALSE)
Dispatch a single event.
Definition TSystem.cxx:433
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition TSystem.cxx:1366
virtual int ClosePipe(FILE *pipe)
Close the pipe.
Definition TSystem.cxx:675
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:950
TString fBuildArch
Definition TSystem.h:312
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
Definition TSystem.cxx:536
virtual const char * GetDynamicPath()
Return the dynamic path (used to find shared libraries).
Definition TSystem.cxx:1811
TSeqCollection * fSignalHandler
Definition TSystem.h:305
virtual const char * GetMakeExe() const
Return the command line use to make an executable.
Definition TSystem.cxx:3982
virtual const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE)
Find a dynamic library using the system search paths.
Definition TSystem.cxx:2050
virtual TString GetFromPipe(const char *command, Int_t *ret=nullptr, Bool_t redirectStderr=kFALSE)
Execute command and return output in TString.
Definition TSystem.cxx:690
virtual void SetFlagsDebug(const char *)
FlagsDebug should contain the options to pass to the C++ compiler in order to compile the library in ...
Definition TSystem.cxx:4073
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
Definition TSystem.cxx:731
virtual Int_t GetGid(const char *group=nullptr)
Returns the group's id. If group = 0, returns current user's group.
Definition TSystem.cxx:1597
virtual void SetMakeExe(const char *directives)
Directives has the same syntax as the argument of SetMakeSharedLib but is used to create an executabl...
Definition TSystem.cxx:4110
TSeqCollection * fCompiled
Definition TSystem.h:330
TString fBuildCompilerVersion
Definition TSystem.h:314
TSystem * FindHelper(const char *path, void *dirptr=nullptr)
Create helper TSystem to handle file and directory operations that might be special for remote file a...
Definition TSystem.cxx:761
virtual const char * GetFlagsDebug() const
Return the debug flags.
Definition TSystem.cxx:3944
virtual const char * HostName()
Return the system's host name.
Definition TSystem.cxx:307
Bool_t fDone
Definition TSystem.h:301
TList * fTimers
Definition TSystem.h:304
Int_t fNfd
Signals that were trapped.
Definition TSystem.h:290
virtual void Unsetenv(const char *name)
Unset environment variable.
Definition TSystem.cxx:1673
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition TSystem.cxx:967
virtual void AddDynamicPath(const char *pathname)
Add a new directory to the dynamic path.
Definition TSystem.cxx:1803
virtual Int_t Select(TList *active, Long_t timeout)
Select on active file descriptors (called by TMonitor).
Definition TSystem.cxx:449
TSeqCollection * fOnExitList
Definition TSystem.h:308
virtual const char * GetObjExt() const
Get the object file extension.
Definition TSystem.cxx:4038
virtual int AnnounceUnixService(int port, int backlog)
Announce unix domain service.
Definition TSystem.cxx:2379
TString fIncludePath
Definition TSystem.h:321
virtual Int_t GetUid(const char *user=nullptr)
Returns the user's id. If user = 0, returns current user's id.
Definition TSystem.cxx:1578
virtual Int_t GetEffectiveUid()
Returns the effective user id.
Definition TSystem.cxx:1588
TString fFlagsDebug
Definition TSystem.h:318
virtual const char * GetLinkdefSuffix() const
Return the linkdef suffix chosen by the user for ACLiC.
Definition TSystem.cxx:4018
virtual void SetDynamicPath(const char *pathname)
Set the dynamic path to a new value.
Definition TSystem.cxx:1822
TString fMakeSharedLib
Definition TSystem.h:326
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:441
Int_t fMaxwfd
Definition TSystem.h:292
virtual int CompileMacro(const char *filename, Option_t *opt="", const char *library_name="", const char *build_dir="", UInt_t dirmode=0)
This method compiles and loads a shared library containing the code from the file "filename".
Definition TSystem.cxx:2852
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:887
virtual void AddStdExceptionHandler(TStdExceptionHandler *eh)
Add an exception handler to list of system exception handlers.
Definition TSystem.cxx:615
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1564
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition TSystem.cxx:2307
virtual void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
Definition TSystem.cxx:227
virtual int SendRaw(int sock, const void *buffer, int length, int flag)
Send exactly length bytes from buffer.
Definition TSystem.cxx:2425
virtual Int_t SetFPEMask(Int_t mask=kDefaultMask)
Set which conditions trigger a floating point exception.
Definition TSystem.cxx:646
Int_t fLevel
Definition TSystem.h:302
virtual const char * GetBuildCompiler() const
Return the build compiler.
Definition TSystem.cxx:3900
virtual void CloseConnection(int sock, Bool_t force=kFALSE)
Close socket connection.
Definition TSystem.cxx:2406
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
Definition TSystem.cxx:2152
TString fBuildDir
Definition TSystem.h:317
void SetErrorStr(const char *errstr)
Set the system error string.
Definition TSystem.cxx:246
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
Definition TSystem.cxx:546
virtual void SetSoExt(const char *soExt)
Set shared library extension, should be either .so, .sl, .a, .dll, etc.
Definition TSystem.cxx:4253
virtual void Closelog()
Close connection to system log daemon.
Definition TSystem.cxx:1710
TString fBuildCompiler
Definition TSystem.h:313
virtual void Setenv(const char *name, const char *value)
Set environment variable.
Definition TSystem.cxx:1665
virtual const char * GetBuildArch() const
Return the build architecture.
Definition TSystem.cxx:3892
virtual int Link(const char *from, const char *to)
Create a link from file1 to file2.
Definition TSystem.cxx:1375
virtual void SigAlarmInterruptsSyscalls(Bool_t)
Definition TSystem.h:340
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:903
virtual void SetLinkedLibs(const char *linkedLibs)
LinkedLibs should contain the library directory and list of libraries needed to recreate the current ...
Definition TSystem.cxx:4222
virtual std::string GetWorkingDirectory() const
Return working directory.
Definition TSystem.cxx:895
TString fSoExt
Definition TSystem.h:323
virtual void SetBuildDir(const char *build_dir, Bool_t isflat=kFALSE)
Set the location where ACLiC will create libraries and use as a scratch area.
Definition TSystem.cxx:4060
static const char * StripOffProto(const char *path, const char *proto)
Strip off protocol string from specified path.
Definition TSystem.cxx:118
virtual void Abort(int code=0)
Abort the application.
Definition TSystem.cxx:740
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:420
virtual const char * GetSoExt() const
Get the shared library extension.
Definition TSystem.cxx:4030
virtual int Utime(const char *file, Long_t modtime, Long_t actime)
Set the a files modification and access times.
Definition TSystem.cxx:1543
virtual const char * GetError()
Return system error string.
Definition TSystem.cxx:255
virtual int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize=-1, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny)
Announce TCP/IP service.
Definition TSystem.cxx:2361
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:485
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1048
virtual Int_t GetFPEMask()
Return the bitmap of conditions that trigger a floating point exception.
Definition TSystem.cxx:636
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1397
virtual void StackTrace()
Print a stack trace.
Definition TSystem.cxx:749
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition TSystem.cxx:1617
virtual int AnnounceUdpService(int port, int backlog, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny)
Announce UDP service.
Definition TSystem.cxx:2370
virtual void ResetSignals()
Reset signals handlers to previous behaviour.
Definition TSystem.cxx:588
TString fBuildNode
Definition TSystem.h:316
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1498
virtual const char * GetFlagsOpt() const
Return the optimization flags.
Definition TSystem.cxx:3952
virtual Bool_t ConsistentWith(const char *path, void *dirptr=nullptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
Definition TSystem.cxx:819
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Definition TSystem.cxx:2036
Basic time type with millisecond precision.
Definition TTime.h:27
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
TTime GetAbsTime() const
Definition TTimer.h:78
virtual void TurnOn()
Add the timer to the system timer list.
Definition TTimer.cxx:247
Bool_t IsAsync() const
Definition TTimer.h:81
void Reset()
Reset the timer.
Definition TTimer.cxx:163
Bool_t IsInterruptingSyscalls() const
Definition TTimer.h:82
void Remove() override
Definition TTimer.h:86
Bool_t fTimeout
Definition TTimer.h:56
Bool_t IsSync() const
Definition TTimer.h:80
This class represents a WWW compatible URL.
Definition TUrl.h:33
TVersionCheck(int versionCode)
Register version of plugin library.
Definition TSystem.cxx:4416
This class implements a mutex interface.
TLine * line
std::ostream & Info()
Definition hadd.cxx:171
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
#define I(x, y, z)
std::string MakePathRelative(const std::string &path, const std::string &base, bool isBuildingROOT=false)
bool GetCryptoRandom(void *buf, unsigned int len)
Get random bytes from the operating system's cryptographic random number generator The requested numb...
R__EXTERN TVirtualRWMutex * gCoreMutex
Int_t fMode
Definition TSystem.h:135
Long64_t fSize
Definition TSystem.h:138
Long_t fDev
Definition TSystem.h:133
Long_t fMtime
Definition TSystem.h:139
Long_t fIno
Definition TSystem.h:134
virtual ~ProcInfo_t()
Definition TSystem.cxx:76
TLine l
Definition textangle.C:4
auto * tt
Definition textangle.C:16