예제 #1
0
        public LoadResult Load(string filename, bool autoBackup = false)
        {
            LoadResult result = LoadResult.Success;

            _fileInfo = new FileInfo(filename);
            _entries  = null;

            if (_fileInfo.Exists)
            {
                _gmml = GMML.Load(_fileInfo.FullName);

                string backupFilePath = _fileInfo.FullName + ".bak";
                if (File.Exists(backupFilePath))
                {
                    _gmmlBackup = GMML.Load(backupFilePath);
                }
                else if (autoBackup || MessageBox.Show("Would you like to create a backup of " + _fileInfo.Name + "?\r\nA backup allows the Original text box to display the source text before edits were made.", "Create Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    File.Copy(_fileInfo.FullName, backupFilePath);
                    _gmmlBackup = GMML.Load(backupFilePath);
                }
                else
                {
                    _gmmlBackup = null;
                }
            }
            else
            {
                result = LoadResult.FileNotFound;
            }

            return(result);
        }
예제 #2
0
        public bool Identify(string filename)
        {
            bool result = true;

            try
            {
                GMML.Load(filename);
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }