Пример #1
0
        private static void DrawIFSTree(GenericFolder root, bool isFile = false)
        {
            var open = CollapsingHeader(root.Name);

            if (isFile && BeginPopupContextItem())
            {
                if (MenuItem("Close"))
                {
                    _ifsFiles.Remove(root);

                    if (_openedFile.Path == root.Path)
                    {
                        _openedFile = null;
                    }

                    root.Dispose();
                    GC.Collect();
                }

                EndPopup();
            }

            if (!open)
            {
                return;
            }

            Indent(16);
            PushID(root.Name);

            foreach (var(_, folder) in root.GetFolders())
            {
                DrawIFSTree(folder);
            }

            foreach (var(name, file) in root.GetFiles())
            {
                if (file.CanRead())
                {
                    if (Selectable(name))
                    {
                        _openedFile = file;
                    }
                }
                else
                {
                    Text(name);
                }
            }

            PopID();
            Unindent(16);
        }
Пример #2
0
        public static GenericFolder Open(string path)
        {
            var file   = File.OpenRead(path);
            var header = new ByteBuffer(file.Read(36));

            if (header.GetU32() != Signature)
            {
                Program.LogWarning("File is not an IFS file.");
                return(null);
            }

            var version = header.GetU16();

            if ((header.GetU16() ^ version) != 0xFFFF)
            {
                Program.LogWarning("File version check failed.");
                return(null);
            }

            header.GetU32();             // time
            header.GetU32();             // ifs size
            var manifestEnd = header.GetU32();
            var dataBlob    = new FileBlob(file, manifestEnd);

            if (version > 1)
            {
                header.Offset += 16;
            }

            file.Seek(header.Offset, SeekOrigin.Begin);
            var manifest = new XDocument();

            try {
                manifest = new KBinReader(file.Read((int)(manifestEnd - header.Offset))).Document;
            } catch (Exception ex) {
                Program.LogWarning($"Error during manifest decoding: {ex}");
            }

            var root = new GenericFolder(dataBlob, manifest, null, path, Path.GetFileName(path));

            try {
                root.FromXml();
            } catch (Exception ex) {
                Program.LogWarning("Exception during ifs unpack: {0}", ex);
            }

            return(root);
        }
Пример #3
0
        public static string GetGenericFolderPath(GenericFolder genericFolder)
        {
            if ((int)genericFolder <= 59 && (int)genericFolder >= 0)
            {
                return(GetCustomFolderPath((Environment.SpecialFolder)genericFolder));
            }

            switch (genericFolder)
            {
            //Multiple items of Environment.SpecialFolder have the same
            //IDs which makes it impossible to select Personal using
            //EditorGUI Enum Popup. GenericFolder changes their IDs
            //and instead we have to do this
            case GenericFolder.MyDocuments:
                return(GetCustomFolderPath(Environment.SpecialFolder.MyDocuments));

            case GenericFolder.Personal:
                return(GetCustomFolderPath(Environment.SpecialFolder.Personal));

            //Unity application paths
            case GenericFolder.ConsoleLogPath:
                return(Application.consoleLogPath);

            case GenericFolder.PersistentDataPath:
                return(Application.persistentDataPath);

            case GenericFolder.DataPath:
                return(Application.dataPath);

            case GenericFolder.SteamingAssetsPath:
                return(Application.streamingAssetsPath);

            case GenericFolder.TemporaryCachePath:
                return(Application.temporaryCachePath);

            default:
                return(GetCustomFolderPath((Environment.SpecialFolder)genericFolder));
            }
        }
 public AdvancedGenericFilePath(GenericFolder folder, string path, string editorPath)
 {
     buildPath          = new GenericFilePath(folder, path);
     separateEditorPath = true;
     this.editorPath    = new GenericFilePath(folder, editorPath);
 }
 public AdvancedGenericFilePath(GenericFolder folder, string path)
 {
     buildPath          = new GenericFilePath(folder, path);
     separateEditorPath = false;
     editorPath         = new GenericFilePath(folder, path);
 }
Пример #6
0
 public static string GenerateFullPath(GenericFolder genericFolder, string filePath) =>
 $@"{FileManager.GetGenericFolderPath(genericFolder)}\{filePath}".Replace('/', '\\');
Пример #7
0
 public GenericFilePath(GenericFolder genericFolder, string filePath)
 {
     this.genericFolder = genericFolder;
     this.filePath      = filePath;
 }
Пример #8
0
 public GenericFilePath(string filePath)
 {
     this.filePath = filePath;
     genericFolder = GenericFolder.PersistentDataPath;
 }