Example #1
0
BOOL CSimpleEditorDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	CStringA pathA(lpszPathName);
	try
	{
		m_spImage = make_shared<CImageEditor>(CString(lpszPathName));
		//String s(pathA);

		//m_spImage = make_shared<Mat>(imread(s));
		//cv::imwrite(String("D:\\TMP\\1.jpg"), *m_spImage);
		//m_spBitmap = make_shared<Gdiplus::Bitmap>(lpszPathName);
		//IplImage img = ;
	}
	catch (CMemoryException* e)
	{
		throw;
	}
	catch (CFileException* e)
	{
		throw;
	}
	catch (CException* e)
	{
		throw;
	}
	return TRUE;
}
Example #2
0
void VDFileSetAttributes(const wchar_t *path, uint32 attrsToChange, uint32 newAttrs) {
    const uint32 nativeAttrMask = VDFileGetNativeAttributesFromAttrsW32(attrsToChange);
    const uint32 nativeAttrVals = VDFileGetNativeAttributesFromAttrsW32(newAttrs);

    if (VDIsWindowsNT()) {
        DWORD nativeAttrs = ::GetFileAttributesW(path);

        if (nativeAttrs != INVALID_FILE_ATTRIBUTES) {
            nativeAttrs ^= (nativeAttrs ^ nativeAttrVals) & nativeAttrMask;

            if (::SetFileAttributesW(path, nativeAttrs))
                return;
        }
    } else {
        VDStringA pathA(VDTextWToA(path));

        DWORD nativeAttrs = ::GetFileAttributesA(pathA.c_str());

        if (nativeAttrs != INVALID_FILE_ATTRIBUTES) {
            nativeAttrs ^= (nativeAttrs ^ nativeAttrVals) & nativeAttrMask;

            if (::SetFileAttributesA(pathA.c_str(), nativeAttrs))
                return;
        }
    }

    throw MyWin32Error("Cannot change attributes on \"%ls\": %%s.", GetLastError(), path);
}
Example #3
0
BOOL CSimpleEditorDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
	CStringA pathA(lpszPathName);
	if (m_spImage)
		m_spImage->Save(lpszPathName);
	//cvSaveImage(pathA, m_spImage.get());
	return TRUE;
}
Example #4
0
PDB WINAPI SdbpCreate(LPCWSTR path, PATH_TYPE type, BOOL write)
{
    PDB db;
    FILE* f;
    std::string pathA(path, path + SdbpStrlen(path));

    f = fopen(pathA.c_str(), write ? "wb" : "rb");
    if (!f)
        return NULL;

    db = (PDB)SdbAlloc(sizeof(DB));
    db->file = f;

    return db;
}
Example #5
0
static void GetModules(str::Str<char>& s)
{
    HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
    if (snap == INVALID_HANDLE_VALUE) return;

    MODULEENTRY32 mod;
    mod.dwSize = sizeof(mod);
    BOOL cont = Module32First(snap, &mod);
    while (cont) {
        ScopedMem<char> nameA(str::conv::ToUtf8(mod.szModule));
        ScopedMem<char> pathA(str::conv::ToUtf8(mod.szExePath));
        s.AppendFmt("Module: %08X %06X %-16s %s\r\n", (DWORD)mod.modBaseAddr, (DWORD)mod.modBaseSize, nameA, pathA);
        cont = Module32Next(snap, &mod);
    }
    CloseHandle(snap);
}
Example #6
0
VDStringW VDGetFullPath(const wchar_t *partialPath) {
    static tpGetFullPathNameW spGetFullPathNameW = (tpGetFullPathNameW)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetFullPathNameW");

    union {
        char		a[MAX_PATH];
        wchar_t		w[MAX_PATH];
    } tmpBuf;

    if (spGetFullPathNameW && !(GetVersion() & 0x80000000)) {
        LPWSTR p;

        tmpBuf.w[0] = 0;
        DWORD count = spGetFullPathNameW(partialPath, MAX_PATH, tmpBuf.w, &p);

        if (count < MAX_PATH)
            return VDStringW(tmpBuf.w);

        VDStringW tmp(count);

        DWORD newCount = spGetFullPathNameW(partialPath, count, (wchar_t *)tmp.data(), &p);
        if (newCount < count)
            return tmp;

        return VDStringW(partialPath);
    } else {
        LPSTR p;
        VDStringA pathA(VDTextWToA(partialPath));

        tmpBuf.a[0] = 0;
        DWORD count = GetFullPathNameA(pathA.c_str(), MAX_PATH, tmpBuf.a, &p);

        if (count < MAX_PATH)
            return VDStringW(VDTextAToW(tmpBuf.a));

        VDStringA tmpA(count);

        DWORD newCount = GetFullPathNameA(pathA.c_str(), count, (char *)tmpA.data(), &p);
        if (newCount < count)
            return VDTextAToW(tmpA);

        return VDStringW(partialPath);
    }
}
Example #7
0
// returns true if running on wine (winex11.drv is present)
// it's not a logical, but convenient place to do it
static bool GetModules(str::Str<char>& s)
{
    bool isWine = false;
    HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
    if (snap == INVALID_HANDLE_VALUE)
        return true;

    MODULEENTRY32 mod;
    mod.dwSize = sizeof(mod);
    BOOL cont = Module32First(snap, &mod);
    while (cont) {
        ScopedMem<char> nameA(str::conv::ToUtf8(mod.szModule));
        if (str::EqI(nameA.Get(), "winex11.drv"))
            isWine = true;
        ScopedMem<char> pathA(str::conv::ToUtf8(mod.szExePath));
        s.AppendFmt("Module: %p %06X %-16s %s\r\n", mod.modBaseAddr, mod.modBaseSize, nameA.Get(), pathA.Get());
        cont = Module32Next(snap, &mod);
    }
    CloseHandle(snap);
    return isWine;
}
Example #8
0
DWORD WINAPI execute_python_script(LPVOID param)
{
    wchar_t *path = (wchar_t*)param;
    Addtolist(0, WHITE, NAME_PLUGIN L" Trying to execute the script located here: '%s'..", path);

    std::wstring pathW(path);
    std::string pathA(widechar_to_multibytes(pathW));

    PyObject* PyFileObject = PyFile_FromString((char*)pathA.c_str(), "r");
    if(PyFileObject == NULL)
    {
        Addtolist(0, RED, NAME_PLUGIN L" Your file doesn't exist.");
        goto clean;
    }

    PyRun_SimpleFile(PyFile_AsFile(PyFileObject), (char*)pathA.c_str());

    Addtolist(0, WHITE, NAME_PLUGIN L" Execution is done!");

clean:
    free(path);
    return 1;
}
Example #9
0
bool CMakeCondition::evaluateCondition(QStringList::const_iterator itBegin, QStringList::const_iterator itEnd) const
{
    if(itBegin==itEnd)
    {
        return isTrue(*itBegin);
    }
    
    bool last = false, done=false;
    last = isTrue(*(prevOperator(itEnd, itBegin)+1));
    while(!done && itBegin!=itEnd)
    {
        QStringList::const_iterator it2;
        it2 = prevOperator(itEnd, itBegin);
        
        done=(itBegin==it2);
        conditionToken c = typeName(*it2);

//         qDebug() << "operator" << *it2 << done;
        QString cmd;
        
        switch(c)
        {
            case NOT:
                last = !last;
                itEnd=it2;
                break;
            case COMMAND:
#ifdef Q_OS_WIN
                cmd = CMakeProjectVisitor::findFile(*(it2+1),
                        CMakeProjectVisitor::envVarDirectories("Path"), QStringList(), CMakeProjectVisitor::Executable);
#else
                cmd = CMakeProjectVisitor::findFile(*(it2+1),
                        CMakeProjectVisitor::envVarDirectories("PATH"), QStringList(), CMakeProjectVisitor::Executable);
#endif
                last = !cmd.isEmpty();
                itEnd=it2-1;
                break;
            case EXISTS:
            {
                QString v=*(it2+1);
//                 kDebug(9042) << "EXISTS" << v << *it2;
                if(v.isEmpty())
                    kDebug(9042) << "error: no";
                else
                {
                    last=false;
                    QFileInfo f(v);
                    if(f.exists())
                    {
                        last=true;
                    }
                }
                itEnd=it2;
            }   break;
            case IS_DIRECTORY: {
                QFileInfo f(*(it2+1));
                last = f.isDir();
                itEnd=it2;
            }   break;
            case DEFINED:
                last=m_vars->contains(*(it2+1));
                itEnd=it2;
                break;
            case AND:
                return evaluateCondition(itBegin, it2-1) && last;
            case OR:
                return evaluateCondition(itBegin, it2-1) || last;
            case MATCHES: {
                QRegExp rx(*(it2+1));
                if(m_vars->contains(*(it2-1)))
                    rx.indexIn(m_vars->value(*(it2-1)).join(""));
                else
                    rx.indexIn(*(it2-1));
                last=rx.matchedLength()>0;
                itEnd=it2-1;
            }   break;
            case LESS: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                int a=strA.toInt(), b=strB.toInt();
                last= (a<b);
                itEnd=it2-1;
            }   break;
            case GREATER: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                int a=strA.toInt(), b=strB.toInt();
                last= (a>b);
                itEnd=it2-1;
            }   break;
            case EQUAL: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                int a=strA.toInt(), b=strB.toInt();
                last= (a==b);
                itEnd=it2-1;
            }   break;
            case STRLESS: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                last= (strA<strB);
                itEnd=it2-1;
            }   break;
            case STRGREATER: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                last= (strA>strB);
                itEnd=it2-1;
            }   break;
            case STREQUAL: {
                QString strA=*(it2-1);
                QString strB=*(it2+1);
                if(m_vars->contains(strA))
                    strA=m_vars->value(strA).join(";");
                last= (strA==strB);
                itEnd=it2-1;
            }   break;
            case IS_NEWER_THAN: {
                QFileInfo pathA(*(it2-1));
                QFileInfo pathB(*(it2+1));
//                 kDebug(9042) << "newer" << strA << strB;
                last= (pathA.lastModified()>pathB.lastModified());
                itEnd=it2-1;
            }
            /*default:
                kDebug(9042) << "no operator:" << *it2;
                break;*/
        }
    }
    return last;
}