Main MRPT website > C++ reference for MRPT 1.9.9
os.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/system/os.h>
13 #include <mrpt/system/filesystem.h>
14 
15 #ifndef HAVE_TIMEGM
16 #endif // HAVE_TIMEGM
17 
18 #include <cstring>
19 #include <float.h>
20 #include <iostream>
21 #include <algorithm>
22 #include <cctype>
23 #include <ctime>
24 #include <cstdio>
25 
26 #ifdef MRPT_OS_WINDOWS
27 #include <conio.h>
28 #include <windows.h>
29 #include <tlhelp32.h>
30 #include <sys/utime.h>
31 #include <io.h>
32 #include <direct.h>
33 #else
34 #include <pthread.h>
35 #include <termios.h>
36 #include <poll.h>
37 #include <unistd.h>
38 #include <sys/select.h>
39 #include <sys/time.h>
40 #include <time.h>
41 #include <unistd.h>
42 #include <utime.h>
43 #include <errno.h>
44 // #include <signal.h>
45 #endif
46 
47 #include <sys/types.h>
48 #include <sys/stat.h>
49 
50 #ifdef MRPT_OS_LINUX
51 #define _access access
52 #define _rmdir rmdir
53 #define _stat stat
54 #endif
55 
56 #include <sstream>
57 
58 using namespace mrpt;
59 using namespace mrpt::utils;
60 using namespace mrpt::system;
61 using namespace std;
62 
63 #ifndef MRPT_OS_WINDOWS
64 /** By ninjalj in
65  * http://stackoverflow.com/questions/3962263/checking-if-a-key-was-pressed
66  */
67 void my_aux_sighandler(int) {}
68 int myKbhit(void)
69 {
70  struct termios oldtio, curtio;
71  // struct sigaction sa;
72 
73  /* Save stdin terminal attributes */
74  tcgetattr(0, &oldtio);
75 
76  // memset(&sa, 0, sizeof(struct sigaction));
77 
78  /* Set non-canonical no-echo for stdin */
79  tcgetattr(0, &curtio);
80  curtio.c_lflag &= ~(ICANON | ECHO);
81  tcsetattr(0, TCSANOW, &curtio);
82 
83  struct pollfd pfds[1];
84 
85  /* See if there is data available */
86  pfds[0].fd = 0;
87  pfds[0].events = POLLIN;
88  const int ret = poll(pfds, 1, 0);
89 
90  /* restore terminal attributes */
91  tcsetattr(0, TCSANOW, &oldtio);
92 
93  return (ret > 0);
94 }
95 
96 #endif
97 
98 /*---------------------------------------------------------------
99  timegm
100  ---------------------------------------------------------------*/
101 #ifdef HAVE_TIMEGM
102 time_t mrpt::system::os::timegm(struct tm* tm) { return ::timegm(tm); }
103 #else
104 // Version for MSVC>=2005, which lacks "timegm"
105 #ifdef HAVE_MKGMTIME
106 time_t mrpt::system::os::timegm(struct tm* tm) { return ::_mkgmtime(tm); }
107 #else
108 // generic version, slower but probably not used in any modern compiler!
109 time_t mrpt::system::os::timegm(struct tm* tm)
110 {
111  static std::mutex cs;
112  std::lock_guard<std::mutex> lock(cs);
113 
114  time_t ret;
115  char tz[256];
116 
117  /* save current timezone and set UTC */
118  char* org_tz = getenv("TZ");
119  if (org_tz) os::strcpy(tz, sizeof(tz), org_tz);
120 
121  putenv("TZ=UTC"); /* use Coordinated Universal Time (i.e. zero offset) */
122  tzset();
123 
124  ret = mktime(tm);
125  if (org_tz)
126  {
127  char buf[256];
128  mrpt::system::os::sprintf(buf, sizeof(buf), "TZ=%s", tz);
129  putenv(buf);
130  }
131  else
132  putenv("TZ=");
133  tzset();
134 
135  return ret;
136 }
137 
138 #endif
139 #endif // HAVE_TIMEGM
140 
141 /*---------------------------------------------------------------
142  mrpt::system::MRPT_getCompilationDate
143 ---------------------------------------------------------------*/
144 #include <mrpt/version.h>
145 #include <errno.h>
146 #include <limits>
147 #include <climits>
148 #include <ctime>
149 #include <cstdlib>
150 
152 {
153  time_t now;
154  char* endptr;
155  const char* source_date_epoch = MRPT_SOURCE_DATE_EPOCH;
156 
157  errno = 0;
158  unsigned long epoch = strtoul(source_date_epoch, &endptr, 10);
159  if (epoch == 0 ||
160  ((errno == ERANGE &&
161  (epoch == std::numeric_limits<unsigned long>::max() || epoch == 0)) ||
162  (errno != 0 && epoch == 0)))
163  {
164  // Last resort:
165  now = time(nullptr);
166  }
167  else
168  {
169  now = epoch;
170  }
171  struct tm* build_time = gmtime(&now);
172  const int year = build_time->tm_year + 1900;
173  const int month = build_time->tm_mon + 1;
174  const int day = build_time->tm_mday;
175 
176  return mrpt::format(
177  "%i-%02i-%02i %02i:%02i:%02i UTC", year, month, day,
178  build_time->tm_hour, build_time->tm_min, build_time->tm_sec);
179 }
180 
181 /*---------------------------------------------------------------
182  mrpt::system::MRPT_getVersion
183 ---------------------------------------------------------------*/
184 string mrpt::system::MRPT_getVersion() { return string(::MRPT_version_str); }
185 /*---------------------------------------------------------------
186  sprintf
187 ---------------------------------------------------------------*/
188 int os::sprintf(char* buf, size_t bufSize, const char* format, ...) noexcept
189 {
191 
192  int result;
193  va_list ap;
194  va_start(ap, format);
195 
196 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
197  // Use a secure version in Visual Studio 2005:
198  result = ::vsprintf_s(buf, bufSize, format, ap);
199 #else
200  // Use standard version:
201  result = ::vsprintf(buf, format, ap);
202 #endif
203 
204  va_end(ap);
205  return result;
206 }
207 
208 /*---------------------------------------------------------------
209  vsprintf
210 ---------------------------------------------------------------*/
212  char* buf, size_t bufSize, const char* format, va_list args) noexcept
213 {
215 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
216  // Use a secure version in Visual Studio 2005:
217  return ::vsprintf_s(buf, bufSize, format, args);
218 #else
219  // Use standard version:
220  return ::vsprintf(buf, format, args);
221 #endif
222 }
223 
224 /*---------------------------------------------------------------
225  vsnprintf
226 ---------------------------------------------------------------*/
228  char* buf, size_t bufSize, const char* format, va_list args) noexcept
229 {
230 #if defined(_MSC_VER)
231 #if (_MSC_VER >= 1400)
232  // Use a secure version in Visual Studio 2005:
233  return ::vsnprintf_s(buf, bufSize, _TRUNCATE, format, args);
234 #else
235  return ::vsprintf(buf, format, args);
236 #endif
237 #else
238  // Use standard version:
239  return ::vsnprintf(buf, bufSize, format, args);
240 #endif
241 }
242 
243 /*---------------------------------------------------------------
244  fopen
245 ---------------------------------------------------------------*/
246 FILE* os::fopen(const std::string& fileName, const char* mode) noexcept
247 {
248  return fopen(fileName.c_str(), mode);
249 }
250 
251 /*---------------------------------------------------------------
252  fopen
253 ---------------------------------------------------------------*/
254 FILE* os::fopen(const char* fileName, const char* mode) noexcept
255 {
256 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
257  // Use a secure version in Visual Studio 2005:
258  FILE* f;
259  if (0 != ::fopen_s(&f, fileName, mode))
260  return NULL;
261  else
262  return f;
263 #else
264  // Use standard version:
265  return ::fopen(fileName, mode);
266 #endif
267 }
268 
269 /*---------------------------------------------------------------
270  fclose
271 ---------------------------------------------------------------*/
272 void os::fclose(FILE* f)
273 {
274  if (!f) THROW_EXCEPTION("Trying to close a nullptr 'FILE*' descriptor")
275  ::fclose(f);
276 }
277 
278 /*---------------------------------------------------------------
279  strcat
280 ---------------------------------------------------------------*/
281 char* os::strcat(char* dest, size_t destSize, const char* source) noexcept
282 {
283  MRPT_UNUSED_PARAM(destSize);
284 
285 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
286  ::strcat_s(dest, destSize, source);
287 #else
288  ::strcat(dest, source);
289 #endif
290  return dest;
291 }
292 
293 /*---------------------------------------------------------------
294  strcpy
295 ---------------------------------------------------------------*/
296 char* os::strcpy(char* dest, size_t destSize, const char* source) noexcept
297 {
298  MRPT_UNUSED_PARAM(destSize);
299 
300 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
301  ::strcpy_s(dest, destSize, source);
302 #else
303  ::strcpy(dest, source);
304 #endif
305  return dest;
306 }
307 
308 /*---------------------------------------------------------------
309  strcmp
310 ---------------------------------------------------------------*/
311 int os::_strcmp(const char* str1, const char* str2) noexcept
312 {
313  return ::strcmp(str1, str2);
314 }
315 
316 /*---------------------------------------------------------------
317  strcmpi
318 ---------------------------------------------------------------*/
319 int os::_strcmpi(const char* str1, const char* str2) noexcept
320 {
321 #ifdef MRPT_OS_WINDOWS
322 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
323  return ::_strcmpi(str1, str2);
324 #else
325  return ::strcmpi(str1, str2);
326 #endif
327 #else
328  return ::strcasecmp(str1, str2);
329 #endif
330 }
331 
332 /** An OS-independent version of strncmp.
333 * \return It will return 0 when both strings are equal, casi sensitive.
334 */
335 int os::_strncmp(const char* str1, const char* str2, size_t count) noexcept
336 {
337  return ::strncmp(str1, str2, count);
338 }
339 
340 /** An OS-independent version of strnicmp.
341 * \return It will return 0 when both strings are equal, casi insensitive.
342 */
343 int os::_strnicmp(const char* str1, const char* str2, size_t count) noexcept
344 {
345 #if defined(_MSC_VER)
346  return ::_strnicmp(str1, str2, count);
347 #else
348  return ::strncasecmp(str1, str2, count);
349 #endif
350 }
351 
352 /*---------------------------------------------------------------
353  memcpy
354 ---------------------------------------------------------------*/
356  void* dest, size_t destSize, const void* src, size_t copyCount) noexcept
357 {
358 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
359  ::memcpy_s(dest, destSize, src, copyCount);
360 #else
361  MRPT_UNUSED_PARAM(destSize);
362  ::memcpy(dest, src, copyCount);
363 #endif
364 }
365 
366 /*---------------------------------------------------------------
367  getch
368 ---------------------------------------------------------------*/
369 int os::getch() noexcept
370 {
371 #ifdef MRPT_OS_WINDOWS
372  return ::getch(); // cin.get();
373 #else
374  struct termios oldt, newt;
375  int ch;
376  tcgetattr(STDIN_FILENO, &oldt);
377  newt = oldt;
378  newt.c_lflag &= ~(ICANON | ECHO);
379  tcsetattr(STDIN_FILENO, TCSANOW, &newt);
380  ch = getchar();
381  tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
382  return ch;
383 #endif
384 }
385 
386 /*---------------------------------------------------------------
387  kbhit
388 ---------------------------------------------------------------*/
389 bool os::kbhit() noexcept
390 {
391 #ifdef MRPT_OS_WINDOWS
392 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
393  return ::_kbhit() != 0;
394 #else
395  return ::kbhit() != 0;
396 #endif
397 #else
398  return myKbhit();
399 #endif
400 }
401 
402 /*---------------------------------------------------------------
403  os::fprintf
404 ---------------------------------------------------------------*/
405 int os::fprintf(FILE* fil, const char* frm, ...) noexcept
406 {
407  int result;
408  va_list ap;
409  va_start(ap, frm);
410 
411 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
412  // Use a secure version in Visual Studio 2005:
413  result = ::vfprintf_s(fil, frm, ap);
414 
415 #else
416  // Use standard version:
417  result = ::vfprintf(fil, frm, ap);
418 #endif
419 
420  va_end(ap);
421  return result;
422 }
423 
424 /*---------------------------------------------------------------
425  mrpt::system::pause
426 ---------------------------------------------------------------*/
427 void mrpt::system::pause(const std::string& msg) noexcept
428 {
429  std::cout << msg << std::endl;
430  os::getch();
431 }
432 
433 /*---------------------------------------------------------------
434  clearConsole
435 ---------------------------------------------------------------*/
437 {
438 #ifdef MRPT_OS_WINDOWS
439  int ret = ::system("cls");
440 #else
441  int ret = ::system("clear");
442 #endif
443  if (ret)
444  cerr << "[mrpt::system::clearConsole] Error invoking 'clear screen' "
445  << endl;
446 }
447 
448 /*---------------------------------------------------------------
449  _strtoll
450  ---------------------------------------------------------------*/
451 int64_t mrpt::system::os::_strtoll(const char* nptr, char** endptr, int base)
452 {
453 #ifdef MRPT_OS_WINDOWS
454  return (int64_t)::strtol(nptr, endptr, base);
455 #else
456  return (int64_t)::strtoll(nptr, endptr, base);
457 #endif
458 }
459 
460 /*---------------------------------------------------------------
461  _strtoull
462  ---------------------------------------------------------------*/
463 uint64_t mrpt::system::os::_strtoull(const char* nptr, char** endptr, int base)
464 {
465 #ifdef MRPT_OS_WINDOWS
466  return (uint64_t)::strtoul(nptr, endptr, base);
467 #else
468  return (uint64_t)::strtoull(nptr, endptr, base);
469 #endif
470 }
471 
472 /** Changes the text color in the console for the text written from now on.
473  * The parameter "color" can be:
474  * - 0 : Normal text color
475  * - 1 : Blue text color
476  * - 2 : Green text color
477  * - 4 : Red text color
478  */
480 {
481  static const int TS_NORMAL = 0;
482  static const int TS_BLUE = 1;
483  static const int TS_GREEN = 2;
484  static const int TS_RED = 4;
485 #ifdef MRPT_OS_WINDOWS
486  static int normal_attributes = -1;
487  HANDLE hstdout =
488  GetStdHandle(changeStdErr ? STD_ERROR_HANDLE : STD_OUTPUT_HANDLE);
489  fflush(changeStdErr ? stderr : stdout);
490 
491  if (normal_attributes < 0)
492  {
493  CONSOLE_SCREEN_BUFFER_INFO info;
494  GetConsoleScreenBufferInfo(hstdout, &info);
495  normal_attributes = info.wAttributes;
496  }
497 
498  SetConsoleTextAttribute(
499  hstdout,
500  (WORD)(
501  color == TS_NORMAL ? normal_attributes
502  : ((color & TS_BLUE ? FOREGROUND_BLUE : 0) |
503  (color & TS_GREEN ? FOREGROUND_GREEN : 0) |
504  (color & TS_RED ? FOREGROUND_RED : 0) |
505  FOREGROUND_INTENSITY)));
506 #else
507  // *nix:
508  static const uint8_t ansi_tab[] = {30, 34, 32, 36, 31, 35, 33, 37};
509  int code = 0;
510  fflush(changeStdErr ? stdout : stderr);
511  if (color != TS_NORMAL)
512  code = ansi_tab[color & (TS_BLUE | TS_GREEN | TS_RED)];
513  fprintf(changeStdErr ? stdout : stderr, "\x1b[%dm", code);
514 #endif
515 }
516 
517 const char* sLicenseTextF =
518  " Mobile Robot Programming Toolkit (MRPT) "
519  " \n"
520  " http://www.mrpt.org/ "
521  " \n"
522  " "
523  " \n"
524  " Copyright (c) 2005-%Y, Individual contributors, see AUTHORS file "
525  "\n"
526  " See: http://www.mrpt.org/Authors - All rights reserved. "
527  " \n"
528  " Released under BSD License. See details in http://www.mrpt.org/License "
529  " \n";
530 
532 {
533  static bool sLicenseTextReady = false;
534  static std::string sLicenseText;
535 
536  if (!sLicenseTextReady)
537  {
538  // Automatically update the last year of the copyright to the
539  // compilation date:
540  time_t rawtime;
541  struct tm* timeinfo;
542  time(&rawtime);
543  timeinfo = localtime(&rawtime);
544 
545  char buf[1024];
546  ::strftime(buf, sizeof(buf), sLicenseTextF, timeinfo);
547  sLicenseText = std::string(buf);
548  sLicenseTextReady = true;
549  }
550  return sLicenseText;
551 }
552 
553 /*---------------------------------------------------------------
554 
555 launchProcess
556 
557 ---------------------------------------------------------------*/
558 
560 
561 {
562 #ifdef MRPT_OS_WINDOWS
563 
564  STARTUPINFOA SI;
565 
566  PROCESS_INFORMATION PI;
567 
568  memset(&SI, 0, sizeof(STARTUPINFOA));
569 
570  SI.cb = sizeof(STARTUPINFOA);
571 
572  if (CreateProcessA(
573  NULL, (LPSTR)command.c_str(), NULL, NULL, true, 0, NULL, NULL, &SI,
574  &PI))
575 
576  {
577  // Wait:
578 
579  WaitForSingleObject(PI.hProcess, INFINITE);
580 
581  return true;
582 
583  } // End of process executed OK
584 
585  else
586 
587  {
588  char str[300];
589 
590  DWORD e = GetLastError();
591 
592  FormatMessageA(
593  FORMAT_MESSAGE_FROM_SYSTEM, 0, e, 0, str, sizeof(str), NULL);
594 
595  // ERROR:
596 
597  std::cerr << "[launchProcess] Couldn't spawn process. Error msg: "
598  << str << std::endl;
599 
600  return false;
601  }
602 
603 #else
604 
605  return 0 == ::system(command.c_str());
606 
607 #endif
608 
609 } // end launchProcess
610 
611 #include <mrpt/mrpt_paths_config.h>
613 {
614  static bool mrpt_shared_first_call = true;
615  static std::string found_mrpt_shared_dir;
616 
617  if (mrpt_shared_first_call)
618  {
619  mrpt_shared_first_call = false;
620 
621  for (int attempt = 0;; attempt++)
622  {
623  std::string dir;
624  switch (attempt)
625  {
626  case 0:
627  dir = string(MRPT_SOURCE_BASE_DIRECTORY) +
628  string("/share/mrpt/");
629  break;
630  case 1:
631  dir = string(MRPT_INSTALL_PREFIX_DIRECTORY) +
632  string("/share/mrpt/");
633  break;
634 #ifdef _WIN32
635  case 2:
636  {
637  char curExe[4096];
638  GetModuleFileNameA(nullptr, curExe, sizeof(curExe));
639 
641  std::string(curExe)) +
642  "/../share/mrpt/";
643  }
644  break;
645 #endif
646 
647  default:
648  found_mrpt_shared_dir = ".";
649  break;
650  };
651  if (!dir.empty() && mrpt::system::directoryExists(dir))
652  found_mrpt_shared_dir = dir;
653 
654  if (!found_mrpt_shared_dir.empty()) break;
655  }
656  }
657 
658  return found_mrpt_shared_dir;
659 } // end of find_mrpt_shared_dir
660 
662  const std::string& command, std::string* output /*=NULL*/,
663  const std::string& mode /*="r"*/)
664 {
665  using namespace std;
666 
667  // Create the stringstream
668  stringstream sout;
669 
670 #ifdef MRPT_OS_LINUX
671  // Run Popen
672  FILE* in;
673  char buff[512];
674 
675  // Test output
676  if (!(in = popen(command.c_str(), mode.c_str())))
677  {
678  sout << "Popen Execution failed!" << endl;
679  *output = sout.str();
680 
681  return -1;
682  }
683 
684  // Parse output
685  while (fgets(buff, sizeof(buff), in) != NULL)
686  {
687  sout << buff;
688  }
689 
690  // Close
691  int exit_code = pclose(in);
692 
693  // set output - if valid pointer given
694  if (output)
695  {
696  *output = sout.str();
697  }
698 
699  // Return exit code
700  return exit_code;
701 #else
702  MRPT_TODO("Write popen alternative for Windows")
703  THROW_EXCEPTION("not implemented for Windows yet!");
704 #endif
705 
706 } // end of executeCommand
GLuint GLuint GLsizei count
Definition: glext.h:3528
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
const char * sLicenseTextF
Definition: os.cpp:517
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
int getch() noexcept
An OS-independent version of getch, which waits until a key is pushed.
Definition: os.cpp:369
int _strncmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strncmp.
Definition: os.cpp:335
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:272
time_t timegm(struct tm *tm)
An OS-independent version of timegm (which is not present in all compilers): converts a time structur...
Definition: os.cpp:109
#define THROW_EXCEPTION(msg)
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
Definition: os.cpp:343
void setConsoleColor(TConsoleColor color, bool changeStdErr=false)
Changes the text color in the console for the text written from now on.
Definition: os.cpp:479
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:76
STL namespace.
std::string MRPT_getCompilationDate()
Returns the MRPT source code timestamp, according to the Reproducible-Builds specifications: https://...
Definition: os.cpp:151
GLuint src
Definition: glext.h:7278
int myKbhit(void)
Definition: os.cpp:68
#define MRPT_TODO(x)
unsigned char uint8_t
Definition: rptypes.h:41
std::string find_mrpt_shared_dir()
Finds the "[MRPT]/share/mrpt/" directory, if available in the system.
Definition: os.cpp:612
int executeCommand(const std::string &command, std::string *output=NULL, const std::string &mode="r")
Execute Generic Shell Command.
Definition: os.cpp:661
GLuint color
Definition: glext.h:8300
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
__int64 int64_t
Definition: rptypes.h:49
void clearConsole()
Clears the console window.
Definition: os.cpp:436
#define vsnprintf
Definition: zutil.h:203
TConsoleColor
For use in setConsoleColor.
Definition: os.h:178
GLsizei const GLchar ** string
Definition: glext.h:4101
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
Definition: os.cpp:405
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
Definition: os.cpp:427
GLint mode
Definition: glext.h:5669
unsigned __int64 uint64_t
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
int int vsprintf(char *buf, size_t bufSize, const char *format, va_list args) noexcept
An OS-independent version of vsprintf (Notice the bufSize param, which may be ignored in some compile...
Definition: os.cpp:211
Definition: inftrees.h:28
char * strcat(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcat.
Definition: os.cpp:281
void my_aux_sighandler(int)
By ninjalj in http://stackoverflow.com/questions/3962263/checking-if-a-key-was-pressed.
Definition: os.cpp:67
GLuint in
Definition: glext.h:7274
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:389
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
uint64_t _strtoull(const char *nptr, char **endptr, int base)
An OS-independent version of strtoull.
Definition: os.cpp:463
GLbyte GLbyte tz
Definition: glext.h:6092
GLuint GLsizei bufSize
Definition: glext.h:4064
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:254
GLenum GLsizei GLenum format
Definition: glext.h:3531
bool directoryExists(const std::string &fileName)
Test if a given directory exists (it fails if the given path refers to an existing file)...
Definition: filesystem.cpp:136
std::string MRPT_getVersion()
Returns a string describing the MRPT version.
Definition: os.cpp:184
int64_t _strtoll(const char *nptr, char **endptr, int base)
An OS-independent version of strtoll.
Definition: os.cpp:451
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
Definition: os.cpp:296
bool launchProcess(const std::string &command)
Executes the given command (which may contain a program + arguments), and waits until it finishes...
Definition: os.cpp:559
const std::string & getMRPTLicense()
Returns a const ref to a text with the same text that appears at the beginning of each MRPT file (use...
Definition: os.cpp:531
std::string extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
Definition: filesystem.cpp:77
int _strcmp(const char *str1, const char *str2) noexcept
An OS-independent version of strcmp.
Definition: os.cpp:311
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
Definition: os.cpp:188
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
Definition: os.cpp:355
int _strcmpi(const char *str1, const char *str2) noexcept
An OS-independent version of strcmpi.
Definition: os.cpp:319



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019