mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Refactor image classes and split them to smaller files.
This commit is contained in:
66
DiscImageChef.DiscImages/RsIde/Helpers.cs
Normal file
66
DiscImageChef.DiscImages/RsIde/Helpers.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Helpers.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disk image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Contains helpers for RS-IDE disk images.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
public partial class RsIde
|
||||
{
|
||||
static byte[] ScrambleAtaString(string text, int length)
|
||||
{
|
||||
byte[] inbuf = Encoding.ASCII.GetBytes(text);
|
||||
if(inbuf.Length % 2 != 0)
|
||||
{
|
||||
byte[] tmpbuf = new byte[inbuf.Length + 1];
|
||||
Array.Copy(inbuf, 0, tmpbuf, 0, inbuf.Length);
|
||||
tmpbuf[tmpbuf.Length - 1] = 0x20;
|
||||
inbuf = tmpbuf;
|
||||
}
|
||||
|
||||
byte[] outbuf = new byte[inbuf.Length];
|
||||
|
||||
for(int i = 0; i < length; i += 2)
|
||||
{
|
||||
outbuf[i] = inbuf[i + 1];
|
||||
outbuf[i + 1] = inbuf[i];
|
||||
}
|
||||
|
||||
byte[] retBuf = new byte[length];
|
||||
for(int i = 0; i < length; i++) retBuf[i] = 0x20;
|
||||
|
||||
Array.Copy(outbuf, 0, retBuf, 0, outbuf.Length >= length ? length : outbuf.Length);
|
||||
return retBuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user