shared: common: Add mountPaths()
Mountpaths indicate mount points of external devices. Files located under such paths should not be removed on sync, because they may have not been deleted, but are just inaccessible right now.
这个提交包含在:
父节点
0e5abf96c8
当前提交
61a446ec2d
@ -19,6 +19,7 @@
|
|||||||
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
|
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
|
||||||
#define SETTINGS_KEY_PDFVIEWER "pdfviewer"
|
#define SETTINGS_KEY_PDFVIEWER "pdfviewer"
|
||||||
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
|
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
|
||||||
|
#define SETTINGS_KEY_MOUNTPATHS "mountpaths"
|
||||||
|
|
||||||
inline void initResources()
|
inline void initResources()
|
||||||
{
|
{
|
||||||
@ -180,6 +181,32 @@ QStringList Common::excludedPaths()
|
|||||||
return ::excludedPaths;
|
return ::excludedPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList Common::mountPaths()
|
||||||
|
{
|
||||||
|
static int ran = false;
|
||||||
|
static QStringList mountPaths;
|
||||||
|
if(!ran)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
mountPaths = settings.value(SETTINGS_KEY_MOUNTPATHS, QStringList{"/media", "/mnt"}).toStringList();
|
||||||
|
ran = true;
|
||||||
|
}
|
||||||
|
return mountPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Common::isMountPath(QString path)
|
||||||
|
{
|
||||||
|
QStringList mountPaths = Common::mountPaths();
|
||||||
|
for(QString &mountPath : mountPaths)
|
||||||
|
{
|
||||||
|
if(path.startsWith(mountPath))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Common::isTextFile(QFileInfo fileInfo)
|
bool Common::isTextFile(QFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
/* TODO: This is not sandboxed yet ... */
|
/* TODO: This is not sandboxed yet ... */
|
||||||
|
@ -12,7 +12,9 @@ QString findInPath(QString needle);
|
|||||||
bool initSqliteDatabase(QString path);
|
bool initSqliteDatabase(QString path);
|
||||||
void ensureConfigured();
|
void ensureConfigured();
|
||||||
QStringList excludedPaths();
|
QStringList excludedPaths();
|
||||||
|
QStringList mountPaths();
|
||||||
bool isTextFile(QFileInfo fileInfo);
|
bool isTextFile(QFileInfo fileInfo);
|
||||||
|
bool isMountPath(QString path);
|
||||||
QString versionText();
|
QString versionText();
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
#endif
|
#endif
|
||||||
|
正在加载...
x
在新工单中引用
屏蔽一个用户