Changeset 534


Ignore:
Timestamp:
11/13/2008 9:35:24 AM (6 years ago)
Author:
lowjoel
Message:

Pass the temporary directory into the ExtractTempFiles? function, since the "scope" of the directory is beyond the function and pretty much the process lifetime.

Location:
branches/eraser6/Installer/Bootstrapper
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Installer/Bootstrapper/Bootstrapper.cpp

    r532 r534  
    8080}; 
    8181 
    82 /// Creates a temporary directory with the given name. The directory and files in it 
    83 /// are deleted when this object is destroyed. 
    84 class TempDir 
    85 { 
    86 public: 
    87     /// Constructor. 
    88     /// 
    89     /// \param[in] dirName The path to the directory. This directory will be created. 
    90     TempDir(std::wstring dirName) 
    91         : DirName(dirName) 
    92     { 
    93         if (!CreateDirectoryW(dirName.c_str(), NULL)) 
    94             throw GetErrorMessage(GetLastError()); 
    95     } 
    96  
    97     ~TempDir() 
    98     { 
    99         RemoveDirectoryW(DirName.c_str()); 
    100     } 
    101  
    102 private: 
    103     std::wstring DirName; 
    104 }; 
    105  
    106 void ExtractTempFiles() 
    107 { 
    108     //Get the path to the temporary folder 
    109     wchar_t tempPath[MAX_PATH]; 
    110     DWORD result = GetTempPathW(sizeof(tempPath) / sizeof(tempPath[0]), tempPath); 
    111     if (!result) 
    112         throw GetErrorMessage(GetLastError()); 
    113  
    114     std::wstring tempDir(tempPath, result); 
    115     if (std::wstring(L"\\/").find(tempDir[tempDir.length() - 1]) == std::wstring::npos) 
    116         tempDir += L"\\"; 
    117     tempDir += L"eraserInstallBootstrapper\\"; 
    118     TempDir dir(tempDir); 
     82void ExtractTempFiles(std::wstring pathToExtract) 
     83{ 
     84    if (std::wstring(L"\\/").find(pathToExtract[pathToExtract.length() - 1])) 
     85        pathToExtract += L"\\"; 
    11986 
    12087    //Open the file 
     
    172139        wchar_t fileName[MAX_PATH]; 
    173140        mbstowcs(fileName, f->Name, sizeof(fileName) / sizeof(fileName[0])); 
    174         HANDLE destFile = CreateFileW((tempDir + fileName).c_str(), GENERIC_WRITE, 0, 
     141        HANDLE destFile = CreateFileW((pathToExtract + fileName).c_str(), GENERIC_WRITE, 0, 
    175142            NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 
    176143        if (destFile == INVALID_HANDLE_VALUE) 
  • branches/eraser6/Installer/Bootstrapper/Bootstrapper.h

    r532 r534  
    4141 
    4242/// Extracts the setup files to the users' temporary folder. 
    43 void ExtractTempFiles(); 
     43///  
     44/// \param[in] pathToExtract The path to extract the temporary files to. 
     45void ExtractTempFiles(std::wstring pathToExtract); 
    4446 
    4547/// Checks for the presence of the .NET Framework on the client computer. 
Note: See TracChangeset for help on using the changeset viewer.