// Return TRUE if the current component is parent of the given component bool VssComponent::IsAncestorOf(VssComponent & descendent) { // The child must have a longer full path if (descendent.fullPath.length() <= fullPath.length()) return false; wstring fullPathAppendedWithBackslash = AppendBackslash(fullPath); wstring descendentPathAppendedWithBackslash = AppendBackslash(descendent.fullPath); // Return TRUE if the current full path is a prefix of the child full path return IsEqual(fullPathAppendedWithBackslash, descendentPathAppendedWithBackslash.substr(0, fullPathAppendedWithBackslash.length())); }
// Initialize a file descriptor from a void VssDependency::Initialize( IVssWMDependency * pDependency ) { FunctionTracer ft(DBG_INFO); VSS_ID guidWriterId; CHECK_COM(pDependency->GetWriterId(&guidWriterId)); CComBSTR bstrLogicalPath; CHECK_COM(pDependency->GetLogicalPath(&bstrLogicalPath)); CComBSTR bstrComponentName; CHECK_COM(pDependency->GetComponentName(&bstrComponentName)); // Initialize local data members writerId = Guid2WString(guidWriterId); logicalPath = BSTR2WString(bstrLogicalPath); componentName = BSTR2WString(bstrComponentName); // Compute the full path fullPath = AppendBackslash(logicalPath) + componentName; if (fullPath[0] != L'\\') fullPath = wstring(L"\\") + fullPath; }
BOOL C4SDefinitions::AssertModules(const char *szPath, char *sMissing) { // Local only if (LocalOnly) return TRUE; // Check all listed modules for availability BOOL fAllAvailable=TRUE; char szModule[_MAX_PATH+1]; if (sMissing) sMissing[0]=0; // Check all definition files for (int32_t cnt=0; cnt<C4S_MaxDefinitions; cnt++) if (Definition[cnt][0]) { // Compose filename using path specified by caller szModule[0]=0; if (szPath) SCopy(szPath,szModule); if (szModule[0]) AppendBackslash(szModule); SAppend(Definition[cnt],szModule); // Missing if (!C4Group_IsGroup(szModule)) { // Add to list if (sMissing) { SNewSegment(sMissing,", "); SAppend(Definition[cnt],sMissing); } fAllAvailable=FALSE; } } return fAllAvailable; }
bool C4VectorFont::Init(C4Group &hGrp, const char *szFilename, C4Config &rCfg) { // name by file Name.Copy(GetFilenameOnly(szFilename)); #if defined(_WIN32) && !defined(HAVE_FREETYPE) // check whether group is directory or packed if (!hGrp.IsPacked()) { // it's open: use the file directly SCopy(hGrp.GetFullName().getData(), FileName, _MAX_PATH); AppendBackslash(FileName); SAppend(szFilename, FileName); if (!FileExists(FileName)) { *FileName=0; return false; } fIsTempFile = false; } else { // it's packed: extract to temp path SCopy(rCfg.AtTempPath(szFilename), FileName, _MAX_PATH); // make sure the filename is not in use, in case multiple instances of the engine are run if (FileExists(FileName)) { RemoveExtension(FileName); StdStrBuf sNewFilename; for (int i=0; i<1000; ++i) { sNewFilename.Format("%s%x", FileName, (int)rand()); if (*GetExtension(szFilename)) { sNewFilename.AppendChar('.'); sNewFilename.Append(GetExtension(szFilename)); } if (!FileExists(sNewFilename.getData())) break; } SCopy(sNewFilename.getData(), FileName, _MAX_PATH); } if (!hGrp.ExtractEntry(szFilename, FileName)) { *FileName=0; return false; } fIsTempFile = true; } // add the font resource //if (!AddFontResourceEx(FileName, FR_PRIVATE, NULL)) requires win2k if (!AddFontResource(FileName)) { if (fIsTempFile) EraseFile(FileName); *FileName='\0'; return false; } #else if (!hGrp.LoadEntry(szFilename, Data)) return false; #endif // success return true; }
bool C4Network2ResList::CreateNetworkFolder() { // get network path without trailing backslash char szNetworkPath[_MAX_PATH+1]; SCopy(Config.AtNetworkPath(""), szNetworkPath, _MAX_PATH); TruncateBackslash(szNetworkPath); // but make sure that the configured path has one AppendBackslash(Config.Network.WorkPath); // does not exist? if (!DirectoryExists(szNetworkPath)) { if (!CreatePath(szNetworkPath)) { LogFatal("Network: could not create network path!"); return false; } return true; } return true; }
// Initialize a file descriptor from a void VssFileDescriptor::Initialize( IVssWMFiledesc * pFileDesc, VSS_DESCRIPTOR_TYPE typeParam ) { FunctionTracer ft(DBG_INFO); // Set the type type = typeParam; CComBSTR bstrPath; CHECK_COM(pFileDesc->GetPath(&bstrPath)); CComBSTR bstrFilespec; CHECK_COM(pFileDesc->GetFilespec (&bstrFilespec)); bool bRecursive = false; CHECK_COM(pFileDesc->GetRecursive(&bRecursive)); CComBSTR bstrAlternate; CHECK_COM(pFileDesc->GetAlternateLocation(&bstrAlternate)); // Initialize local data members path = BSTR2WString(bstrPath); filespec = BSTR2WString(bstrFilespec); expandedPath = bRecursive; path = BSTR2WString(bstrPath); // Get the expanded path expandedPath.resize(MAX_PATH, L'\0'); _ASSERTE(bstrPath && bstrPath[0]); CHECK_WIN32(ExpandEnvironmentStringsW(bstrPath, (PWCHAR)expandedPath.c_str(), (DWORD)expandedPath.length())); expandedPath = AppendBackslash(expandedPath); // Get the affected volume if (!GetUniqueVolumeNameForPathNoThrow(expandedPath, affectedVolume)) { affectedVolume = expandedPath; } }
// Initialize from a IVssComponent void VssComponent::Initialize(wstring writerNameParam, IVssComponent * pComponent) { FunctionTracer ft(DBG_INFO); writerName = writerNameParam; // Get component type CHECK_COM(pComponent->GetComponentType(&type)); // Get component name CComBSTR bstrComponentName; CHECK_COM(pComponent->GetComponentName(&bstrComponentName)); name = BSTR2WString(bstrComponentName); // Get component logical path CComBSTR bstrLogicalPath; CHECK_COM(pComponent->GetLogicalPath(&bstrLogicalPath)); logicalPath = BSTR2WString(bstrLogicalPath); // Compute the full path fullPath = AppendBackslash(logicalPath) + name; if (fullPath[0] != L'\\') fullPath = wstring(L"\\") + fullPath; }
// Initialize from a IVssWMComponent void VssComponent::Initialize(wstring writerNameParam, IVssWMComponent * pComponent) { FunctionTracer ft(DBG_INFO); writerName = writerNameParam; // Get the component info PVSSCOMPONENTINFO pInfo = NULL; CHECK_COM(pComponent->GetComponentInfo (&pInfo)); // Initialize local members name = BSTR2WString(pInfo->bstrComponentName); logicalPath = BSTR2WString(pInfo->bstrLogicalPath); caption = BSTR2WString(pInfo->bstrCaption); type = pInfo->type; isSelectable = pInfo->bSelectable; notifyOnBackupComplete = pInfo->bNotifyOnBackupComplete; // Compute the full path fullPath = AppendBackslash(logicalPath) + name; if (fullPath[0] != L'\\') fullPath = wstring(L"\\") + fullPath; // Get file list descriptors for(unsigned i = 0; i < pInfo->cFileCount; i++) { CComPtr<IVssWMFiledesc> pFileDesc; CHECK_COM(pComponent->GetFile (i, &pFileDesc)); VssFileDescriptor desc; desc.Initialize(pFileDesc, VSS_FDT_FILELIST); descriptors.push_back(desc); } // Get database descriptors for(unsigned i = 0; i < pInfo->cDatabases; i++) { CComPtr<IVssWMFiledesc> pFileDesc; CHECK_COM(pComponent->GetDatabaseFile (i, &pFileDesc)); VssFileDescriptor desc; desc.Initialize(pFileDesc, VSS_FDT_DATABASE); descriptors.push_back(desc); } // Get log descriptors for(unsigned i = 0; i < pInfo->cLogFiles; i++) { CComPtr<IVssWMFiledesc> pFileDesc; CHECK_COM(pComponent->GetDatabaseLogFile (i, &pFileDesc)); VssFileDescriptor desc; desc.Initialize(pFileDesc, VSS_FDT_DATABASE_LOG); descriptors.push_back(desc); } #ifdef VSS_SERVER // Get dependencies for(unsigned i = 0; i < pInfo->cDependencies; i++) { CComPtr<IVssWMDependency> pDependency; CHECK_COM(pComponent->GetDependency(i, &pDependency)); VssDependency dependency; dependency.Initialize(pDependency); dependencies.push_back(dependency); } #endif pComponent->FreeComponentInfo (pInfo); // Compute the affected paths and volumes for(unsigned i = 0; i < descriptors.size(); i++) { if (!FindStringInList(descriptors[i].expandedPath, affectedPaths)) affectedPaths.push_back(descriptors[i].expandedPath); if (!FindStringInList(descriptors[i].affectedVolume, affectedVolumes)) affectedVolumes.push_back(descriptors[i].affectedVolume); } sort( affectedPaths.begin( ), affectedPaths.end( ) ); }
bool ParseArguments( int argc, char** argv ) { strcpy( sourceFile, "" ); strcpy( skinName, "" ); strcpy( mbmPath, "" ); strcpy( sknPath, "" ); strcpy( dllPath, "" ); strcpy( iidFile, "" ); int fileParam = 0; for( int i=1; i<argc; i++ ) { if( sd_strcasecmp( "--drm", argv[i] ) == 0 ) { drmEnabled = true; } else if( sd_strcasecmp( "--forcesystem", argv[i] ) == 0 ) { forceSystem = true; } else if( sd_strcasecmp( "--forcenormal", argv[i] ) == 0 ) { forceNormal = true; } else if( sd_strncasecmp( "-m", argv[i], 2 ) == 0 ) { strcpy( mbmPath, argv[i]+2 ); AppendBackslash( mbmPath ); } else if( sd_strncasecmp( "-t", argv[i], 2 ) == 0 ) { strcpy( sknPath, argv[i]+2 ); AppendBackslash( sknPath ); } else if( sd_strncasecmp( "-s", argv[i], 2 ) == 0 ) { strcpy( dllPath, argv[i]+2 ); AppendBackslash( dllPath ); } else if( sd_strncasecmp( "-i", argv[i], 2 ) == 0 ) { strcpy( iidFile, argv[i]+2 ); } else { if( fileParam == 0 ) { strcpy( sourceFile, argv[i] ); fileParam++; } else if( fileParam == 1 ) { strcpy( skinName, argv[i] ); fileParam++; } } } if( fileParam != 2 ) return false; return true; }
BOOL CopyDirectory (LPCWSTR lpDestinationPath, LPCWSTR lpSourcePath) { WCHAR szFileName[MAX_PATH]; WCHAR szFullSrcName[MAX_PATH]; WCHAR szFullDstName[MAX_PATH]; WIN32_FIND_DATAW FindFileData; LPWSTR lpSrcPtr; LPWSTR lpDstPtr; HANDLE hFind; DPRINT ("CopyDirectory (%S, %S) called\n", lpDestinationPath, lpSourcePath); wcscpy (szFileName, lpSourcePath); wcscat (szFileName, L"\\*.*"); hFind = FindFirstFileW (szFileName, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { DPRINT1 ("Error: %lu\n", GetLastError()); return FALSE; } wcscpy (szFullSrcName, lpSourcePath); lpSrcPtr = AppendBackslash (szFullSrcName); wcscpy (szFullDstName, lpDestinationPath); lpDstPtr = AppendBackslash (szFullDstName); for (;;) { if (wcscmp (FindFileData.cFileName, L".") && wcscmp (FindFileData.cFileName, L"..")) { wcscpy (lpSrcPtr, FindFileData.cFileName); wcscpy (lpDstPtr, FindFileData.cFileName); if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { DPRINT ("Create directory: %S\n", szFullDstName); if (!CreateDirectoryExW (szFullSrcName, szFullDstName, NULL)) { if (GetLastError () != ERROR_ALREADY_EXISTS) { DPRINT1 ("Error: %lu\n", GetLastError()); FindClose (hFind); return FALSE; } } if (!CopyDirectory (szFullDstName, szFullSrcName)) { DPRINT1 ("Error: %lu\n", GetLastError()); FindClose (hFind); return FALSE; } } else { DPRINT ("Copy file: %S -> %S\n", szFullSrcName, szFullDstName); if (!CopyFileW (szFullSrcName, szFullDstName, FALSE)) { DPRINT1 ("Error: %lu\n", GetLastError()); FindClose (hFind); return FALSE; } } } if (!FindNextFileW (hFind, &FindFileData)) { if (GetLastError () != ERROR_NO_MORE_FILES) { DPRINT1 ("Error: %lu\n", GetLastError()); } break; } } FindClose (hFind); DPRINT ("CopyDirectory() done\n"); return TRUE; }