SystemTools.hxx.in 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /*=========================================================================
  2. Program: KWSys - Kitware System Library
  3. Module: $RCSfile$
  4. Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
  5. See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  8. PURPOSE. See the above copyright notices for more information.
  9. =========================================================================*/
  10. #ifndef @KWSYS_NAMESPACE@_SystemTools_hxx
  11. #define @KWSYS_NAMESPACE@_SystemTools_hxx
  12. #include <@KWSYS_NAMESPACE@/ios/iosfwd>
  13. #include <@KWSYS_NAMESPACE@/stl/string>
  14. #include <@KWSYS_NAMESPACE@/stl/vector>
  15. #include <@KWSYS_NAMESPACE@/stl/map>
  16. #include <@KWSYS_NAMESPACE@/Configure.h>
  17. #include <sys/types.h>
  18. // Required for va_list
  19. #include <stdarg.h>
  20. #if @KWSYS_NAMESPACE@_STL_HAVE_STD && !defined(va_list)
  21. // Some compilers move va_list into the std:: namespace and there is no way to
  22. // tell that this has been done. Playing with things being included before or
  23. // after stdarg.h does not solve things because we do not have control over
  24. // what the user does. This hack solves this problem by moving va_list to our
  25. // own namespace that is local for kwsys.
  26. namespace std {} // Required for platforms that do not have std::
  27. namespace @KWSYS_NAMESPACE@_VA_LIST
  28. {
  29. using namespace std;
  30. typedef va_list hack_va_list;
  31. }
  32. namespace @KWSYS_NAMESPACE@
  33. {
  34. typedef @KWSYS_NAMESPACE@_VA_LIST::hack_va_list va_list;
  35. }
  36. #endif // va_list
  37. #if defined( _MSC_VER )
  38. typedef unsigned short mode_t;
  39. #endif
  40. /* Define these macros temporarily to keep the code readable. */
  41. #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  42. # define kwsys_stl @KWSYS_NAMESPACE@_stl
  43. # define kwsys_ios @KWSYS_NAMESPACE@_ios
  44. #endif
  45. namespace @KWSYS_NAMESPACE@
  46. {
  47. class SystemToolsTranslationMap;
  48. class @KWSYS_NAMESPACE@_EXPORT SystemToolsManager
  49. {
  50. public:
  51. SystemToolsManager();
  52. ~SystemToolsManager();
  53. };
  54. // This instance will show up in any translation unit that uses
  55. // SystemTools. It will make sure SystemTools is initialized
  56. // before it is used and is the last static object destroyed.
  57. static SystemToolsManager SystemToolsManagerInstance;
  58. /** \class SystemTools
  59. * \brief A collection of useful platform-independent system functions.
  60. */
  61. class @KWSYS_NAMESPACE@_EXPORT SystemTools
  62. {
  63. public:
  64. /** -----------------------------------------------------------------
  65. * String Manipulation Routines
  66. * -----------------------------------------------------------------
  67. */
  68. /**
  69. * Replace symbols in str that are not valid in C identifiers as
  70. * defined by the 1999 standard, ie. anything except [A-Za-z0-9_].
  71. * They are replaced with `_' and if the first character is a digit
  72. * then an underscore is prepended. Note that this can produce
  73. * identifiers that the standard reserves (_[A-Z].* and __.*).
  74. */
  75. static kwsys_stl::string MakeCindentifier(const char* s);
  76. /**
  77. * Replace replace all occurences of the string in the source string.
  78. */
  79. static void ReplaceString(kwsys_stl::string& source,
  80. const char* replace,
  81. const char* with);
  82. /**
  83. * Return a capitalized string (i.e the first letter is uppercased,
  84. * all other are lowercased).
  85. */
  86. static kwsys_stl::string Capitalized(const kwsys_stl::string&);
  87. /**
  88. * Return a 'capitalized words' string (i.e the first letter of each word
  89. * is uppercased all other are left untouched though).
  90. */
  91. static kwsys_stl::string CapitalizedWords(const kwsys_stl::string&);
  92. /**
  93. * Return a 'uncapitalized words' string (i.e the first letter of each word
  94. * is lowercased all other are left untouched though).
  95. */
  96. static kwsys_stl::string UnCapitalizedWords(const kwsys_stl::string&);
  97. /**
  98. * Return a lower case string
  99. */
  100. static kwsys_stl::string LowerCase(const kwsys_stl::string&);
  101. /**
  102. * Return a lower case string
  103. */
  104. static kwsys_stl::string UpperCase(const kwsys_stl::string&);
  105. /**
  106. * Count char in string
  107. */
  108. static size_t CountChar(const char* str, char c);
  109. /**
  110. * Remove some characters from a string.
  111. * Return a pointer to the new resulting string (allocated with 'new')
  112. */
  113. static char* RemoveChars(const char* str, const char *toremove);
  114. /**
  115. * Remove remove all but 0->9, A->F characters from a string.
  116. * Return a pointer to the new resulting string (allocated with 'new')
  117. */
  118. static char* RemoveCharsButUpperHex(const char* str);
  119. /**
  120. * Replace some characters by another character in a string (in-place)
  121. * Return a pointer to string
  122. */
  123. static char* ReplaceChars(char* str, const char *toreplace,char replacement);
  124. /**
  125. * Returns true if str1 starts (respectively ends) with str2
  126. */
  127. static bool StringStartsWith(const char* str1, const char* str2);
  128. static bool StringEndsWith(const char* str1, const char* str2);
  129. /**
  130. * Returns a pointer to the last occurence of str2 in str1
  131. */
  132. static const char* FindLastString(const char* str1, const char* str2);
  133. /**
  134. * Make a duplicate of the string similar to the strdup C function
  135. * but use new to create the 'new' string, so one can use
  136. * 'delete' to remove it. Returns 0 if the input is empty.
  137. */
  138. static char* DuplicateString(const char* str);
  139. /**
  140. * Return the string cropped to a given length by removing chars in the
  141. * center of the string and replacing them with an ellipsis (...)
  142. */
  143. static kwsys_stl::string CropString(const kwsys_stl::string&,size_t max_len);
  144. /**
  145. * Perform a case-independent string comparison
  146. */
  147. static int Strucmp(const char *s1, const char *s2);
  148. /**
  149. * Convert a string in __DATE__ or __TIMESTAMP__ format into a time_t.
  150. * Return false on error, true on success
  151. */
  152. static bool ConvertDateMacroString(const char *str, time_t *tmt);
  153. static bool ConvertTimeStampMacroString(const char *str, time_t *tmt);
  154. /**
  155. * Split a string on its newlines into multiple lines
  156. * Return false only if the last line stored had no newline
  157. */
  158. static bool Split(const char* s, kwsys_stl::vector<kwsys_stl::string>& l);
  159. static bool Split(const char* s, kwsys_stl::vector<kwsys_stl::string>& l, char separator);
  160. /**
  161. * Return string with space added between capitalized words
  162. * (i.e. EatMyShorts becomes Eat My Shorts
  163. */
  164. static kwsys_stl::string AddSpaceBetweenCapitalizedWords(
  165. const kwsys_stl::string&);
  166. /**
  167. * Append two or more strings and produce new one.
  168. * Programmer must 'delete []' the resulting string, which was allocated
  169. * with 'new'.
  170. * Return 0 if inputs are empty or there was an error
  171. */
  172. static char* AppendStrings(
  173. const char* str1, const char* str2);
  174. static char* AppendStrings(
  175. const char* str1, const char* str2, const char* str3);
  176. /**
  177. * Estimate the length of the string that will be produced
  178. * from printing the given format string and arguments. The
  179. * returned length will always be at least as large as the string
  180. * that will result from printing.
  181. * WARNING: since va_arg is called to iterate of the argument list,
  182. * you will not be able to use this 'ap' anymore from the beginning.
  183. * It's up to you to call va_end though.
  184. */
  185. static int EstimateFormatLength(const char *format, va_list ap);
  186. /**
  187. * Escape specific characters in 'str'.
  188. */
  189. static kwsys_stl::string EscapeChars(
  190. const char *str, const char *chars_to_escape, char escape_char = '\\');
  191. /** -----------------------------------------------------------------
  192. * Filename Manipulation Routines
  193. * -----------------------------------------------------------------
  194. */
  195. /**
  196. * Replace Windows file system slashes with Unix-style slashes.
  197. */
  198. static void ConvertToUnixSlashes(kwsys_stl::string& path);
  199. /**
  200. * For windows this calls ConvertToWindowsOutputPath and for unix
  201. * it calls ConvertToUnixOutputPath
  202. */
  203. static kwsys_stl::string ConvertToOutputPath(const char*);
  204. /**
  205. * Return true if a file exists in the current directory
  206. */
  207. static bool FileExists(const char* filename);
  208. /**
  209. * Return file length
  210. */
  211. static unsigned long FileLength(const char *filename);
  212. /**
  213. * Compare file modification times.
  214. * Return true for successful comparison and false for error.
  215. * When true is returned, result has -1, 0, +1 for
  216. * f1 older, same, or newer than f2.
  217. */
  218. static bool FileTimeCompare(const char* f1, const char* f2,
  219. int* result);
  220. /**
  221. * Get the file extension (including ".") needed for an executable
  222. * on the current platform ("" for unix, ".exe" for Windows).
  223. */
  224. static const char* GetExecutableExtension();
  225. /**
  226. * Given a path that exists on a windows machine, return the
  227. * actuall case of the path as it was created. If the file
  228. * does not exist path is returned unchanged. This does nothing
  229. * on unix but return path.
  230. */
  231. static kwsys_stl::string GetActualCaseForPath(const char* path);
  232. /**
  233. * Given the path to a program executable, get the directory part of
  234. * the path with the file stripped off. If there is no directory
  235. * part, the empty string is returned.
  236. */
  237. static kwsys_stl::string GetProgramPath(const char*);
  238. static bool SplitProgramPath(const char* in_name,
  239. kwsys_stl::string& dir,
  240. kwsys_stl::string& file,
  241. bool errorReport = true);
  242. /**
  243. * Given argv[0] for a unix program find the full path to a running
  244. * executable. argv0 can be null for windows WinMain programs
  245. * in this case GetModuleFileName will be used to find the path
  246. * to the running executable. If argv0 is not a full path,
  247. * then this will try to find the full path. If the path is not
  248. * found false is returned, if found true is returned. An error
  249. * message of the attempted paths is stored in errorMsg.
  250. * exeName is the name of the executable.
  251. * buildDir is a possibly null path to the build directory.
  252. * installPrefix is a possibly null pointer to the install directory.
  253. */
  254. static bool FindProgramPath(const char* argv0,
  255. kwsys_stl::string& pathOut,
  256. kwsys_stl::string& errorMsg,
  257. const char* exeName = 0,
  258. const char* buildDir = 0,
  259. const char* installPrefix = 0);
  260. /**
  261. * Given a path to a file or directory, convert it to a full path.
  262. * This collapses away relative paths relative to the cwd argument
  263. * (which defaults to the current working directory). The full path
  264. * is returned.
  265. */
  266. static kwsys_stl::string CollapseFullPath(const char* in_relative);
  267. static kwsys_stl::string CollapseFullPath(const char* in_relative,
  268. const char* in_base);
  269. /**
  270. * Split a path name into its basic components. The first component
  271. * is one of the following roots:
  272. * "/" = UNIX
  273. * "c:/" = Windows full path (can be any drive letter)
  274. * "c:" = Windows drive-letter relative path (can be any drive letter)
  275. * "//" = Network path
  276. * "" = Relative path
  277. * The remaining components form the path. If there is a trailing
  278. * slash then the last component is the empty string. The
  279. * components can be recombined as "c[0]c[1]/c[2]/.../c[n]" to
  280. * produce the original path.
  281. */
  282. static void SplitPath(const char* p,
  283. kwsys_stl::vector<kwsys_stl::string>& components);
  284. /**
  285. * Join components of a path name into a single string. See
  286. * SplitPath for the format of the components.
  287. */
  288. static kwsys_stl::string JoinPath(
  289. const kwsys_stl::vector<kwsys_stl::string>& components);
  290. /**
  291. * Compare a path or components of a path.
  292. */
  293. static bool ComparePath(const char* c1, const char* c2);
  294. /**
  295. * Return path of a full filename (no trailing slashes)
  296. */
  297. static kwsys_stl::string GetFilenamePath(const kwsys_stl::string&);
  298. /**
  299. * Return file name of a full filename (i.e. file name without path)
  300. */
  301. static kwsys_stl::string GetFilenameName(const kwsys_stl::string&);
  302. /**
  303. * Split a program from its arguments and handle spaces in the paths
  304. */
  305. static void SplitProgramFromArgs(
  306. const char* path,
  307. kwsys_stl::string& program, kwsys_stl::string& args);
  308. /**
  309. * Return longest file extension of a full filename (dot included)
  310. */
  311. static kwsys_stl::string GetFilenameExtension(const kwsys_stl::string&);
  312. /**
  313. * Return shortest file extension of a full filename (dot included)
  314. */
  315. static kwsys_stl::string GetFilenameLastExtension(
  316. const kwsys_stl::string& filename);
  317. /**
  318. * Return file name without extension of a full filename
  319. */
  320. static kwsys_stl::string GetFilenameWithoutExtension(
  321. const kwsys_stl::string&);
  322. /**
  323. * Return file name without its last (shortest) extension
  324. */
  325. static kwsys_stl::string GetFilenameWithoutLastExtension(
  326. const kwsys_stl::string&);
  327. /**
  328. * Return whether the path represents a full path (not relative)
  329. */
  330. static bool FileIsFullPath(const char*);
  331. /**
  332. * For windows return the short path for the given path,
  333. * Unix just a pass through
  334. */
  335. static bool GetShortPath(const char* path, kwsys_stl::string& result);
  336. /**
  337. * Read line from file. Make sure to get everything. Due to a buggy stream
  338. * library on the HP and another on Mac OSX, we need this very carefully
  339. * written version of getline. Returns true if any data were read before the
  340. * end-of-file was reached. If the has_newline argument is specified, it will
  341. * be true when the line read had a newline character.
  342. */
  343. static bool GetLineFromStream(kwsys_ios::istream& istr,
  344. kwsys_stl::string& line,
  345. bool* has_newline=0);
  346. /**
  347. * Get the parent directory of the directory or file
  348. */
  349. static kwsys_stl::string GetParentDirectory(const char* fileOrDir);
  350. /**
  351. * Check if the given file or directory is in subdirectory of dir
  352. */
  353. static bool IsSubDirectory(const char* fileOrDir, const char* dir);
  354. /**
  355. * Convert the path to a string that can be used in a unix makefile.
  356. * double slashes are removed, and spaces are escaped.
  357. */
  358. static kwsys_stl::string ConvertToUnixOutputPath(const char*);
  359. /** -----------------------------------------------------------------
  360. * File Manipulation Routines
  361. * -----------------------------------------------------------------
  362. */
  363. /**
  364. * Make a new directory if it is not there. This function
  365. * can make a full path even if none of the directories existed
  366. * prior to calling this function.
  367. */
  368. static bool MakeDirectory(const char* path);
  369. /**
  370. * Copy the source file to the destination file only
  371. * if the two files differ.
  372. */
  373. static bool CopyFileIfDifferent(const char* source,
  374. const char* destination);
  375. /**
  376. * Compare the contents of two files. Return true if different
  377. */
  378. static bool FilesDiffer(const char* source, const char* destination);
  379. /**
  380. * Return true if the two files are the same file
  381. */
  382. static bool SameFile(const char* file1, const char* file2);
  383. /**
  384. * Copy a file
  385. */
  386. static bool CopyFileAlways(const char* source, const char* destination);
  387. /**
  388. * Copy content directory to another directory with all files and
  389. * subdirectories
  390. */
  391. static bool CopyADirectory(const char* source, const char* destination);
  392. /**
  393. * Remove a file
  394. */
  395. static bool RemoveFile(const char* source);
  396. /**
  397. * Remove a directory
  398. */
  399. static bool RemoveADirectory(const char* source);
  400. /**
  401. * Find a file in the system PATH, with optional extra paths
  402. */
  403. static kwsys_stl::string FindFile(
  404. const char* name,
  405. const kwsys_stl::vector<kwsys_stl::string>& path =
  406. kwsys_stl::vector<kwsys_stl::string>());
  407. /**
  408. * Find an executable in the system PATH, with optional extra paths
  409. */
  410. static kwsys_stl::string FindProgram(
  411. const char* name,
  412. const kwsys_stl::vector<kwsys_stl::string>& path =
  413. kwsys_stl::vector<kwsys_stl::string>(),
  414. bool no_system_path = false);
  415. /**
  416. * Find a library in the system PATH, with optional extra paths
  417. */
  418. static kwsys_stl::string FindLibrary(
  419. const char* name,
  420. const kwsys_stl::vector<kwsys_stl::string>& path);
  421. /**
  422. * Return true if the file is a directory
  423. */
  424. static bool FileIsDirectory(const char* name);
  425. /**
  426. * Return true if the file is a symlink
  427. */
  428. static bool FileIsSymlink(const char* name);
  429. /**
  430. * Return true if the file has a given signature (first set of bytes)
  431. */
  432. static bool FileHasSignature(
  433. const char* filename, const char *signature, long offset = 0);
  434. /**
  435. * Attempt to detect and return the type of a file.
  436. * Up to 'length' bytes are read from the file, if more than 'percent_bin' %
  437. * of the bytes are non-textual elements, the file is considered binary,
  438. * otherwise textual. Textual elements are bytes in the ASCII [0x20, 0x7E]
  439. * range, but also \n, \r, \t.
  440. * The algorithm is simplistic, and should probably check for usual file
  441. * extensions, 'magic' signature, unicode, etc.
  442. */
  443. enum FileTypeEnum
  444. {
  445. FileTypeUnknown,
  446. FileTypeBinary,
  447. FileTypeText
  448. };
  449. static SystemTools::FileTypeEnum DetectFileType(
  450. const char* filename,
  451. unsigned long length = 256,
  452. double percent_bin = 0.05);
  453. /**
  454. * Try to locate the file 'filename' in the directory 'dir'.
  455. * If 'filename' is a fully qualified filename, the basename of the file is
  456. * used to check for its existence in 'dir'.
  457. * If 'dir' is not a directory, GetFilenamePath() is called on 'dir' to
  458. * get its directory first (thus, you can pass a filename as 'dir', as
  459. * a convenience).
  460. * 'filename_found' is assigned the fully qualified name/path of the file
  461. * if it is found (not touched otherwise).
  462. * If 'try_filename_dirs' is true, try to find the file using the
  463. * components of its path, i.e. if we are looking for c:/foo/bar/bill.txt,
  464. * first look for bill.txt in 'dir', then in 'dir'/bar, then in 'dir'/foo/bar
  465. * etc.
  466. * Return true if the file was found, false otherwise.
  467. */
  468. static bool LocateFileInDir(const char *filename,
  469. const char *dir,
  470. kwsys_stl::string& filename_found,
  471. int try_filename_dirs = 0);
  472. /**
  473. * Check if the given file exists in one of the parent directory of the
  474. * given file or directory and if it does, return the name of the file.
  475. * Toplevel specifies the top-most directory to where it will look.
  476. */
  477. static kwsys_stl::string FileExistsInParentDirectories(const char* fname,
  478. const char* directory, const char* toplevel);
  479. /**
  480. * Return file's modified time
  481. */
  482. static long int ModifiedTime(const char* filename);
  483. /**
  484. * Return file's creation time (Win32: works only for NTFS, not FAT)
  485. */
  486. static long int CreationTime(const char* filename);
  487. /**
  488. * Get and set permissions of the file.
  489. */
  490. static bool GetPermissions(const char* file, mode_t& mode);
  491. static bool SetPermissions(const char* file, mode_t mode);
  492. /** -----------------------------------------------------------------
  493. * Time Manipulation Routines
  494. * -----------------------------------------------------------------
  495. */
  496. /**
  497. * Get current time as a double. On certain platforms this will
  498. * return higher resolution than seconds:
  499. * (1) gettimeofday() -- resolution in microseconds
  500. * (2) ftime() -- resolution in milliseconds
  501. * (3) time() -- resolution in seconds
  502. */
  503. static double GetTime();
  504. /**
  505. * Get current date/time
  506. */
  507. static kwsys_stl::string GetCurrentDateTime(const char* format);
  508. /** -----------------------------------------------------------------
  509. * Registry Manipulation Routines
  510. * -----------------------------------------------------------------
  511. */
  512. /**
  513. * Read a registry value
  514. */
  515. static bool ReadRegistryValue(const char *key, kwsys_stl::string &value);
  516. /**
  517. * Write a registry value
  518. */
  519. static bool WriteRegistryValue(const char *key, const char *value);
  520. /**
  521. * Delete a registry value
  522. */
  523. static bool DeleteRegistryValue(const char *key);
  524. /** -----------------------------------------------------------------
  525. * Environment Manipulation Routines
  526. * -----------------------------------------------------------------
  527. */
  528. /**
  529. * Add the paths from the environment variable PATH to the
  530. * string vector passed in. If env is set then the value
  531. * of env will be used instead of PATH.
  532. */
  533. static void GetPath(kwsys_stl::vector<kwsys_stl::string>& path,
  534. const char* env=0);
  535. /**
  536. * Read an environment variable
  537. */
  538. static const char* GetEnv(const char* key);
  539. static bool GetEnv(const char* key, kwsys_stl::string& result);
  540. /**
  541. * Get current working directory CWD
  542. */
  543. static kwsys_stl::string GetCurrentWorkingDirectory(bool collapse =true);
  544. /**
  545. * Change directory the the directory specified
  546. */
  547. static int ChangeDirectory(const char* dir);
  548. /**
  549. * Get the result of strerror(errno)
  550. */
  551. static kwsys_stl::string GetLastSystemError();
  552. /**
  553. * When building DEBUG with MSVC, this enables a hook that prevents
  554. * error dialogs from popping up if the program is being run from
  555. * DART.
  556. */
  557. static void EnableMSVCDebugHook();
  558. /**
  559. * Get the width of the terminal window. The code may or may not work, so
  560. * make sure you have some resonable defaults prepared if the code returns
  561. * some bogus size.
  562. */
  563. static int GetTerminalWidth();
  564. /**
  565. * Add an entry in the path translation table.
  566. */
  567. static void AddTranslationPath(const char * dir, const char * refdir);
  568. /**
  569. * If dir is different after CollapseFullPath is called,
  570. * Then insert it into the path translation table
  571. */
  572. static void AddKeepPath(const char* dir);
  573. /**
  574. * Update path by going through the Path Translation table;
  575. */
  576. static void CheckTranslationPath(kwsys_stl::string & path);
  577. /**
  578. * Delay the execution for a specified amount of time specified
  579. * in miliseconds
  580. */
  581. static void Delay(unsigned int msec);
  582. /**
  583. * Get the operating system name and version
  584. * This is implemented for Win32 only for the moment
  585. */
  586. static kwsys_stl::string GetOperatingSystemNameAndVersion();
  587. /**
  588. * Convert windows-style arguments given as a command-line string
  589. * into more traditional argc/argv arguments.
  590. * Note that argv[0] will be assigned the executable name using
  591. * the ::GetModuleFileName function.
  592. */
  593. static void ConvertWindowsCommandLineToUnixArguments(
  594. const char *cmd_line, int *argc, char ***argv);
  595. protected:
  596. // these two functions can be called from ConvertToOutputPath
  597. /**
  598. * Convert the path to string that can be used in a windows project or
  599. * makefile. Double slashes are removed if they are not at the start of
  600. * the string, the slashes are converted to windows style backslashes, and
  601. * if there are spaces in the string it is double quoted.
  602. */
  603. static kwsys_stl::string ConvertToWindowsOutputPath(const char*);
  604. private:
  605. /**
  606. * Allocate the std::map that serve as the Path Translation table.
  607. */
  608. static void ClassInitialize();
  609. /**
  610. * Deallocate the std::map that serve as the Path Translation table.
  611. */
  612. static void ClassFinalize();
  613. /**
  614. * This method prevents warning on SGI
  615. */
  616. SystemToolsManager* GetSystemToolsManager()
  617. {
  618. return &SystemToolsManagerInstance;
  619. }
  620. /**
  621. * Path translation table from dir to refdir
  622. * Each time 'dir' will be found it will be replace by 'refdir'
  623. */
  624. static SystemToolsTranslationMap *TranslationMap;
  625. friend class SystemToolsManager;
  626. };
  627. } // namespace @KWSYS_NAMESPACE@
  628. /* Undefine temporary macros. */
  629. #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  630. # undef kwsys_stl
  631. # undef kwsys_ios
  632. #endif
  633. #endif