/*++ Copyright (c) 2000 Microsoft Corporation Module Name: queue.hpp Abstract: Abstracts setupapi's file queue Author: Vijay Jayaseelan (vijayj) 08 Oct 2000 Revision History: None --*/ #pragma once // // Disable the compiler warning for long names // #pragma warning( disable : 4786 ) #include template class FileQueue { public: FileQueue() { QueueHandle = SetupOpenFileQueue(); if (QueueHandle == INVALID_HANDLE_VALUE) { throw new W32Exception(); } } void AddForCopy(const std::basic_string &SourceRoot, const std::basic_string &SourcePath, const std::basic_string &SourceFileName, const std::basic_string &DestPath, const std::basic_string &DestFileName, DWORD CopyFlags) { BOOL Result = FALSE; /* if (sizeof(T) == sizeof(WCHAR)) { Result = SetupQueueCopyW(QueueHandle, (PCWSTR)SourceRoot.c_str(), (PCWSTR)SourcePath.c_str(), (PCWSTR) // Left editing here ... */ } void AddForCopy(const SectionValues &RecordToCopy, const std::basic_string &DirSectionName, const std::basic_string &SourceRoot, DWORD CopyStyle) { BOOL Result = FALSE; InfFile &File = RecordToCopy.GetContainer().GetContainer(); Section *DirSection = File.GetSection(DirSectionName); if (sizeof(T) == sizeof(WCHAR)) { Result = SetupQueueCopyW(QueueHandle, (PCWSTR)SourceRoot.c_str(), (PCWSTR)RecordToCopy.GetValue(1).c_str(), (PCWSTR)RecordToCopy.GetName().c_str(), NULL, NULL, (PCWSTR)DirSection->GetValue(RecordToCopy.GetValue(7).c_str()).GetValue(0).c_str(), (PCWSTR)RecordToCopy.GetValue(10).c_str(), CopyStyle); } else { Result = SetupQueueCopyA(QueueHandle, (PCSTR)SourceRoot.c_str(), (PCSTR)RecordToCopy.GetValue(1).c_str(), (PCSTR)RecordToCopy.GetName().c_str(), NULL, NULL, (PCSTR)DirSection->GetValue(RecordToCopy.GetValue(7).c_str()).GetValue(0).c_str(), (PCSTR)RecordToCopy.GetValue(10).c_str(), CopyStyle); } if (!Result) { throw new W32Exception(); } } void AddForCopy(const Section &SectionToCopy, const std::basic_string &DirSectionName, const std::basic_string &SourceRoot, DWORD CopyStyle) { CopyWorkerState State(*this, DirSectionName, SourceRoot, CopyStyle); SectionToCopy->DoForEach(SectionCopyWorker, &State); } void Commit() { if (!SetupCommitFileQueue(NULL, QueueHandle, SetupDefaultQueueCallback, NULL)) { throw new W32Exception(); } } virtual ~FileQueue() { if (QueueHandle != INVALID_HANDLE_VALUE) { SetupCloseFileQueue(QueueHandle); } } protected: struct CopyWorkerState { FileQueue &Queue; const std::basic_string &DirSectionName; const std::basic_string &SourceRoot; DWORD CopyState; CopyWorkerState(FileQueue &Que, const std::basic_string &DirSecName, const std::basic_string &SrcRoot, DWORD Copy) : Queue(Que), DirSectionName(DirSecName), SourceRoot(SrcRoot), CopyState(Copy){} }; static void SectionCopyWorker(SectionValues &Value, void *ContextData) { CopyWorkerState *State = (CopyWorkerState *)ContextData; if (Queue) { Queue->AddForCopy(State->Queue, State->DirSectionName, State->SourceRoot); } } // // data members // HSPFILEQ QueueHandle; }; typedef FileQueue FileQueueA; typedef FileQueue FileQueueW;