Exemple #1
0
 public void WriteFile(FdsWriteOptions option, string filenameAppend)
 {
     if (HasHeader || Corrupt)
     {
         Console.WriteLine("File has header or is corrupt/not a valid fds image");
         return;
     }
     if (option == FdsWriteOptions.WriteNewFile)
     {
         FdsUtility.ByteArrayToFile(
             FilePath.Replace(".fds", filenameAppend + ".fds"),
             FdsUtility.Combine(_header, _data));
         Console.WriteLine("File Written");
     }
     if (option == FdsWriteOptions.BackupOriginal)
     {
         File.Copy(FilePath, FilePath.Replace(".fds", filenameAppend + ".fds"));
         Console.WriteLine("Original backed up");
     }
     if (option == FdsWriteOptions.ModifyInPlace)
     {
         File.Delete(FilePath);
         FdsUtility.ByteArrayToFile(FilePath, FdsUtility.Combine(_header, _data));
         Console.WriteLine("File Written");
     }
 }
Exemple #2
0
 public void WriteFile()
 {
     if (!HasHeader && !Corrupt)
     {
         File.Copy(FilePath, FilePath.Replace(".fds", "_noheader.fds"));
         File.Delete(FilePath);
         FdsUtility.ByteArrayToFile(FilePath, FdsUtility.Combine(_header, _data));
         Console.WriteLine("File written.");
         return;
     }
     Console.WriteLine("File has header or is corrupt/not a valid fds image");
 }
Exemple #3
0
        public FdsFile(string filePath)
        {
            var file = new FileInfo(filePath);

            FilePath  = file.FullName;
            FileSize  = file.Length;
            FileName  = file.Name;
            Sides     = FileSize / 65500;
            HasHeader = FileSize % 65500 == 16;
            Corrupt   = !HasHeader && FileSize % 65500 != 0;
            Header    = FdsUtility.GetHeader(Sides);
            if (!HasHeader && !Corrupt)
            {
                ReadFileAndGenerateHeader();
            }
        }
Exemple #4
0
 private void ReadFileAndGenerateHeader()
 {
     _data   = File.ReadAllBytes(FilePath);
     _header = FdsUtility.GenerateHeader(Sides);
 }