mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 22:39:53 +08:00
30 lines
771 B
C++
30 lines
771 B
C++
#include "inotebookbackend.h"
|
|
|
|
#include <QDir>
|
|
|
|
#include <exception.h>
|
|
#include <utils/pathutils.h>
|
|
|
|
using namespace vnotex;
|
|
|
|
void INotebookBackend::constrainPath(const QString &p_path) const
|
|
{
|
|
if (!PathUtils::pathContains(m_rootPath, p_path)) {
|
|
Exception::throwOne(Exception::Type::InvalidArgument,
|
|
QString("path (%1) does not locate in root folder (%2)")
|
|
.arg(p_path, m_rootPath));
|
|
}
|
|
}
|
|
|
|
QString INotebookBackend::getFullPath(const QString &p_path) const
|
|
{
|
|
constrainPath(p_path);
|
|
return QDir(m_rootPath).filePath(p_path);
|
|
}
|
|
|
|
QString INotebookBackend::getRelativePath(const QString &p_path) const
|
|
{
|
|
constrainPath(p_path);
|
|
return PathUtils::relativePath(m_rootPath, p_path);
|
|
}
|