trikRuntime
fileUtils.h
Go to the documentation of this file.
1 /* Copyright 2013 - 2015 Yurii Litvinov and CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QString>
18 #include <QtXml/QDomElement>
19 
20 namespace trikKernel {
21 
23 class FileUtils
24 {
25 public:
27  static QString readFromFile(const QString &fileName);
28 
30  static void writeToFile(const QString &fileName, const QString &contents, const QString &dirPath = "");
31 
33  static QDomElement readXmlFile(const QString &fileNameWithPath);
34 
36  static QString normalizePath(const QString &path);
37 };
38 
39 }
Definition: analogSensor.h:23
static QDomElement readXmlFile(const QString &fileNameWithPath)
Reads given XML file and returns root element, throws exception if something went wrong...
Definition: fileUtils.cpp:63
static QString normalizePath(const QString &path)
Returns absolute path by given path, adds "/" to the right if needed.
Definition: fileUtils.cpp:84
Helper class with file helper functions.
Definition: fileUtils.h:23
static QString readFromFile(const QString &fileName)
Reads all file contents and returns it as sting or throws an exception.
Definition: fileUtils.cpp:25
static void writeToFile(const QString &fileName, const QString &contents, const QString &dirPath="")
Writes given string to given file, throws exception if something went wrong.
Definition: fileUtils.cpp:42