Esempio n. 1
0
        /// <summary>
        /// Open the .psarc archive which is the given file.
        /// </summary>
        /// <param name="path"></param>
        public PSARCPackage(IFile f)
        {
            using (filestream = f.GetStream())
            {
                string magic = filestream.ReadASCIINullTerminated(4);
                if (magic != "PSAR")
                {
                    throw new NotSupportedException("PSARC file doesn't start with magic.");
                }

                if (filestream.ReadInt16BE() != 1 || filestream.ReadInt16BE() != 4)
                {
                    throw new NotSupportedException("Currently only v1.4 PSARC files are supported.");
                }
            }

            FileName = f.Name;
            root     = new PSARCDirectory(null, ROOT_DIR);
            LoadPackage(f.GetStream());
        }
Esempio n. 2
0
        /// <summary>
        /// Get the directory at the end of this path, or make it (and all
        /// intermediate dirs) if it doesn't exist.
        /// </summary>
        /// <param name="path">Path from PSARC path file, including filename.
        /// </param>
        /// <returns></returns>
        private PSARCDirectory makeOrGetDir(string path)
        {
            string[]   breadcrumbs = path.Split('/');
            IDirectory last        = root;
            IDirectory current;

            if (breadcrumbs.Length == 1)
            {
                return(root);
            }

            for (var idx = 0; idx < breadcrumbs.Length - 1; idx++)
            {
                if (!last.TryGetDirectory(breadcrumbs[idx], out current))
                {
                    current = new PSARCDirectory(last, breadcrumbs[idx]);
                    (last as PSARCDirectory).AddDir(current as PSARCDirectory);
                }
                last = current;
            }
            return(last as PSARCDirectory);
        }