这是一个用来监控本地文件夹变化的服务
w1146869587
2021-11-09 f5e3a3a6785cd9305c476eadf329c8ae00161add
mbwatch/mbfileutil.cpp
@@ -23,6 +23,11 @@
    return strLastTime;
}
QString CMBFileUtil::getPath(QString fileName)
{
    int nPos = fileName.lastIndexOf("/");
    return fileName.mid(0,nPos);
}
bool CMBFileUtil::createLevelDir(QString path)
{
@@ -30,3 +35,38 @@
    return folder.mkpath(path);
}
QString CMBFileUtil::genSvrPath(QString rootPath, QString fileName, QString svrPath)
{
     QString tmpSvrPath,retSvrPath;
    retSvrPath = svrPath;
    tmpSvrPath = getPath(fileName);
    tmpSvrPath = tmpSvrPath.replace(rootPath, "");
    tmpSvrPath += "/";
    // 去除前后斜杠
    tmpSvrPath = trimedSlash(tmpSvrPath);
    svrPath    = trimedSlash(svrPath);
    if( !tmpSvrPath.isEmpty() ){
         retSvrPath = svrPath + "/" + tmpSvrPath;
    }
    retSvrPath = trimedSlash(retSvrPath);
    return retSvrPath;
}
QString CMBFileUtil::trimedSlash(QString str)
{
    int nStartPos = str.indexOf("/");
    int nPos = str.lastIndexOf("/");
    if( nPos == str.length() -1 ){
        str = str.left(nPos);
    }
    if( nStartPos == 0 ){
        str = str.right(str.length()-1);
    }
    return str;
}