/*++ Copyright (c) 1996 Microsoft Corporation Module Name: fileq.c Abstract: This file implements the file copy code. Environment: WIN32 User Mode Author: Wesley Witt (wesw) 17-Feb-1996 --*/ #include "wizard.h" #pragma hdrstop BOOL RebootRequired; DWORD SetupQueueXXXSection( HSPFILEQ QueueHandle, LPTSTR SourceRootPath, HINF InfHandle, HINF ListInfHandle, LPTSTR Section, DWORD CopyStyle, DWORD Action ) { if (Action == SETUP_ACTION_NONE) { return 0; } if (Action == SETUP_ACTION_COPY) { return SetupQueueCopySection( QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle ); } if (Action == SETUP_ACTION_DELETE) { return SetupQueueDeleteSection( QueueHandle, InfHandle, ListInfHandle, Section ); } return 0; } BOOL SetDestinationDir( HINF SetupInf, PFILE_QUEUE_INFO FileQueueInfo, PPLATFORM_INFO PlatformInfo ) { TCHAR Buffer[MAX_PATH*2]; TCHAR DestDir[MAX_PATH*2]; BOOL Rval; if (FileQueueInfo->InfDirId < DIRID_USER) { return TRUE; } DestDir[0] = 0; switch (FileQueueInfo->DestDirId) { case DIRID_SPOOLDRIVERS: _tcscat( DestDir, PlatformInfo->DriverDir ); if (FileQueueInfo->DestDir) { RemoveLastNode( DestDir ); } break; case DIRID_SYSTEM: ExpandEnvironmentStrings( TEXT("%systemroot%\\"), Buffer, sizeof(Buffer) ); _tcscat( DestDir, Buffer ); break; case DIRID_WINDOWS: ExpandEnvironmentStrings( TEXT("%windir%\\"), Buffer, sizeof(Buffer) ); _tcscat( DestDir, Buffer ); break; } if (FileQueueInfo->DestDir) { ExpandEnvironmentStrings( FileQueueInfo->DestDir, Buffer, sizeof(Buffer) ); _tcscat( DestDir, Buffer ); } if (FileQueueInfo->PlatformsFlag == PLATFORM_USE_MACHINE) { _tcscat( DestDir, TEXT("\\") ); _tcscat( DestDir, PlatformInfo->OsPlatform ); } DebugPrint(( TEXT("Setting destination dir: [%d] [%s]"), FileQueueInfo->InfDirId, DestDir )); MakeDirectory( DestDir ); Rval = SetupSetDirectoryId( SetupInf, FileQueueInfo->InfDirId, DestDir ); if (!Rval) { DebugPrint(( TEXT("SetupSetDirectoryId() failed, ec=%d"), GetLastError() )); return FALSE; } return TRUE; } BOOL ProcessFileQueueEntry( HINF SetupInf, HSPFILEQ FileQueue, LPTSTR SourceRoot, PFILE_QUEUE_INFO FileQueueInfo, PPLATFORM_INFO PlatformInfo, DWORD ActionId, BOOL OsPlatformDir ) { TCHAR SourceDir[MAX_PATH*2]; BOOL Rval; // // set the source directory // // work around Setupapi!SetupSetPlatformPathOverride bug if (PlatformInfo->ThisPlatform) { _tcscpy( SourceDir, SourceRoot ); } else { if (! PlatformOverride( ThisPlatformName, PlatformInfo->OsPlatform, SourceRoot, SourceDir ) ) { DebugPrint(( TEXT("PlatformOverride() failed") )); return FALSE; } } #if 0 _tcscpy( SourceDir, SourceRoot ); if (!PlatformInfo->ThisPlatform) { SetupSetPlatformPathOverride( PlatformInfo->OsPlatform ); } #endif // // set the destination directory // SetDestinationDir( SetupInf, FileQueueInfo, PlatformInfo ); // // queue the operation // Rval = SetupQueueXXXSection( FileQueue, SourceDir, SetupInf, SetupInf, FileQueueInfo->SectionName, FileQueueInfo->CopyFlags, ActionId ); if (!Rval) { return FALSE; } return TRUE; } UINT FileQueueCallbackRoutine( IN LPDWORD FileCounter, IN UINT Notification, IN UINT Param1, IN UINT Param2 ) { *FileCounter += 1; return NO_ERROR; } BOOL ProcessFileQueue( HINF SetupInf, HSPFILEQ *FileQueue, PVOID QueueContext, LPTSTR SourceRoot, PFILE_QUEUE_INFO FileQueueInfo, DWORD CountFileQueueInfo, PSP_FILE_CALLBACK MyQueueCallback, DWORD ActionId ) { DWORD i; DWORD j; LPTSTR p; TCHAR Drive[_MAX_DRIVE]; TCHAR Dir[_MAX_DIR]; BOOL OsPlatformDir = FALSE; BOOL Rval; PFILE_QUEUE_CONTEXT FileQueueContext = (PFILE_QUEUE_CONTEXT) QueueContext; INT SetupReboot; DWORD FileCounter; // // check to see if the directory is a platform directory // if this is false then this is most likely an internal setup // _tsplitpath( SourceRoot, Drive, Dir, NULL, NULL ); if (Dir[0] && Dir[1]) { p = Dir + _tcslen(Dir) - 1; *p = 0; p -= 1; while (*p != TEXT('\\')) { p -= 1; } p += 1; for (i=0; ihwnd, WM_MY_PROGRESS, 0xfe, (LPARAM) FileCounter ); } // // copy the files // for (i=0; ihwnd, FileQueue[i], MyQueueCallback, (PVOID) FileQueueContext ); if (!Rval) { DebugPrint(( TEXT("SetupCommitFileQueue() failed, ec=%d"), GetLastError() )); return FALSE; } } } // // set to see if we need to reboot // if (!RebootRequired) { for (i=0; iQueueContext ); for (i=0; i 3) || (EnumPlatforms[SystemInfo.wProcessorArchitecture] == WRONG_PLATFORM ) ) { return FALSE; } Platforms[ EnumPlatforms[SystemInfo.wProcessorArchitecture] ].ThisPlatform = TRUE; if (SourceRoot[0] == 0) { // // get the directory that the setup program is running from // GetModuleFileName( FaxWizModuleHandle, Buffer, sizeof(Buffer) ); _tsplitpath( Buffer, Drive, Dir, NULL, NULL ); _stprintf( SourceRoot, TEXT("%s%s"), Drive, Dir ); } // // open the setup inf file // _stprintf( Buffer, TEXT("%sfaxsetup.inf"), SourceRoot ); *SetupInf = SetupOpenInfFile( Buffer, NULL, INF_STYLE_WIN4, NULL ); if (*SetupInf == INVALID_HANDLE_VALUE) { DebugPrint(( TEXT("SetupOpenInfFile() failed, ec=%d"), GetLastError() )); return FALSE; } // // open the file queues // *FileQueue = (HSPFILEQ*) MemAlloc( sizeof(HSPFILEQ) * CountPlatforms ); if (!*FileQueue) { DebugPrint(( TEXT("Could not allocate memory for file queues") )); return FALSE; } for (i=0; ihwnd = hwnd; FileQueueContext->QueueContext = SetupInitDefaultQueueCallbackEx( hwnd, hwnd, WM_MY_PROGRESS, 0, NULL ); if (!FileQueueContext->QueueContext) { DebugPrint(( TEXT("SetupInitDefaultQueueCallbackEx() failed, ec=%d"), GetLastError() )); return FALSE; } *QueueContext = FileQueueContext; return TRUE; }