예제 #1
0
        void LoadSelfUpdateData(string fileName)
        {
            byte[] fileIDBytes = new byte[7];

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                // Read back the file identification data, if any
                fs.Read(fileIDBytes, 0, 7);
                string fileID = System.Text.Encoding.UTF8.GetString(fileIDBytes);
                if (fileID != "IUSUFV2")
                {
                    //handle self update from RC1 client
                    if (fileID == "IUSUFV1")
                    {
                        LoadSelfUpdateRC1Data(fs);
                        return;
                    }

                    //free up the file so it can be deleted
                    fs.Close();
                    throw new Exception("Self update fileID is wrong: " + fileID);
                }

                byte bType = (byte)fs.ReadByte();
                while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:    //Read Client data file location
                        clientFileLoc = ReadFiles.ReadDeprecatedString(fs);

                        //TODO: wyUp 3.0: Remove this hackish behavior to cope with pre-RC2 client data files
                        if (clientFileLoc.EndsWith("iuc", StringComparison.OrdinalIgnoreCase))
                        {
                            clientFileType = ClientFileType.PreRC2;
                        }
                        else if (clientFileLoc.EndsWith("iucz", StringComparison.OrdinalIgnoreCase))
                        {
                            clientFileType = ClientFileType.RC2;
                        }
                        else
                        {
                            clientFileType = ClientFileType.Final;
                        }

                        break;

                    case 0x02:     //Read Server data file location
                        serverFileLoc = ReadFiles.ReadDeprecatedString(fs);
                        break;

                    case 0x03:     //Client server file location
                        clientSFLoc = ReadFiles.ReadDeprecatedString(fs);
                        break;

                    case 0x04:    //Read Base Directory
                        baseDirectory = ReadFiles.ReadDeprecatedString(fs);
                        break;

                    case 0x05:    //Read Temporary directory
                        tempDirectory = ReadFiles.ReadDeprecatedString(fs);
                        break;

                    case 0x06:    //Read Old client file location
                        oldSelfLocation = ReadFiles.ReadDeprecatedString(fs);
                        break;

                    case 0x07:     //true=Self Update, false=Continue update

                        SelfUpdateState = ReadFiles.ReadBool(fs)
                                                  ? SelfUpdateState.FullUpdate
                                                  : SelfUpdateState.ContinuingRegularUpdate;

                        break;

                    case 0x08:     //is elevation required
                        needElevation = ReadFiles.ReadBool(fs);
                        break;

                    case 0x09:
                        serverOverwrite = ReadFiles.ReadDeprecatedString(fs);
                        break;

                    case 0x0C:
                        updatePathVar = ReadFiles.ReadString(fs);
                        break;

                    case 0x0D:
                        customUrlArgs = ReadFiles.ReadString(fs);
                        break;

                    case 0x0E:
                        forcedLanguageCulture = ReadFiles.ReadString(fs);
                        break;

                    case 0x80:     // is autoupdate mode
                        beginAutoUpdateInstallation = true;

                        // the actual pipe will be created when OnHandleCreated is called
                        isAutoUpdateMode = true;
                        break;

                    case 0x82:
                        UpdatingFromService = true;
                        break;

                    case 0x0F:
                        customProxyUrl = ReadFiles.ReadString(fs);
                        break;

                    case 0x10:
                        customProxyUser = ReadFiles.ReadString(fs);
                        break;

                    case 0x11:
                        customProxyPassword = ReadFiles.ReadString(fs);
                        break;

                    case 0x12:
                        customProxyDomain = ReadFiles.ReadString(fs);
                        break;

                    case 0x13:
                        StartOnErr = ReadFiles.ReadString(fs);
                        break;

                    case 0x14:
                        StartOnErrArgs = ReadFiles.ReadString(fs);
                        break;

                    case 0x15:
                        PasswordUpdateCmd = ReadFiles.ReadString(fs);
                        break;

                    default:
                        ReadFiles.SkipField(fs, bType);
                        break;
                    }

                    bType = (byte)fs.ReadByte();
                }
            }
        }