/// <summary>
 ///     Paks a file into the main update pak file.
 /// </summary>
 /// <param name="file">File to pak.</param>
 private void PakFile(string file)
 {
     //System.Console.WriteLine("Packed: " + file);
     PakResource resource = new PakResource(_pakFile, file, 0, 0);
     resource.DataStream = new FileStream(file, FileMode.Open, FileAccess.Read);
     _pakFile.AddResource(resource);
 }
Esempio n. 2
0
 /// <summary>
 ///		Adds the given resource to this pak file.
 /// </summary>
 /// <param name="resource">Resource to add.</param>
 public void AddResource(PakResource resource)
 {
     _resourceList.Add(resource);
 }
Esempio n. 3
0
 /// <summary>
 ///		Removes the given resource from this pak file.
 /// </summary>
 /// <param name="resource">Resource to remove.</param>
 public void RemoveResource(PakResource resource)
 {
     _resourceList.Remove(resource);
 }
Esempio n. 4
0
 /// <summary>
 ///		Removes the given resource from this pak file.
 /// </summary>
 /// <param name="resource">Resource to remove.</param>
 public void RemoveResource(PakResource resource)
 {
     _resourceList.Remove(resource);
 }
Esempio n. 5
0
 /// <summary>
 ///		Adds the given resource to this pak file.
 /// </summary>
 /// <param name="resource">Resource to add.</param>
 public void AddResource(PakResource resource)
 {
     _resourceList.Add(resource);
 }
        /// <summary>
        ///		Adds the file at a given url to the currently compiling pak file.
        /// </summary>
        /// <param name="path">Url of file to add to pak file.</param>
        /// <param name="locator">Path that should be used by the pak file to locate the paked file in future.</param>
        private void PakFile(string path, string locator)
        {
            // Create a pak resource to represent this file and add it to the pak file.
            PakResource resource = new PakResource(_pakFile, locator, 0, 0);
            _pakFile.AddResource(resource);

            // Load the files data into a memory stream and attach it to the resource.
            Stream stream = StreamFactory.RequestStream(path, StreamMode.Open);

            // If the size of the data is over the maximum pak size then
            // create a new one.
            if (_pakFileMaximumSize != 0 && _pakFileSize + stream.Length > ((_pakFileMaximumSize * 1024) * 1024) && _pakFile.Resources.Count > 1)
            {
                _pakFile.RemoveResource(resource);

                // Find a new pak file we can create without overwriting anything, and save to it.
                string filePath = _buildDirectory + "\\" + _pakFilePrefix.Replace("#", _pakFileIndex.ToString()) + ".pk";
                int fileIndex = 0;
                while (File.Exists(filePath) == true)
                    filePath = _buildDirectory + "\\" + _pakFilePrefix.Replace("#", _pakFileIndex.ToString()) + (fileIndex++) + ".pk";
                _pakFile.Save(filePath);
                _pakFileIndex++;
                _pakFileSize = 0;

                // Create a new pak file to put the rest of the resources into.
                _pakFile = new PakFile();
                _pakFile.AddResource(resource);
            }

            resource.DataStream = stream;
            _pakFileSize += (int)stream.Length;
        }