예제 #1
0
파일: AppEnv.cpp 프로젝트: bsdelf/mous
bool AppEnv::Init()
{
#ifdef CMAKE_INSTALL_PREFIX
    pluginDir = QString(CMAKE_INSTALL_PREFIX) + Path::Plugin;
    resourceDir = QString(CMAKE_INSTALL_PREFIX) + Path::Resource;
#else
    QStringList libPathes =
            (QStringList() << ("/usr/local" + Path::Plugin) << ("/usr" + Path::Plugin));
    foreach (QString path, libPathes) {
        if (QFileInfo(path).isDir()) {
            pluginDir = path;
            break;
        }
    }
    QStringList resPathes =
            (QStringList() << ("/usr/local" + Path::Resource) << ("/usr" + Path::Resource));
    foreach (QString path, resPathes) {
        if (QFileInfo(path).isDir()) {
            resourceDir = path;
            break;
        }
    }
#endif
    if (pluginDir.isEmpty()) {
        qDebug() << "FATAL: plugin directory is empty";
        return false;
    }
    if (resourceDir.isEmpty()) {
        qDebug() << "FATAL: resource directory is empty";
        return false;
    }
    InitFilePath();
    return LoadConfig();
}
예제 #2
0
BOOL
CFileDefExt::InitGeneralPage(HWND hwndDlg)
{
    /* Set general text properties filename filelocation and icon */
    InitFilePath(hwndDlg);

    /* Set file type and icon */
    InitFileType(hwndDlg);

    /* Set open with application */
    if (!m_bDir)
    {
        if (!PathIsExeW(m_wszPath))
            InitOpensWithField(hwndDlg);
        else
        {
            WCHAR wszBuf[MAX_PATH];
            LoadStringW(shell32_hInstance, IDS_EXE_DESCRIPTION, wszBuf, _countof(wszBuf));
            SetDlgItemTextW(hwndDlg, 14006, wszBuf);
            ShowWindow(GetDlgItem(hwndDlg, 14024), SW_HIDE);
            LPCWSTR pwszDescr = m_VerInfo.GetString(L"FileDescription");
            if (pwszDescr)
                SetDlgItemTextW(hwndDlg, 14007, pwszDescr);
            else
            {
                StringCbCopyW(wszBuf, sizeof(wszBuf), PathFindFileNameW(m_wszPath));
                PathRemoveExtension(wszBuf);
                SetDlgItemTextW(hwndDlg, 14007, wszBuf);
            }
        }
    }

    /* Set file created/modfied/accessed time, size and attributes */
    InitFileAttr(hwndDlg);

    return TRUE;
}
예제 #3
0
int CheckpointReceiver :: ReceiveCheckpoint(const CheckpointMsg & oCheckpointMsg)
{
    if (oCheckpointMsg.nodeid() != m_iSenderNodeID
            || oCheckpointMsg.uuid() != m_llUUID)
    {
        PLGErr("msg not valid, Msg.SenderNodeID %lu Receiver.SenderNodeID %lu Msg.UUID %lu Receiver.UUID %lu",
                oCheckpointMsg.nodeid(), m_iSenderNodeID, oCheckpointMsg.uuid(), m_llUUID);
        return -2;
    }

    if (oCheckpointMsg.sequence() == m_llSequence)
    {
        PLGErr("msg already receive, skip, Msg.Sequence %lu Receiver.Sequence %lu",
                oCheckpointMsg.sequence(), m_llSequence);
        return 0;
    }

    if (oCheckpointMsg.sequence() != m_llSequence + 1)
    {
        PLGErr("msg sequence wrong, Msg.Sequence %lu Receiver.Sequence %lu",
                oCheckpointMsg.sequence(), m_llSequence);
        return -2;
    }

    string sFilePath = GetTmpDirPath(oCheckpointMsg.smid()) + "/" + oCheckpointMsg.filepath();
    string sFormatFilePath;
    int ret = InitFilePath(sFilePath, sFormatFilePath);
    if (ret != 0)
    {
        return -1;
    }

    int iFd = open(sFormatFilePath.c_str(), O_CREAT | O_RDWR | O_APPEND, S_IWRITE | S_IREAD);
    if (iFd == -1)
    {
        PLGErr("open file fail, filepath %s", sFormatFilePath.c_str());
        return -1;
    }

    size_t llFileOffset = lseek(iFd, 0, SEEK_END);
    if ((uint64_t)llFileOffset != oCheckpointMsg.offset())
    {
        PLGErr("file.offset %zu not equal to msg.offset %lu", llFileOffset, oCheckpointMsg.offset());
        close(iFd);
        return -2;
    }

    size_t iWriteLen = write(iFd, oCheckpointMsg.buffer().data(), oCheckpointMsg.buffer().size());
    if (iWriteLen != oCheckpointMsg.buffer().size())
    {
        PLGImp("write fail, writelen %zu buffer size %zu", iWriteLen, oCheckpointMsg.buffer().size());
        close(iFd);
        return -1;
    }

    m_llSequence++;
    close(iFd);

    PLGImp("END ok, writelen %zu", iWriteLen);

    return 0;
}