Exemple #1
0
        /// <summary>
        /// Fetch a file.
        /// </summary>
        /// <typeparam name="T">The type of file to fetch.</typeparam>
        /// <param name="filePath">The path to the file to fetch.</param>
        /// <returns>The file.</returns>
        public override IOFile FetchFile <T>(string filePath)
        {
            IOFile f = (IOFile)Activator.CreateInstance(typeof(T));

            f.Read(Files[filePath]);
            return(f);
        }
Exemple #2
0
        /// <summary>
        /// Fetch the file contained in the pack.
        /// </summary>
        /// <typeparam name="T">Type of IOFile.</typeparam>
        /// <returns>The file contained in the pack.</returns>
        public IOFile FetchFile <T>()
        {
            IOFile f = (IOFile)Activator.CreateInstance(typeof(T));

            FileReader.Position = 0;
            f.Read(FileReader);
            return(f);
        }
Exemple #3
0
 /// <summary>
 /// Fetch an IO file.
 /// </summary>
 /// <typeparam name="T">The type of file.</typeparam>
 /// <param name="filePath">Path to the file.</param>
 /// <returns>The file fetched.</returns>
 public virtual IOFile FetchFile <T>(string filePath)
 {
     FileReader.Position = FileListing[filePath].Offset;
     if (FileListing[filePath].IsPacked)
     {
         using (Pack p = new Pack()) {
             p.Read(FileReader.ReadBytes(FileListing[filePath].Size));
             return(p.FetchFile <T>());
         }
     }
     else
     {
         IOFile f = (IOFile)Activator.CreateInstance(typeof(T));
         f.Read(FileReader.ReadBytes(FileListing[filePath].Size));
         return(f);
     }
 }
Exemple #4
0
 /// <summary>
 /// Open a file from a file path.
 /// </summary>
 /// <typeparam name="T">The type of IOFile.</typeparam>
 /// <param name="filePath">Path of the file.</param>
 /// <returns>The file openend.</returns>
 public static IOFile OpenFile <T>(string filePath)
 {
     if (FileListing.Contains(filePath))
     {
         return(FileMap[filePath].FetchFile <T>(filePath));
     }
     else if (GameHelper.GameAssemby.GetManifestResourceNames().Contains(GetEmbeddedResourceName(filePath)))
     {
         IOFile f = (IOFile)Activator.CreateInstance(typeof(T));
         f.Read(GameHelper.GameAssemby.GetManifestResourceStream(GetEmbeddedResourceName(filePath)));
         return(f);
     }
     else
     {
         IOFile f = (IOFile)Activator.CreateInstance(typeof(T));
         f.Read(filePath);
         return(f);
     }
 }