NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
filesystem.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2014 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include <iostream>
20#include <fstream>
21#include <sstream>
22#include <windows.h>
23
24#include "filesystem.hpp"
25#include "../../kernel.hpp"
26#include "../utils/datetimetools.hpp"
27
28std::string removeQuotationMarks(const std::string& sString);
29
30
35{
36 sPath = "";
37 sExecutablePath = "";
38 sValidExtensions = ";.dat;.txt;.tmp;.def;.nscr;.png;.gif;.eps;.bps;.svg;.tex;.labx;.csv;.cache;.ndat;.nprc;.nlng;.nlyt;.log;.plugins;.hlpidx;.nhlp;.jdx;.dx;.jcm;.ibw;.ndb;.ods;.jpg;.bmp;.tga;.bps;.prc;.obj;.xyz;.stl;.json;.off;.pdf;.wav;.wave;.xls;.xlsx;.chm;.h;.hpp;.cxx;.cpp;.c;.m;.tif;.tiff;.ini;.xml;.yaml;.yml;.nsi;";
39
40 for (int i = 0; i < 7; i++)
41 {
42 sTokens[i][0] = "";
43 sTokens[i][1] = "";
44 }
45}
46
47
57{
58 sPath = _fSys.sPath;
61
62 for (int i = 0; i < 7; i++)
63 {
64 sTokens[i][0] = _fSys.sTokens[i][0];
65 sTokens[i][1] = _fSys.sTokens[i][1];
66 }
67
68 return *this;
69}
70
71
82std::string FileSystem::cleanPath(std::string sFilePath, bool checkInvalidChars) const
83{
84 sFilePath = replacePathSeparator(removeQuotationMarks(sFilePath));
85 StripSpaces(sFilePath);
86
87 if (sFilePath[0] == '<')
88 {
89 for (int i = 0; i < 7; i++)
90 {
91 if (sFilePath.substr(0,sTokens[i][0].length()) == sTokens[i][0])
92 {
93 if (sFilePath[sTokens[i][0].length()] != '/')
94 sFilePath = sTokens[i][1] + "/" + sFilePath.substr(sTokens[i][0].length());
95 else
96 sFilePath = sTokens[i][1] + sFilePath.substr(sTokens[i][0].length());
97
98 break;
99 }
100 }
101
102 if (sFilePath.substr(0,6) == "<this>")
103 {
104 if (sFilePath[6] != '/')
105 sFilePath = sTokens[0][1] + "/" + sFilePath.substr(6);
106 else
107 sFilePath = sTokens[0][1] + sFilePath.substr(6);
108 }
109 }
110
112 return sFilePath;
113
114 const std::string sINVALID_CHARS = "\"#%&<>|";
115
116 for (unsigned int i = 0; i < sFilePath.length(); i++)
117 {
118 if (sFilePath[i] == (char)142)
119 sFilePath[i] = 'Ä';
120 else if (sFilePath[i] == (char)132)
121 sFilePath[i] = 'ä';
122 else if (sFilePath[i] == (char)153)
123 sFilePath[i] = 'Ö';
124 else if (sFilePath[i] == (char)148)
125 sFilePath[i] = 'ö';
126 else if (sFilePath[i] == (char)154)
127 sFilePath[i] = 'Ü';
128 else if (sFilePath[i] == (char)129)
129 sFilePath[i] = 'ü';
130 else if (sFilePath[i] == (char)225)
131 sFilePath[i] = 'ß';
132 else if (sFilePath[i] == '~')
133 {
134 NumeReKernel::issueWarning("INTERNAL ISSUE: Replaced a tilde character in \"" + sFilePath + "\" with a slash. This should not happen. Consider informing the development team about this warning and how to recreate it. Thank you.");
135 sFilePath[i] = '/';
136 }
137 else if (sINVALID_CHARS.find(sFilePath[i]) != std::string::npos)
138 {
139 NumeReKernel::issueWarning("Replaced an invalid character in \"" + sFilePath + "\" with an underscore. This should not happen. Consider informing the development team about this warning and how to recreate it. Thank you.");
140 sFilePath[i] = '_';
141 }
142 }
143
144 return sFilePath;
145}
146
147
159void FileSystem::resolveWildCards(std::string& _sFileName, bool isFile, bool checkExtension) const
160{
161 if (_sFileName.find_first_of("*?") != std::string::npos)
162 {
163 WIN32_FIND_DATA FindFileData;
164 HANDLE hFind = INVALID_HANDLE_VALUE;
165 hFind = FindFirstFile(_sFileName.c_str(), &FindFileData);
166 std::string sNewFileName = "";
167
168 do
169 {
170 if (!isFile && FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
171 {
172 sNewFileName = FindFileData.cFileName;
173 break;
174 }
175 else if (isFile && FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
176 continue;
177
178 sNewFileName = FindFileData.cFileName;
179
180 if (sNewFileName.length() > 4
181 && sNewFileName.find('.') != std::string::npos
182 && (!checkExtension || sValidExtensions.find(";"+toLowerCase(sNewFileName.substr(sNewFileName.rfind('.')))+";") != std::string::npos))
183 break;
184 else if (sNewFileName.find('.') != std::string::npos)
185 sNewFileName = "";
186 else
187 sNewFileName += ".*";
188 }
189 while (FindNextFile(hFind, &FindFileData) != 0);
190
191 FindClose(hFind);
192
193 if (sNewFileName.length() > 4)
194 {
195 std::string sPathTemp = _sFileName;
196
197 if (sPathTemp.rfind('/') != std::string::npos && sPathTemp.rfind('\\') != std::string::npos)
198 {
199 if (sPathTemp.rfind('/') < sPathTemp.rfind('\\'))
200 sPathTemp = sPathTemp.substr(0, sPathTemp.rfind('\\'));
201 else
202 sPathTemp = sPathTemp.substr(0, sPathTemp.rfind('/'));
203 }
204 else if (sPathTemp.rfind('/') != std::string::npos)
205 {
206 sPathTemp = sPathTemp.substr(0, sPathTemp.rfind('/'));
207 }
208 else if (sPathTemp.rfind('\\') != std::string::npos)
209 {
210 sPathTemp = sPathTemp.substr(0, sPathTemp.rfind('\\'));
211 }
212 else
213 {
214 sPathTemp = "";
215 }
216
217 if (sPathTemp.length())
218 _sFileName = sPathTemp + "/" + sNewFileName;
219 else
220 _sFileName = sNewFileName;
221 }
222 }
223}
224
225
234int FileSystem::createFolders(const std::string& _sPath) const
235{
236 // Create the folder (returns false, if there's more
237 // than one folder to be created)
238 if (CreateDirectory(_sPath.c_str(), nullptr))
239 {
240 return 1;
241 }
242
243 // If there's more than one folder to be created
244 // create them recursively here
245 if (GetLastError() == ERROR_PATH_NOT_FOUND)
246 {
247 for (unsigned int i = 0; i < _sPath.length(); i++)
248 {
249 if (_sPath[i] == '/' || _sPath[i] == '\\')
250 {
251 CreateDirectory(_sPath.substr(0,i).c_str(), nullptr);
252 }
253 }
254
255 CreateDirectory(_sPath.c_str(), nullptr);
256 }
257
258 // Note that the folder might already exist
259 if (GetLastError() == ERROR_ALREADY_EXISTS)
260 {
261 return -1;
262 }
263
264 return 1;
265}
266
267
280std::string FileSystem::ValidFileName(std::string _sFileName, const std::string sExtension, bool checkExtension, bool doCleanPath) const
281{
282 std::string sValid = "";
284
285 _sFileName = cleanPath(_sFileName, doCleanPath);
286
287 // Find the position of the last colon in the string
288 // should be directly after the drive letter
289 unsigned int nPos = _sFileName.find_last_of(':');
290
291 // If there's no colon in the current path, then it is a
292 // network address
293 if (nPos == std::string::npos)
294 {
295 if (_sFileName.substr(0, 2) != "//")
296 _sFileName = sPath.substr(1, sPath.length()-2) + "/" + _sFileName;
297 }
298
299 // Resolve wildcards in the passed file name
300 resolveWildCards(_sFileName, true, checkExtension);
301
302 // Find the last dot to identify the extension
303 nPos = _sFileName.find_last_of(".");
304
305 // If the position of the last dot is either
306 // zero or one, it is a relative path. The
307 // consecutive character should be a path
308 // separator. In this case, we'll add the
309 // default extension
310 if (nPos == std::string::npos
311 || (nPos == 0 || nPos == 1)
312 || (_sFileName.find('/', nPos) != std::string::npos || _sFileName.find('\\', nPos) != std::string::npos))
313 sValid = _sFileName + sExtension;
314 else if (checkExtension && sExtension.length())
315 {
316 // Extract the string part after the last
317 // dot in the file path
318 sValid = _sFileName.substr(nPos);
319
320 // Remove the possible trailing quotation
321 // mark from the extension
322 if (sValid.back() == '"')
323 sValid.pop_back();
324
325 // Ensure that the found extension is valid.
326 // Otherwise the extension will be exchanged
327 // automatically
328 if (sValidExtensions.find(";"+toLowerCase(sValid)+";") != std::string::npos)
329 {
330 sValid = _sFileName;
331 }
332 else
333 {
334 if (sValid == ".*")
335 sValid = _sFileName.substr(0,nPos);
336 else
337 throw SyntaxError(SyntaxError::INVALID_FILETYPE, _sFileName, _sFileName.substr(nPos), _sFileName);
338 }
339 }
340 else
341 sValid = _sFileName;
342
343 // It's possible, that a new wildcard was added to the
344 // file path. Resolve it here
345 resolveWildCards(sValid, true, checkExtension);
346
347 // Ensure that the file path separators are unix-like
348 for (unsigned int i = 0; i < sValid.length(); i++)
349 {
350 if (sValid[i] == '\\')
351 sValid[i] = '/';
352 }
353
354 return sValid;
355}
356
357
369std::string FileSystem::ValidFolderName(std::string _sFileName, bool doCleanPath, bool appendTrailingSeparator) const
370{
371 _sFileName = cleanPath(_sFileName, doCleanPath);
372
373 // Find the position of the last colon in the string
374 // should be directly after the drive letter
375 unsigned int nPos = _sFileName.find_last_of(':');
376
377 // If there's no colon in the current path, then it is a
378 // network address
379 if (nPos == std::string::npos)
380 {
381 if (_sFileName.substr(0,2) != "//")
382 _sFileName = sPath.substr(1, sPath.length()-2) + "/" + _sFileName;
383 }
384
385 // Resolve wildcards in the passed file name
386 resolveWildCards(_sFileName, false);
387
388 // Fallback for the case that this is actually a
389 // file and not a folder
390 if (_sFileName.find_first_of("*?") != std::string::npos)
391 resolveWildCards(_sFileName, true, false);
392
393 // Ensure that the file path separators are unix-like
394 for (unsigned int i = 0; i < _sFileName.length(); i++)
395 {
396 if (_sFileName[i] == '\\')
397 _sFileName[i] = '/';
398 }
399
400 // Catch the case, where the file detection may have failed
401 if (fileExists(_sFileName))
402 return _sFileName;
403
404 // Append a trailing path separator, if it is missing
405 if (appendTrailingSeparator && _sFileName.back() != '/')
406 _sFileName += "/";
407 else if (!appendTrailingSeparator && _sFileName.back() == '/')
408 _sFileName.pop_back();
409
410 return _sFileName;
411}
412
413
424std::string FileSystem::ValidizeAndPrepareName(const std::string& _sFileName, const std::string& sExtension) const
425{
426 std::string sValid = ValidFileName(_sFileName, sExtension, sExtension.length());
427 createFolders(sValid.substr(0, sValid.rfind('/')));
428 return sValid;
429}
430
431
443int FileSystem::setPath(std::string _sPath, bool bMkDir, std::string _sExePath)
444{
445
447
448 if (sExecutablePath[0] == '"')
450
451 if (sExecutablePath[sExecutablePath.length()-1] == '"')
452 sExecutablePath = sExecutablePath.substr(0,sExecutablePath.length()-1);
453
454 sPath = fromSystemCodePage(_sPath);
455
456 if (sPath.find('<') != std::string::npos)
457 {
458 for (unsigned int i = 0; i < 6; i++)
459 {
460 if (sPath.find(sTokens[i][0]) != std::string::npos)
461 sPath.replace(sPath.find(sTokens[i][0]), sTokens[i][0].length(), sTokens[i][1]);
462 }
463 }
464
465 if (sPath.find('~') != std::string::npos)
466 {
467 for (unsigned int i = 0; i < sPath.length(); i++)
468 {
469 if (sPath[i] == '~')
470 sPath[i] = '/';
471 }
472 }
473
474 while (sPath.find('\\') != std::string::npos)
475 sPath[sPath.find('\\')] = '/';
476
477 if (sPath.find(':') == std::string::npos)
478 {
479 if (sPath.length() > 3 && sPath.substr(0,3) != "..\\" && sPath.substr(0,3) != "../" && sPath.substr(0,2) != ".\\" && sPath.substr(0,2) != "./")
480 sPath = "\"" + sExecutablePath + "\\" + sPath + "\"";
481 else if (sPath.length() > 2 && (sPath.substr(0,2) == ".\\" || sPath.substr(0,2) == "./"))
482 sPath = "\"" + sExecutablePath + sPath.substr(1) + "\"";
483 else if (sPath.length() > 3 && (sPath.substr(0,3) == "..\\" || sPath.substr(0,3) == "../"))
484 {
485 while (sPath.length() > 3 && (sPath.substr(0,3) == "..\\" || sPath.substr(0,3) == "../"))
486 {
487 if (sExecutablePath.find('\\') != std::string::npos)
488 sExecutablePath = sExecutablePath.substr(0,sExecutablePath.rfind('\\'));
489 else
490 {
491 sPath = _sPath;
492 break;
493 }
494
495 sPath = sPath.substr(3);
496 }
497
498 sPath = "\"" + sExecutablePath + "\\" + sPath + "\"";
499 }
500 else
501 sPath = "\"" + sExecutablePath + "\\" + sPath + "\"";
502 }
503
504 if (sPath[0] == '"')
505 sPath = sPath.substr(1);
506
507 if (sPath[sPath.length()-1] == '"')
508 sPath = sPath.substr(0, sPath.length()-1);
509
510
511 if (bMkDir)
512 {
513 int nReturn = createFolders(sPath);
514 sPath = "\"" + sPath + "\"";
515 return nReturn;
516 }
517
518 sPath = "\"" + sPath + "\"";
519
520 return 1;
521}
522
523
533{
534 std::string sRevisionsPath = sPath.substr(1, sPath.length()-2) + "/.revisions";
535 createFolders(sRevisionsPath);
536 SetFileAttributesA(sRevisionsPath.c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
537}
538
539
547std::string FileSystem::getPath() const
548{
549 if (sPath[0] == '"' && sPath[sPath.length()-1] == '"')
550 return sPath.substr(1,sPath.length()-2);
551 return sPath;
552}
553
554
566std::vector<std::string> FileSystem::getFileParts(const std::string& sFilePath) const
567{
568 std::vector<std::string> vFileParts;
569 // Create a valid file path first
570 std::string sValidName = sFilePath;
571
572 if (isFile(sValidName))
573 sValidName = ValidFileName(sValidName, ".dat", false);
574 else
575 sValidName = ValidFolderName(sValidName);
576
577 // Does it contain a drive letter? Then the second
578 // character will always be a colon
579 if (sValidName[1] == ':')
580 {
581 vFileParts.push_back(sValidName.substr(0, 1));
582 // extract everything from the fourth character
583 // to the last path separator
584 if (sValidName.length() > 2)
585 vFileParts.push_back(sValidName.substr(3, sValidName.rfind('/') - 3));
586 }
587 else
588 {
589 vFileParts.push_back("");
590 vFileParts.push_back(sValidName.substr(0, sValidName.rfind('/')));
591 }
592
593 // Is it a file or a folder?
594 if (sValidName.find('.') != std::string::npos && sValidName.rfind('/')+1 < sValidName.rfind('.'))
595 {
596 // file
597 vFileParts.push_back(sValidName.substr(sValidName.rfind('/')+1, sValidName.rfind('.') - sValidName.rfind('/')-1));
598 vFileParts.push_back(sValidName.substr(sValidName.rfind('.')+1));
599 }
600 else
601 {
602 // folder
603 vFileParts.push_back(sValidName.substr(sValidName.rfind('/')+1));
604 vFileParts.push_back("");
605 }
606
607 // Return the separated paths
608 return vFileParts;
609}
610
611
620static double windowSystemTimeToDouble(SYSTEMTIME stUTC)
621{
622 time_stamp timeStamp;
623
624 //NumeReKernel::print(toString(stUTC.wYear) + "/" + toString(stUTC.wMonth) + "/" + toString(stUTC.wDay) + ", " + toString(stUTC.wHour) + ":" + toString(stUTC.wMinute));
625 timeStamp.m_ymd = date::year_month_day(date::year(stUTC.wYear), date::month(stUTC.wMonth), date::day(stUTC.wDay));
626 timeStamp.m_hours = std::chrono::hours(stUTC.wHour);
627 timeStamp.m_minutes = std::chrono::minutes(stUTC.wMinute);
628 timeStamp.m_seconds = std::chrono::seconds(stUTC.wSecond);
629
630 return to_double(getTimePointFromTimeStamp(timeStamp));
631}
632
633
642FileInfo FileSystem::getFileInfo(const std::string& sFilePath) const
643{
644 FileInfo fInfo;
645 std::vector<std::string> vFileParts = getFileParts(sFilePath);
646
647 // Insert the splitted path
648 fInfo.drive = vFileParts[0];
649 fInfo.path = vFileParts[1];
650 fInfo.name = vFileParts[2];
651 fInfo.ext = vFileParts[3];
652
653 WIN32_FIND_DATA FindFileData;
654 HANDLE hFind = INVALID_HANDLE_VALUE;
655
656 if (isFile(sFilePath))
657 hFind = FindFirstFile(ValidFileName(sFilePath, ".dat", false).c_str(), &FindFileData);
658 else
659 hFind = FindFirstFile(ValidFolderName(sFilePath, true, false).c_str(), &FindFileData);
660
661 // Only fill in the remainig information, if a corresponding
662 // file could be found
663 if (hFind != INVALID_HANDLE_VALUE)
664 {
665 // Insert the file information
666 LARGE_INTEGER fileSize;
667 fileSize.LowPart = FindFileData.nFileSizeLow;
668 fileSize.HighPart = FindFileData.nFileSizeHigh;
669 fInfo.filesize = size_t(fileSize.QuadPart);
670
671 SYSTEMTIME stUTC;
672 FileTimeToSystemTime(&FindFileData.ftCreationTime, &stUTC);
674 FileTimeToSystemTime(&FindFileData.ftLastWriteTime, &stUTC);
676
677 fInfo.fileAttributes = FindFileData.dwFileAttributes;
678 FindClose(hFind);
679 }
680
681 return fInfo;
682}
683
684
694void FileSystem::setTokens(std::string _sTokens)
695{
696 for (int i = 0; i < 7; i++)
697 {
698 sTokens[i][0] = _sTokens.substr(0,_sTokens.find('='));
699 sTokens[i][1] = _sTokens.substr(_sTokens.find('=')+1, _sTokens.find(';')-1-_sTokens.find('='));
700 _sTokens = _sTokens.substr(_sTokens.find(';')+1);
701
702 if (!_sTokens.length())
703 break;
704 }
705}
706
707
716bool FileSystem::isFile(const std::string& _sPath) const
717{
718 if (fileExists(_sPath))
719 return true;
720
721 if (_sPath.rfind('.') != std::string::npos)
722 {
723 std::string sExt = _sPath.substr(_sPath.rfind('.'));
724
725 if (sValidExtensions.find(";" + sExt + ";") != std::string::npos)
726 return true;
727
728 if (sExt.find('/') != std::string::npos || sExt.find('\\') != std::string::npos)
729 return false;
730
731 if (sExt.length() < 6 || sExt == ".*")
732 return true;
733
734 if (_sPath.find_last_of("\\/", _sPath.length() - sExt.length()) != std::string::npos)
735 return true;
736 }
737
738 return false;
739}
740
741
751{
753
754 if (!_instance)
755 return;
756
757 assign(_instance->getFileSystem());
758}
759
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
This class implements the basic input/ output file system and provides functionalities to work with f...
Definition: filesystem.hpp:92
std::string sPath
Definition: filesystem.hpp:98
std::string ValidFolderName(std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const
This member function evaluates, whether the passed foldername is a valid foldername.
Definition: filesystem.cpp:369
std::string ValidizeAndPrepareName(const std::string &_sFileName, const std::string &sExtension=".dat") const
This member function validizes the passed file name and creates the needed folders on-the-fly.
Definition: filesystem.cpp:424
std::string cleanPath(std::string sFilePath, bool checkInvalidChars) const
This function cleans the passed file path, i.e. replaces the character encoding of umlauts,...
Definition: filesystem.cpp:82
std::string sExecutablePath
Definition: filesystem.hpp:99
FileSystem & assign(const FileSystem &_fSys)
Assignment member function to copy the settings from another FileSystem instance.
Definition: filesystem.cpp:56
std::vector< std::string > getFileParts(const std::string &sFilePath) const
This member function separates all path parts into single strings: the drive letter,...
Definition: filesystem.cpp:566
void initializeFromKernel()
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up...
Definition: filesystem.cpp:750
FileInfo getFileInfo(const std::string &sFilePath) const
Return the file information about the passed file path.
Definition: filesystem.cpp:642
std::string getPath() const
Returns the default path of this FileSystem instance.
Definition: filesystem.cpp:547
void resolveWildCards(std::string &_sFileName, bool isFile, bool checkExtension=true) const
This member function resolves all wildcards, which may be found in the passed filename.
Definition: filesystem.cpp:159
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
Definition: filesystem.cpp:280
FileSystem()
Default constructor.
Definition: filesystem.cpp:34
void setTokens(std::string _sTokens)
This member function may be used to update the path placeholders of the current FileSystem instance.
Definition: filesystem.cpp:694
void createRevisionsFolder()
This member function creates the hidden revisions folders for the version control system.
Definition: filesystem.cpp:532
std::string sTokens[7][2]
Definition: filesystem.hpp:100
std::string sValidExtensions
Definition: filesystem.hpp:101
bool isFile(const std::string &_sPath) const
This function determines, whether a path name indicates a file or a folder.
Definition: filesystem.cpp:716
int createFolders(const std::string &_sPath) const
This member function creates all missing directories in the passed path.
Definition: filesystem.cpp:234
int setPath(std::string _sPath, bool bMkDir, std::string _sExePath)
This member function may be used to set the preferred file path of the current FileSystem instance.
Definition: filesystem.cpp:443
This class provides the interface to the core of NumeRe. It provides all functionalities,...
Definition: kernel.hpp:97
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
Definition: kernel.hpp:221
FileSystem & getFileSystem()
Definition: kernel.hpp:258
static void issueWarning(std::string sWarningMessage)
This static function may be used to issue a warning to the user. The warning will be printed by the t...
Definition: kernel.cpp:2833
Common exception class for all exceptions thrown in NumeRe.
Definition: error.hpp:32
@ INVALID_FILETYPE
Definition: error.hpp:127
double to_double(sys_time_point tp)
Convert a sys_time_point to a double. The double is returned in units of seconds.
sys_time_point getTimePointFromTimeStamp(const time_stamp &ts)
Convert a time_stamp to a sys_time_point.
static bool checkInvalidChars(std::string sPathname)
This function checks for the invalid chars that can not appear in a valid directory name.
Definition: filecheck.cpp:14
static double windowSystemTimeToDouble(SYSTEMTIME stUTC)
Static function to convert Windows UTC system time to a double.
Definition: filesystem.cpp:620
std::string removeQuotationMarks(const std::string &sString)
This function simply removes the surrounding quotation marks.
std::string fromSystemCodePage(std::string)
Transforms the system code page to the internal one.
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
bool fileExists(const string &)
This function checks, whether the file with the passed file name exists.
Definition: tools.cpp:2500
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
This structure contains all relevant information about a file path.
Definition: filesystem.hpp:41
std::string path
Definition: filesystem.hpp:43
size_t filesize
Definition: filesystem.hpp:46
double creationTime
Definition: filesystem.hpp:48
double modificationTime
Definition: filesystem.hpp:49
std::string drive
Definition: filesystem.hpp:42
size_t fileAttributes
Definition: filesystem.hpp:47
std::string ext
Definition: filesystem.hpp:45
std::string name
Definition: filesystem.hpp:44
This structure defines all fields necessary to create a time stamp or a formatted date.
date::year_month_day m_ymd
std::chrono::minutes m_minutes
std::chrono::seconds m_seconds
std::chrono::hours m_hours