ENUM_ExtractErrorCode ExtractOfficePackage( LPCTSTR szPkgFilename, LPCTSTR szDestPath, Files &files ) { Files mspfiles, cabfiles, dstfiles; if(!CreateDirectoryNested(szDestPath)) return EE_PATH; if(!ExtractExe(szPkgFilename, szDestPath, mspfiles)) return EE_EXE; for(int i=0; i<mspfiles.size(); ++i) { CString strPath = mspfiles[i]; strPath += UPK_PATH_SUFFIX; if(!CreateDirectoryNested(strPath)) return EE_PATH; if(!ExtractMSP(mspfiles[i], strPath, cabfiles)) return EE_MSP; } for(int i=0; i<cabfiles.size(); ++i) { CString strPath = cabfiles[i]; strPath += UPK_PATH_SUFFIX; if(!CreateDirectoryNested(strPath)) return EE_PATH; if(!ExtractCab(cabfiles[i], strPath, files)) return EE_CAB; } return EE_SUCCESS; }
HRESULT CImplRepairVul::Repair(LPCTSTR sDownloadPath, LPCTSTR szImportPath, DWORD dwFlags) { if(m_arrDownloadItem.GetSize()==0) return KERR_NONE; if( !sDownloadPath || !CreateDirectoryNested(sDownloadPath) ) return KERR_WRITE_FILE; HRESULT hr = S_OK; CSysEnv& sysEnv = singleton<CSysEnv>::Instance(); sysEnv.Init(); if( FAILED( hr=sysEnv.IsSupported(TRUE) ) ) return hr; //if(CheckIfFirstRunLeakRepair()) // FixUpdateGarbage(); m_strDownloadPath = sDownloadPath; m_strImportPath = szImportPath ? szImportPath : _T(""); m_dwRepairFlags = dwFlags; m_bCanceled = FALSE; if(m_thinfo.m_hInstallEvent) { CloseHandle( m_thinfo.m_hInstallEvent ); m_thinfo.m_hInstallEvent = NULL; } m_thinfo.m_hInstallEvent = CreateEvent(NULL,FALSE,FALSE,NULL); m_hHandleDownload = CreateThread(NULL, 0, _ThreadFuncDownload, (PVOID)this, 0, NULL); m_hHandleInstall = CreateThread(NULL, 0, _ThreadFuncInstall, (PVOID)this, 0, NULL); return S_OK; }
BOOL CreateDirectoryNested( LPCTSTR lpszDir ) { if( ::PathIsDirectory( lpszDir ) ) return TRUE; if(_tcslen(lpszDir)>=MAX_PATH) return FALSE; TCHAR szPreDir[ MAX_PATH ]; _tcscpy_s( szPreDir, lpszDir ); //确保路径末尾没有反斜杠 ModifyPathSpec( szPreDir, FALSE ); //获取上级目录 BOOL bGetPreDir = ::PathRemoveFileSpec( szPreDir ); if( !bGetPreDir ) return FALSE; //如果上级目录不存在,则递归创建上级目录 if( !::PathIsDirectory( szPreDir ) ) { CreateDirectoryNested( szPreDir ); } return ::CreateDirectory( lpszDir, NULL ); }
void UpkExeFile( BOOL bNewMethod, LPCTSTR szPath ) { CString strTmpPath; GetTempUpkPath(strTmpPath); CreateDirectoryNested(strTmpPath); Files files; INT err = bNewMethod ? ExtractOfficePackage(szPath, strTmpPath, files) : UpkUse7z(szPath, strTmpPath, files); _tprintf(_T("- UPK OFFICE FILE :%s - %d -> %s\r\n"), szPath, err, strTmpPath); DumpFiles(files, TRUE); _tprintf(_T("--END \r\n")); //DeletePath(strTmpPath); }
BOOL CreateDirEx (const char *lpFullPath, DWORD dwFileAttributes) { USES_CONVERSION; return CreateDirectoryNested( CA2CT(lpFullPath) ); }
BOOL CCommon::gr_create_folder(CString csPath) { return CreateDirectoryNested(csPath); }