CSystem.h
Go to the documentation of this file.
1 #ifndef istd_CSystem_included
2 #define istd_CSystem_included
3 
4 
5 // Qt includes
6 #include <QtCore/QString>
7 #include <QtCore/QMap>
8 
9 
10 #if defined(Sleep)
11 #undef Sleep
12 #endif
13 
14 
15 namespace istd
16 {
17 
18 
24 class CSystem
25 {
26 public:
27  typedef QMap<QString, QString> EnvironmentVariables;
28 
30  {
32  :totalBytes(0),
33  freeBytes(0)
34  {
35  }
36 
37  bool operator ==(const FileDriveInfo& info) const
38  {
39  return (totalBytes == info.totalBytes) && (freeBytes == info.freeBytes);
40  }
41 
42  quint64 totalBytes;
43  quint64 freeBytes;
44  };
45 
46 
47  // static methods
48 
52  static QString GetOperationSystemName();
53 
61  static bool ConvertToFileName(const QString& fileNameString, QString& fileName, const QString replacingChar = QString());
62 
66  static QString GetNormalizedPath(const QString& path);
67 
73  static QString GetVariableValue(const QString& varName, bool envVars = true, bool embeddedVars = true);
74 
78  static QString GetEnrolledPath(const QString& path, bool envVars = true, bool embeddedVars = true);
79 
84 
88  static void SetTempDirectoryPath(const QString& tempPath);
89 
93  static void Sleep(double seconds);
94 
98  static bool CopyDirectory(const QString &srcPath, const QString &dstPath);
99 
103  static bool RemoveDirectory(const QString& directoryPath);
104 
108  static bool FileCopy(const QString& source, const QString& result, bool overWrite = false);
109 
113  static bool FileMove(const QString& source, const QString& targetFolder, bool overWrite = false);
114 
118  static bool EnsurePathExists(const QString& filePath);
119 
123  static QString GetCurrentUserName();
124 
128  static FileDriveInfo GetFileDriveInfo(const QString& fileDrivePath);
129 
135  static QString GetCompilerVariable(const QString& varName);
136 
143  static void SetUserVariables(const QString& compilerMode, const QString& compilerName, const QString& platformCode);
144 
148  static QString ConvertNetworkPathToUnc(const QString& localPath);
149 
150 private:
151  static QString s_compilerMode;
152  static QString s_compilerName;
153  static QString s_platformCode;
154 };
155 
156 
157 } // namespace istd
158 
159 
160 #endif // !istd_CSystem_included
161 
162 
static bool EnsurePathExists(const QString &filePath)
Ensure that the given path exists.
QMap< QString, QString > EnvironmentVariables
Definition: CSystem.h:27
static void SetUserVariables(const QString &compilerMode, const QString &compilerName, const QString &platformCode)
Set some user specific variables to override the generated by compiler.
static bool CopyDirectory(const QString &srcPath, const QString &dstPath)
Copy files and directories from one folder to another.
static bool ConvertToFileName(const QString &fileNameString, QString &fileName, const QString replacingChar=QString())
Make a valid file name from a string.
static QString GetEnrolledPath(const QString &path, bool envVars=true, bool embeddedVars=true)
Get path with enrolled system variables.
static QString GetCurrentUserName()
Get the name of the currently logged user.
static FileDriveInfo GetFileDriveInfo(const QString &fileDrivePath)
Get the free space information for the given file drive.
static void SetTempDirectoryPath(const QString &tempPath)
Set path for for temporary data to the current process.
static bool FileMove(const QString &source, const QString &targetFolder, bool overWrite=false)
Move a file to another directory.
bool operator==(const FileDriveInfo &info) const
Definition: CSystem.h:37
static QString GetVariableValue(const QString &varName, bool envVars=true, bool embeddedVars=true)
Get value of system variables.
static QString GetCompilerVariable(const QString &varName)
Get compiler specific variable.
static QString GetNormalizedPath(const QString &path)
Get normalized path with enrolled system variables.
Implementation of global system helpers.
Definition: CSystem.h:24
static EnvironmentVariables GetEnvironmentVariables()
Get list of environment valiables related to the current process.
static QString ConvertNetworkPathToUnc(const QString &localPath)
Convert a mapped network path to UNC representation.
static bool RemoveDirectory(const QString &directoryPath)
Remove a given directory with all contents.
static bool FileCopy(const QString &source, const QString &result, bool overWrite=false)
Copy file to directory.
static void Sleep(double seconds)
Sleep current thread.
static QString GetOperationSystemName()
Get the name of the operation system currently used.

© 2007-2017 Witold Gantzke and Kirill Lepskiy