MRPT  1.9.9
filesystem.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-2018, 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 "system-precomp.h" // Precompiled headers
11 
13 #include <mrpt/system/filesystem.h>
14 #include <mrpt/system/os.h> // for sprintf
15 #include <mrpt/core/format.h>
16 #include <mrpt/core/exceptions.h> // for MRPT_END, MRPT_START, e
17 
18 #include <cstring>
19 #include <string>
20 #include <vector>
21 #include <stdio.h>
22 #include <algorithm>
23 
24 #ifdef _WIN32
25 #include <conio.h>
26 #include <windows.h>
27 #include <process.h>
28 #include <tlhelp32.h>
29 #include <sys/utime.h>
30 #include <io.h>
31 #include <direct.h>
32 #else
33 #include <termios.h>
34 #include <sys/time.h>
35 #include <time.h>
36 #include <unistd.h>
37 #include <utime.h>
38 #include <errno.h>
39 #endif
40 
41 #include <sys/types.h>
42 #include <sys/stat.h>
43 
44 #if !defined(_MSC_VER)
45 #define _access access
46 #define _rmdir rmdir
47 #ifndef _stat // It seems MinGW already defines this.
48 #define _stat stat
49 #endif
50 #endif
51 
52 using namespace mrpt;
53 using namespace mrpt::system;
54 using namespace std;
55 
56 /*---------------------------------------------------------------
57  ExtractFileName
58  Extracts just the name of a filename from a
59  complete path plus name plus extension.
60  ---------------------------------------------------------------*/
61 string mrpt::system::extractFileName(const string& filePath)
62 {
63  int i, dotPos = int(filePath.size());
64  if (filePath.size() < 2) return string("");
65 
66  for (i = (int)filePath.size() - 1;
67  i >= 0 && !(filePath[i] == '\\' || filePath[i] == '/'); i--)
68  if (dotPos == int(filePath.size()) && filePath[i] == '.') dotPos = i;
69  return filePath.substr(i + 1, dotPos - i - 1);
70 }
71 
72 /*---------------------------------------------------------------
73  ExtractFileDirectory
74  Extracts just the directory of a filename from a
75  complete path plus name plus extension.
76  ---------------------------------------------------------------*/
77 string mrpt::system::extractFileDirectory(const string& filePath)
78 {
79  if (filePath.size() < 2) return filePath;
80 
81  // Search the first "/" or "\" from the right:
82  int i;
83  for (i = (int)filePath.size() - 1; i > 0; i--)
84  if (filePath[i] == '\\' || filePath[i] == '/') break;
85 
86  if (!i)
87  return string("");
88  else
89  return filePath.substr(0, i + 1);
90 }
91 
92 /*---------------------------------------------------------------
93  ExtractFileName
94  Extracts just the name of a filename from a
95  complete path plus name plus extension.
96  ---------------------------------------------------------------*/
98  const string& filePath, bool ignore_gz)
99 {
100  if (filePath.size() < 2) return string("");
101 
102  size_t i_end = filePath.size() - 1;
103 
104  int i = (int)(i_end);
105  while (i > 0)
106  {
107  if (filePath[i] == '.')
108  {
109  string the_ext = filePath.substr(i + 1, i_end - i);
110  if (!ignore_gz || the_ext != "gz")
111  return the_ext;
112  else
113  {
114  i_end = --i;
115  }
116  }
117  else
118  i--;
119  }
120  // No extension:
121  return string("");
122 }
123 
124 /*---------------------------------------------------------------
125  FileExists
126  ---------------------------------------------------------------*/
127 bool mrpt::system::fileExists(const string& path)
128 {
129  return 0 ==
130  _access(path.c_str(), 0x00); // 0x00 = Check for existence only!
131 }
132 
133 /*---------------------------------------------------------------
134  directoryExists
135  ---------------------------------------------------------------*/
137 {
138  std::string path = _path;
139 
140  // Remove the trailing "/" or "\\":
141  if (!path.empty() && (*path.rbegin() == '/' || *path.rbegin() == '\\'))
142  path = path.substr(0, path.size() - 1);
143 
144  // Verify it's a directory:
145  struct _stat buf;
146  if (0 != _stat(path.c_str(), &buf)) return false;
147 
148 #ifdef _WIN32
149  return 0 != (buf.st_mode & _S_IFDIR);
150 #else
151  return S_ISDIR(buf.st_mode);
152 #endif
153 }
154 
155 /*---------------------------------------------------------------
156  createDirectory
157  ---------------------------------------------------------------*/
158 bool mrpt::system::createDirectory(const string& dirName)
159 {
160 #ifdef _WIN32
161  bool rc = 0 != CreateDirectoryA(dirName.c_str(), nullptr);
162  return (rc || GetLastError() == ERROR_ALREADY_EXISTS);
163 #else
164  int ret = mkdir(dirName.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
165  if (ret && errno != EEXIST) // We ignore this error...
166  {
167  string str = format("[createDirectory %s]", dirName.c_str());
168  perror(str.c_str());
169  return false;
170  }
171  else
172  return true; // OK
173 #endif
174 }
175 
176 /*---------------------------------------------------------------
177  deleteFile
178  ---------------------------------------------------------------*/
179 bool mrpt::system::deleteFile(const string& fileName)
180 {
181  return 0 == remove(fileName.c_str());
182 }
183 
184 /*---------------------------------------------------------------
185  mrpt::system::deleteFiles
186 ---------------------------------------------------------------*/
187 void mrpt::system::deleteFiles(const string& s)
188 {
189  MRPT_START
190  size_t len = s.size() + 20;
191  char* aux = new char[len];
192 #ifdef _WIN32
193  os::sprintf(aux, len, "del %s", &s[0]);
194  for (char* c = aux; *c; c++)
195  if (*c == '/') *c = '\\';
196  os::strcat(aux, len, " /Q");
197 #else
198  os::sprintf(aux, len, "rm %s", &s[0]);
199 #endif
200 
201  int res = ::system(aux);
202  if (res)
203  {
204  fprintf(
205  stderr,
206  "[mrpt::system::deleteFiles] Warning: error invoking: `%s`\n", aux);
207  }
208  delete[] aux;
209  MRPT_END
210 }
211 
212 /*---------------------------------------------------------------
213  deleteFilesInDirectory
214 ---------------------------------------------------------------*/
216  const string& path, bool deleteDirectoryAsWell)
217 {
218  if (!directoryExists(path)) return false;
219 
222  path, FILE_ATTRIB_ARCHIVE | FILE_ATTRIB_DIRECTORY, lstFiles);
223 
224  for (CDirectoryExplorer::TFileInfoList::iterator i = lstFiles.begin();
225  i != lstFiles.end(); ++i)
226  {
227  if (i->isDir)
228  {
229  if (i->name != "." && i->name != "..")
230  {
231  if (!mrpt::system::deleteFilesInDirectory(i->wholePath, true))
232  return false;
233  }
234  }
235  else
236  {
237  if (!mrpt::system::deleteFile(i->wholePath)) return false;
238  }
239  }
240 
241  // Finally, delete the directory itselt.
242  if (deleteDirectoryAsWell)
243  return 0 == _rmdir(path.c_str());
244  else
245  return true;
246 }
247 
249 {
250  MRPT_START
251 
252 #ifdef _WIN32
253  char auxBuf[MAX_PATH] = "";
254  if (!::GetCurrentDirectoryA(sizeof(auxBuf) - 1, auxBuf))
255  THROW_EXCEPTION("Error getting current working directory!");
256  return std::string(auxBuf);
257 
258 #else
259  size_t size = 100;
260  for (;;)
261  {
262  char* buffer = (char*)malloc(size);
263  if (::getcwd(buffer, size) == buffer)
264  {
266  free(buffer);
267  return s;
268  }
269  free(buffer);
270  if (errno != ERANGE)
271  THROW_EXCEPTION("Error getting current working directory!");
272  size *= 2;
273  }
274 #endif
275 
276  MRPT_END
277 }
278 
279 /*---------------------------------------------------------------
280  getTempFileName
281  ---------------------------------------------------------------*/
283 {
284 #ifdef _WIN32
285  FILETIME tt;
286  GetSystemTimeAsFileTime(&tt);
287  const UINT uniq = static_cast<UINT>(tt.dwLowDateTime);
288  char TMP_PATH[MAX_PATH];
289  char tmpPath[MAX_PATH];
290  GetTempPathA(MAX_PATH, tmpPath);
291  GetTempFileNameA(tmpPath, "mrpt", uniq, TMP_PATH);
292  return std::string(TMP_PATH);
293 #else
294  char tmp[] = "/tmp/mrpt_tempXXXXXX";
295  int fd;
296  fd = mkstemp(tmp);
297  ASSERT_(fd >= 0);
298  close(fd);
299  return std::string(tmp);
300 #endif
301 }
302 
303 /** Renames a file - If the target path is different and the filesystem allows
304  * it, it will be moved to the new location.
305  * \return false on any error. In that case, if a pointer to a receiver string
306  * is passed in error_msg, a description of the error is saved there.
307  */
309  const string& oldFileName, const string& newFileName,
310  std::string* error_msg)
311 {
312  bool ret_err = 0 == rename(oldFileName.c_str(), newFileName.c_str());
313 
314  if (error_msg)
315  {
316  if (ret_err)
317  *error_msg = strerror(errno);
318  else
319  *error_msg = "";
320  }
321 
322  return ret_err;
323 }
324 
325 /*---------------------------------------------------------------
326  fileNameStripInvalidChars
327 ---------------------------------------------------------------*/
329  const std::string& filename, const char replacement_to_invalid_chars)
330 {
331  const char forbid[] = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};
332  const unsigned int nForbid = sizeof(forbid) / sizeof(forbid[0]);
333 
334  string ret(filename);
335  for (string::iterator c = ret.begin(); c != ret.end(); ++c)
336  {
337  bool invalid = (*c < 32);
338 
339  for (unsigned int i = 0; !invalid && i < nForbid; i++)
340  if (*c == forbid[i]) invalid = true;
341 
342  if (invalid) *c = '_';
343  }
344  return ret;
345 }
346 
347 /*---------------------------------------------------------------
348  getFileSize
349 ---------------------------------------------------------------*/
351 {
352 #if defined(_MSC_VER)
353  // Visual Studio:
354  struct __stat64 filStat;
355  if (_stat64(fileName.c_str(), &filStat))
356  return uint64_t(-1);
357  else
358  return uint64_t(filStat.st_size);
359 #else
360  // The rest of the world:
361  struct stat filStat;
362  if (stat(fileName.c_str(), &filStat))
363  return uint64_t(-1);
364  else
365  return uint64_t(filStat.st_size);
366 #endif
367 }
368 
369 /** Replace the filename extension by another one. */
371  const std::string& filePath, const std::string& newExtension)
372 {
373  if (filePath.size() < 2) return filePath;
374 
375  const size_t i_end = filePath.size() - 1;
376 
377  for (int i = int(i_end); i > 0; i--)
378  if (filePath[i] == '.') return filePath.substr(0, i + 1) + newExtension;
379 
380  // No extension found: add it:
381  return filePath + string(".") + newExtension;
382 }
383 
384 /*---------------------------------------------------------------
385  copyFile
386 ---------------------------------------------------------------*/
388  const std::string& sourceFile, const std::string& targetFile,
389  std::string* outErrStr, bool copyAttribs)
390 {
391  const std::string org =
393  const std::string trg =
395 
396  const bool fil_exs = fileExists(org);
397  const bool dir_exs = directoryExists(org);
398 
399  // Is source a directory?
400  if (!fil_exs)
401  {
402  if (outErrStr)
403  *outErrStr =
404  string("Source does not exist or permission denied!: ") + org;
405  return false;
406  }
407  if (dir_exs)
408  {
409  if (outErrStr) *outErrStr = string("Is source a directory?: ") + org;
410  return false;
411  }
412 
413  // Check if source file exists and we have access to open it:
414  FILE* f_src = fopen(org.c_str(), "rb");
415  if (!f_src)
416  {
417  if (outErrStr)
418  *outErrStr = string(
419  "Source file exists but cannot open it... is file "
420  "being used?: ") +
421  org;
422  return false;
423  }
424 
425  // Assure that "target" is not an existing directory:
426  if (directoryExists(trg))
427  {
428  if (outErrStr)
429  *outErrStr = string("Target cannot be a directory: ") + trg;
430  fclose(f_src);
431  return false;
432  }
433 
434  // Try to open the file for writting:
435  FILE* f_trg = fopen(trg.c_str(), "wb");
436  if (!f_trg)
437  {
438  if (!fileExists(trg))
439  {
440  // It does not exist and does not allow us to create it:
441  if (outErrStr)
442  *outErrStr = string("Cannot create target file: ") + trg;
443  fclose(f_src);
444  return false;
445  }
446  else
447  {
448 // It exists, but cannot overwrite it:
449 
450 #ifdef _WIN32
451  // Try changing the permissions of the target file:
452  DWORD dwProp = GetFileAttributesA(trg.c_str());
453  if (dwProp == INVALID_FILE_ATTRIBUTES)
454  {
455  if (outErrStr)
456  *outErrStr =
457  string(
458  "Cannot get file attributes for target file, "
459  "trying to remove a possible read-only attribute "
460  "after first attempt of copy failed, for: ") +
461  trg;
462  fclose(f_src);
463  return false;
464  }
465 
466  dwProp &= ~FILE_ATTRIBUTE_HIDDEN;
467  dwProp &= ~FILE_ATTRIBUTE_READONLY;
468  dwProp &= ~FILE_ATTRIBUTE_SYSTEM;
469 
470  if (!SetFileAttributesA(trg.c_str(), dwProp))
471  {
472  if (outErrStr)
473  *outErrStr =
474  string(
475  "Cannot get file attributes for target file, "
476  "trying to remove a possible read-only attribute "
477  "after first attempt of copy failed, for: ") +
478  trg;
479  fclose(f_src);
480  return false;
481  }
482 
483  // Try again:
484  f_trg = fopen(trg.c_str(), "wb");
485  if (!f_trg)
486  {
487  if (outErrStr)
488  *outErrStr = string(
489  "Cannot overwrite target file, even after "
490  "changing file attributes! : ") +
491  trg;
492  fclose(f_src);
493  return false;
494  }
495 #else
496  // Try changing the permissions of the target file:
497  if (chmod(trg.c_str(), S_IRWXU | S_IRGRP | S_IROTH))
498  {
499  if (outErrStr)
500  *outErrStr =
501  string(
502  "Cannot set file permissions for target file, "
503  "trying to remove a possible read-only attribute "
504  "after first attempt of copy failed, for: ") +
505  trg;
506  fclose(f_src);
507  return false;
508  }
509 
510  // Try again:
511  f_trg = fopen(trg.c_str(), "wb");
512  if (!f_trg)
513  {
514  if (outErrStr)
515  *outErrStr = string(
516  "Cannot overwrite target file, even after "
517  "changing file permissions! : ") +
518  trg;
519  fclose(f_src);
520  return false;
521  }
522 #endif
523  }
524  }
525 
526  // Ok, here we have both files open: Perform the copy:
527  char buf[66000];
528  size_t nBytes = 0;
529  while (0 != (nBytes = fread(buf, 1, 64 * 1024, f_src)))
530  {
531  if (nBytes != fwrite(buf, 1, nBytes, f_trg))
532  {
533  if (outErrStr)
534  *outErrStr = string(
535  "Error writing the contents of the target "
536  "file (disk full?): ") +
537  trg;
538  fclose(f_src);
539  fclose(f_trg);
540  return false;
541  }
542  }
543 
544  // Close file handles:
545  fclose(f_src);
546  fclose(f_trg);
547 
548  // In Windows only, copy the file attributes:
549  if (copyAttribs)
550  {
551 #ifdef _WIN32
552  DWORD dwPropSrc = GetFileAttributesA(org.c_str());
553  if (dwPropSrc == INVALID_FILE_ATTRIBUTES)
554  {
555  if (outErrStr)
556  *outErrStr =
557  string(
558  "Cannot get the file attributes for source file: ") +
559  org;
560  return false;
561  }
562  DWORD dwPropTrg = GetFileAttributesA(trg.c_str());
563  if (dwPropTrg == INVALID_FILE_ATTRIBUTES)
564  {
565  if (outErrStr)
566  *outErrStr =
567  string(
568  "Cannot get the file attributes for target file: ") +
569  trg;
570  return false;
571  }
572 
573  // Leave only those attributes which can be legally copied:
574  // (Refer to: http://msdn2.microsoft.com/en-us/library/aa365535.aspx )
575  dwPropSrc &= FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN |
576  FILE_ATTRIBUTE_NORMAL |
577  FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
578  FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_READONLY |
579  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_TEMPORARY;
580 
581  // Copy them to the target attributes:
582  dwPropTrg &=
583  ~(FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN |
584  FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
585  FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_READONLY |
586  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_TEMPORARY);
587  dwPropTrg |= dwPropSrc;
588 
589  // Set attributes of target file:
590  if (!SetFileAttributesA(trg.c_str(), dwPropTrg))
591  {
592  if (outErrStr)
593  *outErrStr =
594  string("Cannot set file attributes for target file: ") +
595  trg;
596  return false;
597  }
598 #else
599 // Linux: No file attributes to copy.
600 #endif
601  } // end // if (copyAttribs)
602 
603  return true;
604 }
605 
606 // ---------------------------------------------------------------
607 // filePathSeparatorsToNative
608 // ---------------------------------------------------------------
610  const std::string& filePath)
611 {
612  std::string ret = filePath;
613  const size_t N = ret.size();
614  for (size_t i = 0; i < N; i++)
615  {
616 #ifdef _WIN32
617  if (ret[i] == '/') ret[i] = '\\';
618 #else
619  if (ret[i] == '\\') ret[i] = '/';
620 #endif
621  }
622  return ret;
623 }
624 
626 {
627  struct stat fS;
628  if (0 != stat(filename.c_str(), &fS))
629  return 0;
630  else
631  return fS.st_mtime;
632 }
633 
634 #include <mrpt/version.h>
635 // Read docs in .h
637 {
638  using std::string;
639  using std::vector;
640 
641  static vector<string> sPaths;
642  static string sDetectedPath;
643  static bool is_first = true;
644  if (is_first)
645  {
646  is_first = false;
647 
648  // Source dir:
649  sPaths.push_back(
650  string(MRPT_CMAKE_SOURCE_DIR) + string("/share/mrpt/"));
651  // Install dir:
652  sPaths.push_back(
653  string(MRPT_CMAKE_INSTALL_PREFIX) + string("/share/mrpt/"));
654 
655  // Program path & ".." & "../..":
656  char buf[2048];
657  bool sBufOk = false;
658 #ifdef _WIN32
659  sBufOk = (0 != GetModuleFileNameA(NULL, buf, sizeof(buf)));
660 #endif
661 #ifdef MRPT_OS_LINUX
662  sBufOk = (-1 != readlink("/proc/self/exe", buf, sizeof(buf)));
663 #endif
664 
665  if (sBufOk)
666  {
667  string sBuf = string(buf);
668  std::replace(sBuf.begin(), sBuf.end(), '\\', '/');
669  sBuf = extractFileDirectory(sBuf);
670  sPaths.push_back(sBuf + string("share/mrpt/"));
671  sPaths.push_back(sBuf + string("../share/mrpt/"));
672  sPaths.push_back(sBuf + string("../../share/mrpt/"));
673  }
674 
675  for (const auto& e : sPaths)
676  if (directoryExists(e))
677  {
678  sDetectedPath = e;
679  break;
680  }
681  }
682  return sDetectedPath;
683 }
Scalar * iterator
Definition: eigen_plugins.h:26
static void explore(const std::string &path, const unsigned long mask, TFileInfoList &outList)
The path of the directory to examine must be passed to this constructor, among the According to the f...
bool createDirectory(const std::string &dirName)
Creates a directory.
Definition: filesystem.cpp:158
#define MRPT_START
Definition: exceptions.h:262
#define _stat
Definition: filesystem.cpp:48
std::string getShareMRPTDir()
Attempts to find the directory [PREFIX/]share/mrpt/ and returns its absolute path, or empty string if not found.
Definition: filesystem.cpp:636
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:273
GLuint buffer
Definition: glext.h:3917
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
Definition: filesystem.cpp:127
bool renameFile(const std::string &oldFileName, const std::string &newFileName, std::string *error_msg=nullptr)
Renames a file - If the target path is different and the filesystem allows it, it will be moved to th...
Definition: filesystem.cpp:308
STL namespace.
std::string fileNameStripInvalidChars(const std::string &filename, const char replacement_to_invalid_chars='_')
Replace invalid filename chars by underscores (&#39;_&#39;) or any other user-given char. ...
Definition: filesystem.cpp:328
#define FILE_ATTRIB_ARCHIVE
GLdouble s
Definition: glext.h:3676
GLenum GLsizei len
Definition: glext.h:4712
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Definition: filesystem.cpp:282
std::string filePathSeparatorsToNative(const std::string &filePath)
Windows: replace all &#39;/&#39;->&#39;\&#39; , in Linux/MacOS: replace all &#39;\&#39;->&#39;/&#39;.
Definition: filesystem.cpp:609
const GLubyte * c
Definition: glext.h:6313
std::string fileNameChangeExtension(const std::string &filename, const std::string &newExtension)
Replace the filename extension by another one.
Definition: filesystem.cpp:370
void deleteFiles(const std::string &s)
Delete one or more files, especified by the (optional) path and the file name (including &#39;...
Definition: filesystem.cpp:187
#define _rmdir
Definition: filesystem.cpp:46
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
Definition: filesystem.cpp:97
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:406
unsigned __int64 uint64_t
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define FILE_ATTRIB_DIRECTORY
char * strcat(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcat.
Definition: os.cpp:282
std::string getcwd()
Returns the current working directory.
Definition: filesystem.cpp:248
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
#define MRPT_END
Definition: exceptions.h:266
#define _access
Definition: filesystem.cpp:45
bool deleteFile(const std::string &fileName)
Deletes a single file.
Definition: filesystem.cpp:179
bool copyFile(const std::string &sourceFile, const std::string &targetFile, std::string *outErrStr=nullptr, bool copyAttribs=true)
Copies file sourceFile to targetFile.
Definition: filesystem.cpp:387
bool deleteFilesInDirectory(const std::string &s, bool deleteDirectoryAsWell=false)
Delete all the files in a given directory (nothing done if directory does not exists, or path is a file).
Definition: filesystem.cpp:215
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:255
GLsizeiptr size
Definition: glext.h:3923
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
GLuint res
Definition: glext.h:7268
uint64_t getFileSize(const std::string &fileName)
Return the size of the given file, or size_t(-1) if some error is found accessing that file...
Definition: filesystem.cpp:350
std::string extractFileName(const std::string &filePath)
Extract just the name (without extension) of a filename from a complete path plus name plus extension...
Definition: filesystem.cpp:61
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 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:189
time_t getFileModificationTime(const std::string &filename)
Return the time of the file last modification, or "0" if the file doesn&#39;t exist.
Definition: filesystem.cpp:625



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020