BOOL CFCacheImpl::AddFile( LPCWSTR lpFilePath, ULONGLONG qwFileSize ) { BOOL retval = FALSE; int nRetCode; char* szError = NULL; CStringA strSql; CStringW strFilePath; CStringW strExt; int nExt; if (!m_pDbConnect) goto clean0; if (!lpFilePath) goto clean0; strFilePath = lpFilePath; strFilePath.MakeLower(); nExt = strFilePath.ReverseFind(_T('.')); if (nExt != -1 && nExt > strFilePath.ReverseFind(_T('\\'))) { strExt = strFilePath.Right(strFilePath.GetLength() - nExt); } if (strExt.IsEmpty()) { strExt = _T(".n/a"); } strSql.Format("insert into files values('%s', '%s', %I64d)", KUTF16_To_UTF8(strFilePath), KUTF16_To_UTF8(strExt), qwFileSize); nRetCode = sqlite3_exec(m_pDbConnect, strSql, NULL, NULL, &szError); if (nRetCode) goto clean0; retval = TRUE; clean0: return retval; }
// ************************************************************* // GetDbSchemeName() // ************************************************************* CStringW OgrStyleHelper::GetDbSchemeName(CStringW layerName, bool withTrailingPoint) { int pos = layerName.ReverseFind(L'.'); if (pos != -1) { return layerName.Mid(0, pos + withTrailingPoint ? 1 : 0); } return L""; }
std::vector<CStringW> Unzip::Extract(LPCWSTR pszFilename, LPCWSTR pszFolder, std::function<bool(LPCWSTR filePath, DWORD& flagsAndAttributes)> predicate) { std::vector<CStringW> result; unzFile uf = NULL; try { uf = Unzip_Open(pszFilename); unz_global_info gi; if (UNZ_OK != unzGetGlobalInfo(uf, &gi)) throw runtime_error("failed to unzGetGlobalInfo"); for (uLong i = 0; i < gi.number_entry; ++i) { FILETIME ftLocal; CStringW path = CStringW(pszFolder) + L'\\' + Unzip_GetCurentFilePath(uf, ftLocal); CStringW filename = path.Mid(path.ReverseFind(L'\\') + 1); if (filename.IsEmpty()) { if (!CreateDirectoryW(path, NULL)) throw runtime_error("failed to CreateDirectory"); continue; } DWORD flagsAndAttributes = FILE_ATTRIBUTE_NORMAL; if (predicate(path, flagsAndAttributes)) { Unzip_ExtractFile(uf, path, flagsAndAttributes, ftLocal); result.push_back(path); } if (i + 1 < gi.number_entry && UNZ_OK != unzGoToNextFile(uf)) throw runtime_error("failed to unzGoToNextFile"); } unzClose(uf); return result; } catch (...) { if (uf != NULL) unzClose(uf); for each (auto file in result) DeleteFileW(file); throw; } }
BOOL CDdnPayCardApp::InitInstance() { CWinApp::InitInstance(); WCHAR chPath[512] = {0}; GetModuleFileNameW(this->m_hInstance,chPath,512); CStringW strFilew = chPath; strFilew = strFilew.Left(strFilew.ReverseFind(_T('\\'))); strFilew += _T("\\CardLog\\"); _wmkdir(strFilew); GXX_LOG_CREATE(strFilew); GXX_LOG_HIT(_T("init instance")); G2XStartup(); return TRUE; }
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) { int argc; LPWSTR *argv; HKEY hKey; BOOL bShowMsg = TRUE; DWORD dwDisp; argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); CStringW wcsPath = argv[0]; WCHAR szSysDir[256]; CStringW wcsSysDir; ::LocalFree(argv); wcsPath = wcsPath.Mid(0, wcsPath.ReverseFind(L'\\') + 1); // note: '\\' is included in the Path ::GetSystemDirectoryW(szSysDir, 256); wcsSysDir = szSysDir; // --- for TCC file // --- Reg ".tcc" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L".tcc", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"TCC_File_Type", 0); ::RegCloseKey(hKey); // --- Reg "shell\open\command" of "TCC_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCC_File_Type\\shell\\open\\command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"\"" + wcsSysDir + L"\\notepad.exe\" \"%1\"", 0); ::RegCloseKey(hKey); // --- Reg "shell\edit\command" of "TCC_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCC_File_Type\\shell\\edit\\command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"\"" + wcsSysDir + L"\\notepad.exe\" \"%1\"", 0); ::RegCloseKey(hKey); // --- Reg "shell\parse" of "TCC_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCC_File_Type\\shell\\parse", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"Parse", 0); ::RegCloseKey(hKey); // --- Reg "shell\parse\command" of "TCC_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCC_File_Type\\shell\\parse\\command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"\"" + wcsPath + L"tcax.exe\" \"%L\"", 0); ::RegCloseKey(hKey); // --- Reg "DefaultIcon" of "TCC_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCC_File_Type\\DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, wcsPath + L"icons\\tcc.ico", 0); ::RegCloseKey(hKey); // --- for ASS file // --- Reg ".ass" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L".ass", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"ASS_File_Type", 0); ::RegCloseKey(hKey); // --- Reg "DefaultIcon" of "ASS_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"ASS_File_Type\\DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, wcsPath + L"icons\\ass.ico", 0); ::RegCloseKey(hKey); // --- for tcas file // --- Reg ".tcas" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L".tcas", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"TCAS_File_Type", 0); ::RegCloseKey(hKey); // --- Reg "shell\open\command" of "TCAS_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCAS_File_Type\\shell\\open\\command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, L"\"" + wcsPath + L"tools\\timeShift.exe\" \"%L\"", 0); ::RegCloseKey(hKey); // --- Reg "DefaultIcon" of "TCAS_File_Type" in "HKEY_CLASSES_ROOT" if (::RegCreateKeyExW( HKEY_CLASSES_ROOT, L"TCAS_File_Type\\DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS) { return FALSE; } ::RegSetValueW(hKey, NULL, REG_SZ, wcsPath + L"icons\\tcas.ico", 0); ::RegCloseKey(hKey); ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, 0, 0); ::MessageBoxW(NULL, L"TCAX file association successfully executed.\n\nTCAX程序文件关联成功执行, 请点确定.", L"TCAX - Info", MB_OK | MB_ICONINFORMATION); return TRUE; }
HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin) { HRESULT hr = __super::CompleteConnect(pReceivePin); if (FAILED(hr)) { return hr; } (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this, pReceivePin); m_fCanBlock = false; bool fForkedSomewhere = false; CStringW fileName; CStringW pinName; IPin* pPin = (IPin*)this; IBaseFilter* pBF = (IBaseFilter*)m_pFilter; pPin = GetUpStreamPin(pBF, pPin); if (pPin) { pBF = GetFilterFromPin(pPin); } while (pPin && pBF) { if (IsSplitter(pBF)) { pinName = GetPinName(pPin); } CLSID clsid = GetCLSID(pBF); if (clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) { m_fCanBlock = true; } int nIn, nOut, nInC, nOutC; CountPins(pBF, nIn, nOut, nInC, nOutC); fForkedSomewhere = fForkedSomewhere || nIn > 1 || nOut > 1; DWORD cStreams = 0; if (CComQIPtr<IAMStreamSelect> pSSF = pBF) { hr = pSSF->Count(&cStreams); if (SUCCEEDED(hr)) { for (int i = 0; i < (int)cStreams; i++) { AM_MEDIA_TYPE* pmt = nullptr; hr = pSSF->Info(i, &pmt, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); if (SUCCEEDED(hr) && pmt && pmt->majortype == MEDIATYPE_Audio) { m_pSSF = pSSF; DeleteMediaType(pmt); break; } DeleteMediaType(pmt); } } } if (CComQIPtr<IFileSourceFilter> pFSF = pBF) { WCHAR* pszName = nullptr; AM_MEDIA_TYPE mt; if (SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) { fileName = pszName; CoTaskMemFree(pszName); fileName.Replace('\\', '/'); CStringW fn = fileName.Mid(fileName.ReverseFind('/') + 1); if (!fn.IsEmpty()) { fileName = fn; } // Haali & LAVFSplitter return only one "Audio" pin name, cause CMainFrame::OnInitMenuPopup lookup find the wrong popmenu, // add space at the end to prevent this, internal filter never return "Audio" only. if (!pinName.IsEmpty()) { fileName = pinName + L" "; } WCHAR* pName = DEBUG_NEW WCHAR[fileName.GetLength() + 1]; if (pName) { wcscpy_s(pName, fileName.GetLength() + 1, fileName); if (m_pName) { delete [] m_pName; } m_pName = pName; if (cStreams == 1) { // Simple external track, no need to use the info from IAMStreamSelect m_pSSF.Release(); } } } break; } pPin = GetFirstPin(pBF); pPin = GetUpStreamPin(pBF, pPin); if (pPin) { pBF = GetFilterFromPin(pPin); } } if (!fForkedSomewhere) { m_fCanBlock = true; } m_hNotifyEvent = nullptr; return S_OK; }
HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin) { HRESULT hr = __super::CompleteConnect(pReceivePin); if(FAILED(hr)) return hr; ((CStreamSwitcherFilter*)m_pFilter)->CompleteConnect(PINDIR_INPUT, this, pReceivePin); m_fCanBlock = false; bool fForkedSomewhere = false; CStringW fileName; CStringW pinName; IPin* pPin = (IPin*)this; IBaseFilter* pBF = (IBaseFilter*)m_pFilter; while((pPin = GetUpStreamPin(pBF, pPin)) && (pBF = GetFilterFromPin(pPin))) { if(IsSplitter(pBF)) { pinName = GetPinName(pPin); } CLSID clsid = GetCLSID(pBF); if(clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) m_fCanBlock = true; int nIn, nOut, nInC, nOutC; CountPins(pBF, nIn, nOut, nInC, nOutC); fForkedSomewhere = fForkedSomewhere || nIn > 1 || nOut > 1; if(CComQIPtr<IFileSourceFilter> pFSF = pBF) { WCHAR* pszName = NULL; AM_MEDIA_TYPE mt; if(SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) { fileName = pszName; CoTaskMemFree(pszName); fileName.Replace('\\', '/'); CStringW fn = fileName.Mid(fileName.ReverseFind('/')+1); if(!fn.IsEmpty()) fileName = fn; if(!pinName.IsEmpty()) fileName += L" / " + pinName; WCHAR* pName = new WCHAR[fileName.GetLength()+1]; if(pName) { wcscpy(pName, fileName); if(m_pName) delete [] m_pName; m_pName = pName; } } break; } pPin = GetFirstPin(pBF); } if(!fForkedSomewhere) m_fCanBlock = true; m_hNotifyEvent = NULL; return S_OK; }
ULONG CFormData::ProcessForm() { CStringA startPart = "--" + CStringA(m_sBoundary) + "\r\n"; Append(startPart); BOOL bHasFields = FALSE; //STLOG_WRITE("%s(%d): Ponto de apoio", __FUNCTION__, __LINE__); // Varrer os fields primeiro POSITION p1 = m_items.GetStartPosition(); while(p1) { CStringW key1; CFormItem *pAttr; m_items.GetNextAssoc(p1, key1, pAttr); if(!pAttr->m_bFile) { bHasFields = TRUE; CStringW s; s.Format(FIELD_BOUND, pAttr->m_name, pAttr->m_value); Append(CStringA(s)); } if(p1 != NULL) { startPart = "--" + CStringA(m_sBoundary) + "\r\n"; Append(startPart); } } //STLOG_WRITE("%s(%d): Ponto de apoio", __FUNCTION__, __LINE__); BOOL bFirst = TRUE; // Varrer os files p1 = m_items.GetStartPosition(); while(p1) { CStringW key1; CFormItem *pAttr; m_items.GetNextAssoc(p1, key1, pAttr); if(pAttr->m_bFile) { if(bFirst && bHasFields) { startPart = "--" + CStringA(m_sBoundary) + "\r\n"; Append(startPart); bFirst = FALSE; } CStringW sFileName = pAttr->m_value; if(sFileName.Find('\\') >= 0 || sFileName.Find('/') >= 0) { int pos = sFileName.ReverseFind('\\'); if(pos < 0) pos = sFileName.ReverseFind('/'); sFileName = sFileName.Mid(pos+1); } CStringW s; s.Format(FILE_BOUND, pAttr->m_name, sFileName, pAttr->m_mime); Append(CStringA(s)); Append("\r\n"); AppendFile(pAttr->m_value); Append("\r\n"); if(p1 != NULL) { startPart = "--" + CStringA(m_sBoundary) + "\r\n"; Append(startPart); } } } startPart = "--" + CStringA(m_sBoundary) + "--\r\n"; Append(startPart); //STLOG_WRITE("%s(%d): Ponto de apoio", __FUNCTION__, __LINE__); //STLOG_WRITE("%s(%d): Buffer: %s", __FUNCTION__, __LINE__, m_buffer.GetData()); return m_buffer.GetCount(); }
HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin) { HRESULT hr = __super::CompleteConnect(pReceivePin); if (FAILED(hr)) { return hr; } (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this, pReceivePin); m_fCanBlock = false; bool fForkedSomewhere = false; CStringW fileName; CStringW pinName; IPin* pPin = (IPin*)this; IBaseFilter* pBF = (IBaseFilter*)m_pFilter; pPin = GetUpStreamPin(pBF, pPin); if (pPin) { pBF = GetFilterFromPin(pPin); } while (pPin && pBF) { if (IsSplitter(pBF)) { pinName = GetPinName(pPin); } CLSID clsid = GetCLSID(pBF); if (clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter) { m_fCanBlock = true; } int nIn, nOut, nInC, nOutC; CountPins(pBF, nIn, nOut, nInC, nOutC); fForkedSomewhere = fForkedSomewhere || nIn > 1 || nOut > 1; if (CComQIPtr<IFileSourceFilter> pFSF = pBF) { WCHAR* pszName = NULL; AM_MEDIA_TYPE mt; if (SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName) { fileName = pszName; CoTaskMemFree(pszName); fileName.Replace('\\', '/'); CStringW fn = fileName.Mid(fileName.ReverseFind('/')+1); if (!fn.IsEmpty()) { fileName = fn; } // Haali & LAVFSplitter return only one "Audio" pin name, cause CMainFrame::OnInitMenuPopup lookup find the wrong popmenu, // add space at the end to prevent this, internal filter never return "Audio" only. if (!pinName.IsEmpty()) { fileName = pinName + L" "; } WCHAR* pName = DNew WCHAR[fileName.GetLength()+1]; if (pName) { wcscpy_s(pName, fileName.GetLength() + 1, fileName); if (m_pName) { delete [] m_pName; } m_pName = pName; } } break; } pPin = GetFirstPin(pBF); pPin = GetUpStreamPin(pBF, pPin); if (pPin) { pBF = GetFilterFromPin(pPin); } } if (!fForkedSomewhere) { m_fCanBlock = true; } m_hNotifyEvent = NULL; return S_OK; }
BOOL CFCacheImpl::DelFile(LPCWSTR lpFilePath) { BOOL retval = FALSE; int nRetCode; char* szError = NULL; CStringA strSql; CStringW strFilePath; int nExt; CStringW strExt; sqlite3_stmt* pStmt = NULL; ULONGLONG qwSize; if (!m_pDbConnect) goto clean0; if (!lpFilePath) goto clean0; strFilePath = lpFilePath; strFilePath.MakeLower(); nExt = strFilePath.ReverseFind(_T('.')); if (nExt != -1 && nExt > strFilePath.ReverseFind(_T('\\'))) { strExt = strFilePath.Right(strFilePath.GetLength() - nExt); } if (strExt.IsEmpty()) { strExt = _T(".n/a"); } // 获得大小 strSql.Format("select size from files where path = '%s'", KUTF16_To_UTF8(strFilePath)); nRetCode = sqlite3_prepare(m_pDbConnect, strSql, -1, &pStmt, 0); if (nRetCode) goto clean0; nRetCode = sqlite3_step(pStmt); if (SQLITE_ROW != nRetCode) goto clean0; qwSize = sqlite3_column_int64(pStmt, 0); // 删除文件 strSql.Format("delete from files where path = '%s'", KUTF16_To_UTF8(strFilePath)); nRetCode = sqlite3_exec(m_pDbConnect, strSql, NULL, NULL, &szError); if (nRetCode) goto clean0; // 从Top100中删除 strSql.Format("delete from top100 where path = '%s'", KUTF16_To_UTF8(strFilePath)); nRetCode = sqlite3_exec(m_pDbConnect, strSql, NULL, NULL, &szError); // 从Exts中去除大小 strSql.Format("insert into exts values('%s', -%I64d, -1)", KUTF16_To_UTF8(strExt), qwSize); nRetCode = sqlite3_exec(m_pDbConnect, strSql, NULL, NULL, &szError); // 从总大小中去除大小 strSql.Format("insert into info values(-%I64d, -1)", qwSize); nRetCode = sqlite3_exec(m_pDbConnect, strSql, NULL, NULL, &szError); retval = TRUE; clean0: if (pStmt) { sqlite3_finalize(pStmt); pStmt = NULL; } return retval; }