public static void AddCbmFileToDict(Dictionary <int, TestFile> dictGeos64Zip, Dictionary <int, TestFile> toDict, int indexOfDiskDict, int indexOfCbmFile, int indexOfTestFile)
        {
            byte[]    bamBlock;
            byte[]    dirEntry     = null;
            ArrayList dirEntryList = new ArrayList();

            byte[] imageData     = dictGeos64Zip[indexOfDiskDict].data;
            int    imageDataType = 0; // sorry hard coded

            bamBlock     = DOSDisk.ReadBAMBlock(imageData, imageDataType);
            dirEntryList = DOSDisk.GetDirEntryList(bamBlock, imageData, imageDataType);
            dirEntry     = (byte[])dirEntryList[indexOfCbmFile - 1];

            string filename = (Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(dirEntry)));

            byte[]   fileData = DOSDisk.getFileData(dirEntry, imageData, imageDataType);
            string   newMD5   = Core.GetMD5Hash(fileData);
            TestFile tf       = new TestFile(filename, fileData, newMD5);

            tf.cleanCvtData    = tf.data;
            tf.CleanCvtDataMd5 = tf.dataMd5;

            toDict.Add(indexOfTestFile, tf);
        }
Esempio n. 2
0
        static void ShowDir(string imagePathFilename)
        {
            byte[]    bamBlock;
            ArrayList dirEntryList = new ArrayList();

            //string imagePathFilename = @"free.d64";
            byte[] imageData     = DiskImageFile.ReadFile(imagePathFilename);
            int    imageDataType = DiskImageFile.GetImageDataType(imagePathFilename);

            bamBlock = DOSDisk.ReadBAMBlock(imageData, imageDataType);
            Console.Write("0 \"{0}\" {1} {2}"
                          , Core.ConvertPETSCII2ASCII(DOSDisk.GetDiskName(bamBlock, imageDataType))
                          , Core.ConvertPETSCII2ASCII(DOSDisk.GetDiskID(bamBlock, imageDataType))
                          , Core.ConvertPETSCII2ASCII(DOSDisk.GetDOSType(bamBlock, imageDataType)));
            Console.Write("    ");
            Console.Write("|{0}", "DirIndex");
            Console.Write("|{0}", "  GEOS  ");
            Console.Write("|{0}", "MD5");
            Console.WriteLine();
            dirEntryList = DOSDisk.GetDirEntryList(bamBlock, imageData, imageDataType);
            int dirIndex = 0;

            foreach (byte[] de in dirEntryList)
            {
                dirIndex++;
                if (!DOSDisk.IsDirEntryEmpty(de))
                {
                    string filename = Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(de));
                    Console.Write("{0,-5}\"{1}\"{2}{3}{4}{5}"
                                  , DOSDisk.GetFileSizeInBlocks(de).ToString()
                                  , filename
                                  , Core.ConvertPETSCII2ASCII(DOSDisk.GetPartAfterFilename(de))
                                  , DOSDisk.GetSplatFileSign(de)
                                  , DOSDisk.GetFileTypeExt(de)
                                  , DOSDisk.GetLockFlagSign(de)
                                  );
                    Console.Write("  ");
                    Console.Write("|{0,8}", dirIndex.ToString());
                    Console.Write("|{0} {1}"
                                  , (GEOSDisk.IsGeosFile(de) ? GEOSDisk.GetGEOSFiletypeName(de) : "   ")
                                  , (GEOSDisk.IsGeosFile(de) ? GEOSDisk.GetGEOSFileStructureName(de) : "    ")
                                  );
                    Console.Write("|{0}"
                                  , DOSDisk.GetMD5ByCBMFile(de, imageData, imageDataType)
                                  );
                    Console.WriteLine();


                    //if (GEOSDisk.IsGeosFile(de))
                    //{
                    //    DiskImageFile.WriteCVTFile(de, imagePathFilename, filename);
                    //}
                    //else
                    //{
                    //    DiskImageFile.WriteFileBlockChain(de[1], de[2], imagePathFilename, filename);
                    //}
                }
            }
            Console.WriteLine("{0} BLOCKS FREE."
                              , DOSDisk.GetFreeBlocks(bamBlock).ToString()
                              );
        }
Esempio n. 3
0
        private void doOpenFile(string fileName)
        {
            listView1.Items.Clear();
            textBoxInfoText.Text = "";
            string[] MP3FileArray =
            {
                "StartMP3_64",
                "StartMP64.1",
                "StartMP64.2",
                "StartMP64.3",
                "StartMP64.4",
                "StartMP64.5",
                "StartMP3_128",
                "StartMP128.1",
                "StartMP128.2",
                "StartMP128.3",
                "StartMP128.4",
                "StartMP128.5"
            };
            listView1.Columns[0].TextAlign = HorizontalAlignment.Right;

            string imagePathFilename = fileName;

            byte[]    bamBlock;
            ArrayList dirEntryList = new ArrayList();

            byte[] imageData = DiskImageFile.ReadFile(imagePathFilename);
            String md5       = Core.GetMD5Hash(imageData);

            textBoxFilename.Text = fileName + " MD5:" + md5;

            int imageDataType = DiskImageFile.GetImageDataType(imagePathFilename);

            bamBlock = DOSDisk.ReadBAMBlock(imageData, imageDataType);
            textBoxDiskLabel.Text = String.Format("0 \"{0}\" {1} {2}"
                                                  , Core.ConvertPETSCII2ASCII(DOSDisk.GetDiskName(bamBlock, imageDataType))
                                                  , Core.ConvertPETSCII2ASCII(DOSDisk.GetDiskID(bamBlock, imageDataType))
                                                  , Core.ConvertPETSCII2ASCII(DOSDisk.GetDOSType(bamBlock, imageDataType)));

            dirEntryList = DOSDisk.GetDirEntryList(bamBlock, imageData, imageDataType);

            textBoxInfoText.Text += "{|class=\"wikitable\"" + Environment.NewLine;
            textBoxInfoText.Text += "|" + Environment.NewLine;
            textBoxInfoText.Text += "{|" + Environment.NewLine;
            textBoxInfoText.Text += "| '''Imagedatei'''" + Environment.NewLine;
            textBoxInfoText.Text += "| ''':'''" + Environment.NewLine;
            textBoxInfoText.Text += "|" + Path.GetFileName(imagePathFilename) + Environment.NewLine;
            textBoxInfoText.Text += "|-" + Environment.NewLine;
            textBoxInfoText.Text += "|'''Imagedatei MD5'''" + Environment.NewLine;
            textBoxInfoText.Text += "|''':'''" + Environment.NewLine;
            textBoxInfoText.Text += "|" + md5 + Environment.NewLine;
            textBoxInfoText.Text += "|-" + Environment.NewLine;
            textBoxInfoText.Text += "|'''Quelle'''" + Environment.NewLine;
            textBoxInfoText.Text += "|''':'''" + Environment.NewLine;
            textBoxInfoText.Text += "|" + Environment.NewLine;
            textBoxInfoText.Text += "|}" + Environment.NewLine;
            textBoxInfoText.Text += "{| class=\"wikitable sortable\"" + Environment.NewLine;
            textBoxInfoText.Text += "!Nr." + Environment.NewLine;
            textBoxInfoText.Text += "!Datei" + Environment.NewLine;
            textBoxInfoText.Text += "!style=\"text-align:right\"|Größe" + Environment.NewLine;
            textBoxInfoText.Text += "!MD5" + Environment.NewLine;
            textBoxInfoText.Text += "!Info" + Environment.NewLine;

            int dirIndex = 0;

            foreach (byte[] de in dirEntryList)
            {
                dirIndex++;
                if (!DOSDisk.IsDirEntryEmpty(de))
                {
                    String[] colText =
                    {
                        Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(de)) + Core.ConvertPETSCII2ASCII(DOSDisk.GetPartAfterFilename(de)),
                        DOSDisk.GetFileSizeInBlocks(de).ToString(),
                        DOSDisk.GetSplatFileSign(de),
                        DOSDisk.GetFileTypeExt(de),
                        DOSDisk.GetLockFlagSign(de),
                        dirIndex.ToString(),
                        (GEOSDisk.IsGeosFile(de) ? GEOSDisk.GetGEOSFiletypeName(de) : "   "),
                        (GEOSDisk.IsGeosFile(de) ? GEOSDisk.GetGEOSFileStructureName(de) : "    "),
                        DOSDisk.GetMD5ByCBMFile(de,                                                                                      imageData,  imageDataType),
                        DOSDisk.GetInfoTextByMP3File(de,                                                                                 imageData,  imageDataType),
                    };
                    ListViewItem listViewItem = new ListViewItem(colText[0]); // first col
                    listViewItem.SubItems.Add(colText[1]);
                    listViewItem.SubItems.Add(colText[2]);
                    listViewItem.SubItems.Add(colText[3]);
                    listViewItem.SubItems.Add(colText[4]);
                    listViewItem.SubItems.Add(colText[5]);
                    listViewItem.SubItems.Add(colText[6]);
                    listViewItem.SubItems.Add(colText[7]);
                    listViewItem.SubItems.Add(colText[8]);
                    listViewItem.SubItems.Add(colText[9]);
                    listView1.Items.Add(listViewItem);
                    //textBoxInfoText.Text += String.Format("{0,-16} {1,5}  {2,-32} {3}{4}", colText[0],colText[1],colText[8], colText[9],Environment.NewLine);
                    Boolean IsBold = MP3FileArray.Contains(colText[0].TrimEnd());
                    textBoxInfoText.Text += "|-" + Environment.NewLine;
                    textBoxInfoText.Text += "|" + dirIndex + Environment.NewLine;
                    if (IsBold)
                    {
                        textBoxInfoText.Text += "|'''" + colText[0].TrimEnd() + "'''" + Environment.NewLine;
                    }
                    else
                    {
                        textBoxInfoText.Text += "|" + colText[0].TrimEnd() + Environment.NewLine;
                    }
                    textBoxInfoText.Text += "|style = \"text-align:right\" |" + colText[1] + Environment.NewLine;
                    textBoxInfoText.Text += "|" + colText[8] + Environment.NewLine;
                    textBoxInfoText.Text += "|" + colText[9] + Environment.NewLine;
                }
            }
            textBoxInfoText.Text += "|}" + Environment.NewLine;
            textBoxInfoText.Text += "|}" + Environment.NewLine;

            /*
             * {|class="wikitable"
             |
             | {|
             |'''Imagedatei'''
             |''':'''
             | MP3_64D.D81
             |-
             |'''Imagedatei MD5'''
             |''':'''
             | 93C4E05B0C50BBD6A4B6A9976FA6B35D
             |-
             |'''Quelle'''
             |''':'''
             |
             |}
             | {| class="wikitable sortable"
             | !Datei
             | !style="text-align:right"|Größe
             | !MD5
             | !Info
             |-
             |StartMP3_64
             |style="text-align:right"|56
             |9296FD29D63ED70733F943ACF7B4FD88
             |BUILD:FULL-090100.2020 Deutsch C64
             |}
             |}
             */
        }
        static void ExtraxctFile(string imagePathFilename, int dirIndex, string asciiCbmFilename, string outPathFilename)
        {
            byte[]    bamBlock;
            byte[]    dirEntry     = null;
            ArrayList dirEntryList = new ArrayList();

            byte[] imageData     = DiskImageFile.ReadFile(imagePathFilename);
            int    imageDataType = DiskImageFile.GetImageDataType(imagePathFilename);

            bamBlock     = DOSDisk.ReadBAMBlock(imageData, imageDataType);
            dirEntryList = DOSDisk.GetDirEntryList(bamBlock, imageData, imageDataType);
            // by DirIndex
            if (dirIndex > 0)
            {
                dirEntry = (byte[])dirEntryList[dirIndex - 1];
            }
            else
            {
                if (asciiCbmFilename.Length > 0)
                {
                    bool found = false;
                    foreach (byte[] de in dirEntryList)
                    {
                        if (Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(de)) == asciiCbmFilename)
                        {
                            if (!found)
                            {
                                dirEntry = de;
                                found    = true;
                            }
                            else
                            {
                                throw new Exception("Filename is not unique!");
                            }
                        }
                    }
                    if (!found)
                    {
                        throw new Exception(String.Format("Filename {0} not found!", asciiCbmFilename));
                    }
                }
                else
                {
                    throw new Exception("No file specified");
                }
            }
            string filename = (Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(dirEntry)));

            if (DOSDisk.GetFileType(dirEntry) == 0)
            {
                throw new Exception(String.Format("File {0} is deleted!", filename));
            }
            byte[] fileData = DOSDisk.getFileData(dirEntry, imageData, imageDataType);
            if (outPathFilename != "")
            {
                DiskImageFile.WriteFile(fileData, outPathFilename);
            }
            else
            {
                DiskImageFile.WriteFile(fileData, filename);
            }
        }