mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00

Thanks to [marked JavaScript library](https://github.com/chjj/marked) by Christopher Jeffrey. The [style sheet](http://kevinburke.bitbucket.org/markdowncss/markdown.css) was created by Kevin Burke. Signed-off-by: Le Tan <tamlokveer@gmail.com>
36 lines
861 B
C++
36 lines
861 B
C++
#include "vutils.h"
|
|
#include <QFile>
|
|
#include <QDebug>
|
|
|
|
VUtils::VUtils()
|
|
{
|
|
|
|
}
|
|
|
|
QString VUtils::readFileFromDisk(const QString &filePath)
|
|
{
|
|
QFile file(filePath);
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
qWarning() << "error: fail to read file" << filePath;
|
|
return QString();
|
|
}
|
|
QString fileText(file.readAll());
|
|
file.close();
|
|
qDebug() << "read file content:" << filePath;
|
|
return fileText;
|
|
}
|
|
|
|
bool VUtils::writeFileToDisk(const QString &filePath, const QString &text)
|
|
{
|
|
QFile file(filePath);
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
qWarning() << "error: fail to open file" << filePath << "to write to";
|
|
return false;
|
|
}
|
|
QTextStream stream(&file);
|
|
stream << text;
|
|
file.close();
|
|
qDebug() << "write file content:" << filePath;
|
|
return true;
|
|
}
|