Main MRPT website > C++ reference for 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-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 
13 #include <mrpt/system/filesystem.h>
14 #include <mrpt/system/os.h> // for sprintf
15 #include "mrpt/utils/bits.h" // for format
16 #include "mrpt/utils/mrpt_macros.h" // for MRPT_END, MRPT_START, e
17 
18 #include <cstring>
19 #include <string>
20 #include <vector>
21 #include <stdio.h>
22 
23 #ifdef MRPT_OS_WINDOWS
24 #include <conio.h>
25 #include <windows.h>
26 #include <process.h>
27 #include <tlhelp32.h>
28 #include <sys/utime.h>
29 #include <io.h>
30 #include <direct.h>
31 #else
32 #include <termios.h>
33 #include <sys/time.h>
34 #include <time.h>
35 #include <unistd.h>
36 #include <utime.h>
37 #include <errno.h>
38 #endif
39 
40 #include <sys/types.h>
41 #include <sys/stat.h>
42 
43 #if !defined(_MSC_VER)
44 #define _access access
45 #define _rmdir rmdir
46 #ifndef _stat // It seems MinGW already defines this.
47 #define _stat stat
48 #endif
49 #endif
50 
51 using namespace mrpt;
52 using namespace mrpt::utils;
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 MRPT_OS_WINDOWS
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 MRPT_OS_WINDOWS
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 MRPT_OS_WINDOWS
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  cerr << "[mrpt::system::deleteFiles] Warning: error invoking: " << aux
205  << endl;
206  }
207  delete[] aux;
208  MRPT_END
209 }
210 
211 /*---------------------------------------------------------------
212  deleteFilesInDirectory
213 ---------------------------------------------------------------*/
215  const string& path, bool deleteDirectoryAsWell)
216 {
217  if (!directoryExists(path)) return false;
218 
220  CDirectoryExplorer::explore(
221  path, FILE_ATTRIB_ARCHIVE | FILE_ATTRIB_DIRECTORY, lstFiles);
222 
223  for (CDirectoryExplorer::TFileInfoList::iterator i = lstFiles.begin();
224  i != lstFiles.end(); ++i)
225  {
226  if (i->isDir)
227  {
228  if (i->name != "." && i->name != "..")
229  {
230  if (!mrpt::system::deleteFilesInDirectory(i->wholePath, true))
231  return false;
232  }
233  }
234  else
235  {
236  if (!mrpt::system::deleteFile(i->wholePath)) return false;
237  }
238  }
239 
240  // Finally, delete the directory itselt.
241  if (deleteDirectoryAsWell)
242  return 0 == _rmdir(path.c_str());
243  else
244  return true;
245 }
246 
248 {
249  MRPT_START
250 
251 #ifdef MRPT_OS_WINDOWS
252  char auxBuf[MAX_PATH] = "";
253  if (!::GetCurrentDirectoryA(sizeof(auxBuf) - 1, auxBuf))
254  THROW_EXCEPTION("Error getting current working directory!");
255  return std::string(auxBuf);
256 
257 #else
258  size_t size = 100;
259  for (;;)
260  {
261  char* buffer = (char*)malloc(size);
262  if (::getcwd(buffer, size) == buffer)
263  {
265  free(buffer);
266  return s;
267  }
268  free(buffer);
269  if (errno != ERANGE)
270  THROW_EXCEPTION("Error getting current working directory!");
271  size *= 2;
272  }
273 #endif
274 
275  MRPT_END
276 }
277 
278 /*---------------------------------------------------------------
279  getTempFileName
280  ---------------------------------------------------------------*/
282 {
283 #ifdef MRPT_OS_WINDOWS
284  FILETIME tt;
285  GetSystemTimeAsFileTime(&tt);
286  const UINT uniq = static_cast<UINT>(tt.dwLowDateTime);
287  char TMP_PATH[MAX_PATH];
288  char tmpPath[MAX_PATH];
289  GetTempPathA(MAX_PATH, tmpPath);
290  GetTempFileNameA(tmpPath, "mrpt", uniq, TMP_PATH);
291  return std::string(TMP_PATH);
292 #else
293  char tmp[] = "/tmp/mrpt_tempXXXXXX";
294  int fd;
295  fd = mkstemp(tmp);
296  ASSERT_(fd >= 0);
297  close(fd);
298  return std::string(tmp);
299 #endif
300 }
301 
302 /** Renames a file - If the target path is different and the filesystem allows
303  * it, it will be moved to the new location.
304  * \return false on any error. In that case, if a pointer to a receiver string
305  * is passed in error_msg, a description of the error is saved there.
306  */
308  const string& oldFileName, const string& newFileName,
309  std::string* error_msg)
310 {
311  bool ret_err = 0 == rename(oldFileName.c_str(), newFileName.c_str());
312 
313  if (error_msg)
314  {
315  if (ret_err)
316  *error_msg = strerror(errno);
317  else
318  *error_msg = "";
319  }
320 
321  return ret_err;
322 }
323 
324 /*---------------------------------------------------------------
325  fileNameStripInvalidChars
326 ---------------------------------------------------------------*/
328  const std::string& filename, const char replacement_to_invalid_chars)
329 {
330  const char forbid[] = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};
331  const unsigned int nForbid = sizeof(forbid) / sizeof(forbid[0]);
332 
333  string ret(filename);
334  for (string::iterator c = ret.begin(); c != ret.end(); ++c)
335  {
336  bool invalid = (*c < 32);
337 
338  for (unsigned int i = 0; !invalid && i < nForbid; i++)
339  if (*c == forbid[i]) invalid = true;
340 
341  if (invalid) *c = '_';
342  }
343  return ret;
344 }
345 
346 /*---------------------------------------------------------------
347  getFileSize
348 ---------------------------------------------------------------*/
350 {
351 #if defined(_MSC_VER)
352  // Visual Studio:
353  struct __stat64 filStat;
354  if (_stat64(fileName.c_str(), &filStat))
355  return uint64_t(-1);
356  else
357  return uint64_t(filStat.st_size);
358 #else
359  // The rest of the world:
360  struct stat filStat;
361  if (stat(fileName.c_str(), &filStat))
362  return uint64_t(-1);
363  else
364  return uint64_t(filStat.st_size);
365 #endif
366 }
367 
368 /** Replace the filename extension by another one. */
370  const std::string& filePath, const std::string& newExtension)
371 {
372  if (filePath.size() < 2) return filePath;
373 
374  const size_t i_end = filePath.size() - 1;
375 
376  for (int i = int(i_end); i > 0; i--)
377  if (filePath[i] == '.') return filePath.substr(0, i + 1) + newExtension;
378 
379  // No extension found: add it:
380  return filePath + string(".") + newExtension;
381 }
382 
383 /*---------------------------------------------------------------
384  copyFile
385 ---------------------------------------------------------------*/
387  const std::string& sourceFile, const std::string& targetFile,
388  std::string* outErrStr, bool copyAttribs)
389 {
390  const std::string org =
392  const std::string trg =
394 
395  const bool fil_exs = fileExists(org);
396  const bool dir_exs = directoryExists(org);
397 
398  // Is source a directory?
399  if (!fil_exs)
400  {
401  if (outErrStr)
402  *outErrStr =
403  string("Source does not exist or permission denied!: ") + org;
404  return false;
405  }
406  if (dir_exs)
407  {
408  if (outErrStr) *outErrStr = string("Is source a directory?: ") + org;
409  return false;
410  }
411 
412  // Check if source file exists and we have access to open it:
413  FILE* f_src = fopen(org.c_str(), "rb");
414  if (!f_src)
415  {
416  if (outErrStr)
417  *outErrStr = string(
418  "Source file exists but cannot open it... is file "
419  "being used?: ") +
420  org;
421  return false;
422  }
423 
424  // Assure that "target" is not an existing directory:
425  if (directoryExists(trg))
426  {
427  if (outErrStr)
428  *outErrStr = string("Target cannot be a directory: ") + trg;
429  fclose(f_src);
430  return false;
431  }
432 
433  // Try to open the file for writting:
434  FILE* f_trg = fopen(trg.c_str(), "wb");
435  if (!f_trg)
436  {
437  if (!fileExists(trg))
438  {
439  // It does not exist and does not allow us to create it:
440  if (outErrStr)
441  *outErrStr = string("Cannot create target file: ") + trg;
442  fclose(f_src);
443  return false;
444  }
445  else
446  {
447 // It exists, but cannot overwrite it:
448 
449 #ifdef MRPT_OS_WINDOWS
450  // Try changing the permissions of the target file:
451  DWORD dwProp = GetFileAttributesA(trg.c_str());
452  if (dwProp == INVALID_FILE_ATTRIBUTES)
453  {
454  if (outErrStr)
455  *outErrStr =
456  string(
457  "Cannot get file attributes for target file, "
458  "trying to remove a possible read-only attribute "
459  "after first attempt of copy failed, for: ") +
460  trg;
461  fclose(f_src);
462  return false;
463  }
464 
465  dwProp &= ~FILE_ATTRIBUTE_HIDDEN;
466  dwProp &= ~FILE_ATTRIBUTE_READONLY;
467  dwProp &= ~FILE_ATTRIBUTE_SYSTEM;
468 
469  if (!SetFileAttributesA(trg.c_str(), dwProp))
470  {
471  if (outErrStr)
472  *outErrStr =
473  string(
474  "Cannot get file attributes for target file, "
475  "trying to remove a possible read-only attribute "
476  "after first attempt of copy failed, for: ") +
477  trg;
478  fclose(f_src);
479  return false;
480  }
481 
482  // Try again:
483  f_trg = fopen(trg.c_str(), "wb");
484  if (!f_trg)
485  {
486  if (outErrStr)
487  *outErrStr = string(
488  "Cannot overwrite target file, even after "
489  "changing file attributes! : ") +
490  trg;
491  fclose(f_src);
492  return false;
493  }
494 #else
495  // Try changing the permissions of the target file:
496  if (chmod(trg.c_str(), S_IRWXU | S_IRGRP | S_IROTH))
497  {
498  if (outErrStr)
499  *outErrStr =
500  string(
501  "Cannot set file permissions for target file, "
502  "trying to remove a possible read-only attribute "
503  "after first attempt of copy failed, for: ") +
504  trg;
505  fclose(f_src);
506  return false;
507  }
508 
509  // Try again:
510  f_trg = fopen(trg.c_str(), "wb");
511  if (!f_trg)
512  {
513  if (outErrStr)
514  *outErrStr = string(
515  "Cannot overwrite target file, even after "
516  "changing file permissions! : ") +
517  trg;
518  fclose(f_src);
519  return false;
520  }
521 #endif
522  }
523  }
524 
525  // Ok, here we have both files open: Perform the copy:
526  char buf[66000];
527  size_t nBytes = 0;
528  while (0 != (nBytes = fread(buf, 1, 64 * 1024, f_src)))
529  {
530  if (nBytes != fwrite(buf, 1, nBytes, f_trg))
531  {
532  if (outErrStr)
533  *outErrStr = string(
534  "Error writing the contents of the target "
535  "file (disk full?): ") +
536  trg;
537  fclose(f_src);
538  fclose(f_trg);
539  return false;
540  }
541  }
542 
543  // Close file handles:
544  fclose(f_src);
545  fclose(f_trg);
546 
547  // In Windows only, copy the file attributes:
548  if (copyAttribs)
549  {
550 #ifdef MRPT_OS_WINDOWS
551  DWORD dwPropSrc = GetFileAttributesA(org.c_str());
552  if (dwPropSrc == INVALID_FILE_ATTRIBUTES)
553  {
554  if (outErrStr)
555  *outErrStr =
556  string(
557  "Cannot get the file attributes for source file: ") +
558  org;
559  return false;
560  }
561  DWORD dwPropTrg = GetFileAttributesA(trg.c_str());
562  if (dwPropTrg == INVALID_FILE_ATTRIBUTES)
563  {
564  if (outErrStr)
565  *outErrStr =
566  string(
567  "Cannot get the file attributes for target file: ") +
568  trg;
569  return false;
570  }
571 
572  // Leave only those attributes which can be legally copied:
573  // (Refer to: http://msdn2.microsoft.com/en-us/library/aa365535.aspx )
574  dwPropSrc &= FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN |
575  FILE_ATTRIBUTE_NORMAL |
576  FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
577  FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_READONLY |
578  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_TEMPORARY;
579 
580  // Copy them to the target attributes:
581  dwPropTrg &=
582  ~(FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN |
583  FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
584  FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_READONLY |
585  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_TEMPORARY);
586  dwPropTrg |= dwPropSrc;
587 
588  // Set attributes of target file:
589  if (!SetFileAttributesA(trg.c_str(), dwPropTrg))
590  {
591  if (outErrStr)
592  *outErrStr =
593  string("Cannot set file attributes for target file: ") +
594  trg;
595  return false;
596  }
597 #else
598 // Linux: No file attributes to copy.
599 #endif
600  } // end // if (copyAttribs)
601 
602  return true;
603 }
604 
605 // ---------------------------------------------------------------
606 // filePathSeparatorsToNative
607 // ---------------------------------------------------------------
609  const std::string& filePath)
610 {
611  std::string ret = filePath;
612  const size_t N = ret.size();
613  for (size_t i = 0; i < N; i++)
614  {
615 #ifdef MRPT_OS_WINDOWS
616  if (ret[i] == '/') ret[i] = '\\';
617 #else
618  if (ret[i] == '\\') ret[i] = '/';
619 #endif
620  }
621  return ret;
622 }
623 
625 {
626  struct stat fS;
627  if (0 != stat(filename.c_str(), &fS))
628  return 0;
629  else
630  return fS.st_mtime;
631 }
632 
633 #include <mrpt/version.h>
634 // Read docs in .h
636 {
637  using std::string;
638  using std::vector;
639 
640  static vector<string> sPaths;
641  static string sDetectedPath;
642  static bool is_first = true;
643  if (is_first)
644  {
645  is_first = false;
646 
647  // Source dir:
648  sPaths.push_back(
649  string(MRPT_CMAKE_SOURCE_DIR) + string("/share/mrpt/"));
650  // Install dir:
651  sPaths.push_back(
652  string(MRPT_CMAKE_INSTALL_PREFIX) + string("/share/mrpt/"));
653 
654  // Program path & ".." & "../..":
655  char buf[2048];
656  bool sBufOk = false;
657 #ifdef MRPT_OS_WINDOWS
658  sBufOk = (0 != GetModuleFileNameA(NULL, buf, sizeof(buf)));
659 #endif
660 #ifdef MRPT_OS_LINUX
661  sBufOk = (-1 != readlink("/proc/self/exe", buf, sizeof(buf)));
662 #endif
663 
664  if (sBufOk)
665  {
666  string sBuf = string(buf);
667  std::replace(sBuf.begin(), sBuf.end(), '\\', '/');
668  sBuf = extractFileDirectory(sBuf);
669  sPaths.push_back(sBuf + string("share/mrpt/"));
670  sPaths.push_back(sBuf + string("../share/mrpt/"));
671  sPaths.push_back(sBuf + string("../../share/mrpt/"));
672  }
673 
674  for (const auto& e : sPaths)
675  if (directoryExists(e))
676  {
677  sDetectedPath = e;
678  break;
679  }
680  }
681  return sDetectedPath;
682 }
bool createDirectory(const std::string &dirName)
Creates a directory.
Definition: filesystem.cpp:158
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define _stat
Definition: filesystem.cpp:47
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:635
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:272
GLuint buffer
Definition: glext.h:3917
#define THROW_EXCEPTION(msg)
Scalar * iterator
Definition: eigen_plugins.h:26
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:307
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:327
#define FILE_ATTRIB_ARCHIVE
GLdouble s
Definition: glext.h:3676
GLenum GLsizei len
Definition: glext.h:4712
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Definition: filesystem.cpp:281
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
#define MRPT_END
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:608
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:369
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
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
#define _rmdir
Definition: filesystem.cpp:45
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
#define MRPT_START
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:281
std::string getcwd()
Returns the current working directory.
Definition: filesystem.cpp:247
#define _access
Definition: filesystem.cpp:44
#define ASSERT_(f)
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:386
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:214
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:254
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:349
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:188
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:624



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