Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        public static SimpleFile CreateInstance(DirectoryEntry entry)
        {
            SimpleFile file = null;

            switch (entry.FileType)
            {
            case FileTypes.Basic:
                file = new BasicFile();
                break;

            case FileTypes.Data:
                throw new Exception("Unsupported file type: Data");
                break;

            case FileTypes.Text:
                file = new TextFile();
                break;

            case FileTypes.Assembly:
                file = new AssemblyFile();
                break;
            }

            if (null == file)
            {
                return(null);
            }

            file.Disk             = entry.Disk;
            file.Name             = entry.Name;
            file.Granule          = entry.StartGranule;
            file.LastSectorLength = entry.LastSectorLength;

            return(file);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles file selection option from open file dialog window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dlgOpenFile_FileOk(object sender, CancelEventArgs e)
        {
            if (null == (m_dskInfo = SimpleDisk.CreateInstance(dlgOpenFile.FileName)))
            {
                lblInfo.Text = "Image is not a valid CoCo disk!";
                return;
            }

            tabMain.Enabled = true;

            lblInfo.Text = String.Format(@"       Tracks: {0}
 Track Length: {1} bytes
     Granules: {2}
Free Granules: {3}
   Free Space: {4} bytes
   Used Space: {5} bytes
        Files: {6}",
                                         m_dskInfo.Tracks,
                                         m_dskInfo.TrackLength,
                                         m_dskInfo.Granules.Length,
                                         m_dskInfo.FreeGranules,
                                         m_dskInfo.FreeGranules * 2304,
                                         (68 - m_dskInfo.FreeGranules) * 2304,
                                         m_dskInfo.Files.Count);

            lstFiles.Nodes.Clear();
            foreach (DirectoryEntry de in m_dskInfo.Directory)
            {
                TreeNode file = new TreeNode(de.Name);
                file.Nodes.Add(String.Format("Type: {0}", de.FileType));

                SimpleFile sf = de.GetFile();
                switch (de.FileType)
                {
                case FileTypes.Assembly:
                    AssemblyFile af = (AssemblyFile)sf;
                    file.Nodes.Add(String.Format("Length: {0}", af.BlockLength));
                    file.Nodes.Add(String.Format("Load Addr: {0}", af.LoadAddress));
                    file.Nodes.Add(String.Format("Exec Addr: {0}", af.ExecAddress));
                    break;

                default:
                    break;
                }

                //file.Nodes.Add (String.Format ("Length: {0}", de.Length));
                //file.Nodes.Add (String.Format ("Granule: {0}", de.Granule));
                lstFiles.Nodes.Add(file);
            }
        }