public void Check() { try { ParseFile parse = new ParseFile(); var Mangas = parse.GetManga("webtoons"); var open = parse.GetValueSettings("open links"); foreach (var manga in Mangas) { var splitterino = manga.Split(new[] { "[]" }, StringSplitOptions.None); var Name = splitterino[0]; var Chapter = int.Parse(splitterino[1]); Chapter++; var Url = splitterino[2]; var rssitems = new RSSReader().Read(Url); foreach (var rssitem in rssitems.Items) { if (rssitem.Title.Text.Contains(Chapter.ToString())) { if (open.Equals("1")) { Process.Start(rssitem.Links[0].Uri.AbsoluteUri); parse.SetManga("webtoons", Name, Chapter.ToString()); debug.Write($"[{DateTime.Now}][Kissmanga] Found new Chapter {Name} {rssitem.Title.Text}."); } } } } } catch (Exception ex) { debug.Write($"[{DateTime.Now}][Webtoons] Error {ex.Message}."); } }
public void Move(string site, string name, string chapter) { using (ParseFile parse = new ParseFile()) { parse.RemoveManga("backlog", name); parse.AddManga(site, name, chapter, ""); } }
public void Setup() { ParseFile parse = new ParseFile(); Settings.Default.SettingBatoto = parse.GetValueSettings("batoto"); Settings.Default.SettingMangastream = parse.GetValueSettings("mangastream"); Settings.Default.SettingMangareader = parse.GetValueSettings("mangareader"); Settings.Default.SettingMangafox = parse.GetValueSettings("mangafox"); Settings.Default.SettingKissmanga = parse.GetValueSettings("kissmanga"); Settings.Default.SettingWebtoons = parse.GetValueSettings("webtoons"); Settings.Default.SettingOpenLinks = parse.GetValueSettings("open links"); Settings.Default.SettingBatotoRSS = parse.GetValueSettings("batoto_rss"); Settings.Default.SettingRefreshTime = int.Parse(parse.GetValueSettings("refresh time")); //Settings.Default.Save(); }
public async Task<ParseFile> UploadFileAsync(ParseFile file) { try { await file.SaveAsync(); return file; } catch (Exception ex) { var msg = ex.Message; return null; } }
private void initializeUtfHeader(FileStream UtfTableFs) { this.TableSize = ParseFile.ReadUintBE(UtfTableFs, 4); this.Unknown1 = ParseFile.ReadUshortBE(UtfTableFs, 8); this.RowOffset = (uint)ParseFile.ReadUshortBE(UtfTableFs, 0xA) + 8; this.StringTableOffset = ParseFile.ReadUintBE(UtfTableFs, 0xC) + 8; this.DataOffset = ParseFile.ReadUintBE(UtfTableFs, 0x10) + 8; this.TableNameOffset = ParseFile.ReadUintBE(UtfTableFs, 0x14); this.TableName = ParseFile.ReadAsciiString(UtfTableFs, this.StringTableOffset + this.TableNameOffset); this.NumberOfFields = ParseFile.ReadUshortBE(UtfTableFs, 0x18); this.RowSize = ParseFile.ReadUshortBE(UtfTableFs, 0x1A); this.NumberOfRows = ParseFile.ReadUintBE(UtfTableFs, 0x1C); }
public async void updateFundacion(Fundacion fundacion) { ParseObject e = await FundacionById(fundacion.ObjectId); var stream = await fundacion.ArchivoImg.OpenAsync(FileAccessMode.Read); ParseFile fileP = new ParseFile(fundacion.ArchivoImg.Name, stream.AsStream()); await fileP.SaveAsync(); e["foto"] = fileP; e["nombre"] = fundacion.Nombre; e["direccion"] = fundacion.Direccion; e["descripcion"] = fundacion.Descripcion; e["cuenta_bancaria"] = fundacion.Cuenta_bancaria; e["correo"] = fundacion.Correo; e["telefono"] = fundacion.Telefono; await e.SaveAsync(); }
public byte[] GetSectorByLba(long lba) { long sectorOffset; byte[] sectorBytes = null; for (int i = (this.TrackCount - 1); i >= 0; i--) { if (lba >= this.TrackEntries[i].StartSector) { sectorOffset = ((lba - this.TrackEntries[i].StartSector) * this.TrackEntries[i].SectorSize) + this.TrackEntries[i].Offset; sectorBytes = ParseFile.ParseSimpleOffset(this.TrackEntries[i].TrackStream, sectorOffset, (int)this.TrackEntries[i].SectorSize); break; } } return(sectorBytes); }
public static MidiChunkStruct parseMidiChunk(Stream pStream) { MidiChunkStruct ret = new MidiChunkStruct(); ret.magicBytes = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(pStream, MIDI_CHUNK_OFFSET + 0, 4), 0); ret.magicBytesSection = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(pStream, MIDI_CHUNK_OFFSET + 4, 4), 0); ret.chunkSize = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(pStream, MIDI_CHUNK_OFFSET + 8, 4), 0); ret.maxSeqCount = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(pStream, MIDI_CHUNK_OFFSET + 12, 4), 0); ret.subSeqOffsetAddr = new int[ret.maxSeqCount + 1]; for (int i = 0; i < ret.subSeqOffsetAddr.Length; i++) { ret.subSeqOffsetAddr[i] = BitConverter.ToInt32(ParseFile.ParseSimpleOffset(pStream, MIDI_CHUNK_OFFSET + 16 + (4 * i), 4), 0); } return(ret); }
public static bool IsGzipFile(string pFilePath) { bool ret = false; byte[] signatureBytes = null; using (FileStream fs = File.OpenRead(pFilePath)) { signatureBytes = ParseFile.ParseSimpleOffset(fs, HEADER_OFFSET, GZIP_SIGNATURE.Length); } if ((signatureBytes != null) && (ParseFile.CompareSegment(signatureBytes, HEADER_OFFSET, GZIP_SIGNATURE))) { ret = true; } return(ret); }
private async void AvatarFromCamera(IUICommand command) { var ui = new CameraCaptureUI(); ui.PhotoSettings.CroppedAspectRatio = new Size(4, 3); var file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo); if (file != null) { IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var parseObject = new ParseFile(Guid.NewGuid() + ".jpg", fileStream.AsStreamForRead()); await parseObject.SaveAsync(); AssigneAvatarToModel(parseObject.Url.AbsoluteUri); } }
/// <summary> /// Checks for WAD file Magic Bytes. /// </summary> /// <param name="sourceFile">Full path to file to check.</param> /// <returns>Boolean value indicating if input file has WAD magic bytes.</returns> public static bool IsWadFile(string sourceFile) { bool isWad = false; byte[] magicBytes = new byte[NintendoWad.STANDARD_IDENTIFIER.Length]; using (FileStream fs = File.OpenRead(sourceFile)) { magicBytes = ParseFile.ParseSimpleOffset(fs, NintendoWad.IDENTIFIER_OFFSET, NintendoWad.STANDARD_IDENTIFIER.Length); if (ParseFile.CompareSegment(magicBytes, 0, NintendoWad.STANDARD_IDENTIFIER)) { isWad = true; } } return(isWad); }
/// <summary> /// Extract optional footer. /// </summary> /// <returns>File name of extracted file or String.Empty if footer is not present.</returns> public string ExtractFooter() { string destinationFile = String.Empty; if (this.FooterSize > 0) { destinationFile = Path.Combine( this.GetUnpackFolder(false), (this.TitleId.ToString("X8") + ".trailer")); using (FileStream fs = File.OpenRead(this.SourceFileName)) { ParseFile.ExtractChunkToFile(fs, this.FooterOffset, this.FooterSize, destinationFile); } } return(destinationFile); }
public override void Initialize(Stream pStream, string pFilePath) { base.Initialize(pStream, pFilePath); this.deviceCount = this.getDeviceCount(pStream); this.getS98Devices(pStream); Int32 tagOffset = BitConverter.ToInt32(this.songNameOffset, 0) + TAG_IDENTIFIER_LENGTH; this.v3Tags = ParseFile.ParseSimpleOffset(pStream, tagOffset, (int)pStream.Length - tagOffset); tagOffset -= TAG_IDENTIFIER_LENGTH; // check this this.data = ParseFile.ParseSimpleOffset(pStream, V3_DEVICE_INFO_OFFSET, tagOffset - V3_DEVICE_INFO_OFFSET); this.parseTagData(); this.addDevicesToHash(); }
private void InitializeAndValidateFat(FileStream isoStream) { this.FileAllocationTable = new uint[this.ClusterCount + 2]; // first 2 entries of FAT contain info for (ulong i = 0; i < (this.ClusterCount + 2); i++) { this.FileAllocationTable[i] = ParseFile.ReadUintLE(isoStream, (long)(this.FatAbsoluteOffset + (i * 4))); if (i == 1) // first two cells are populated { if (!((this.FileAllocationTable[0] == MicrosoftExFatFileSystem.FAT_MEDIA_TYPE) && (this.FileAllocationTable[1] == MicrosoftExFatFileSystem.FAT_CELL1_PLACEHOLDER))) { MessageBox.Show("WARNING: File Allocation Table (FAT) cell check failed."); } } } // for (ulong i = 0; i < (this.ClusterCount + 2); i++ ) }
private void parseFadesChunk() { foreach (ChunkStruct c in chunks) { if (ParseFile.CompareSegment(c.chunkIdentifier, 0, FADE_SIGNATURE)) { this.fades = new Int32[c.chunkData.Length / 4]; int j = 0; for (int i = 0; i < c.chunkData.Length; i += 4) { byte[] tempTime = ParseFile.ParseSimpleOffset(c.chunkData, i, 4); this.fades[j] = BitConverter.ToInt32(tempTime, 0); j++; } } } }
public static void Compile(ParsedCommandOptions opts) { Console.WriteLine("Reading parse file.."); var output = GetSelectedOutput(opts); var input = new MultiFileInputStream(new List <string>(new string[] { @"C:\Users\yveem\source\repos\Redmond\TestInput.txt" })); //var input = GetAllCSFiles(@"C:\Users\yveem\source\repos\CompileTestProject"); //var input = GetAllCSFiles(@"C:\Users\yveem\source\repos\Redmond"); ParseFile parseFile = new ParseFile(@"C:\Users\yveem\source\repos\Redmond\TestParse.parse").Read(); string inputFile = opts.FindOption("input", "i")?.Argument ?? @"C:\Users\yveem\source\repos\Redmond\TestInput.txt"; var context = new CompilationContext(parseFile, input, output); context.Compile(); }
public static void ExtractAndWriteSwavFromSwar(Stream pStream, Swar pSwar, string pOutputPath, bool includeOutputFolderInFileName) { string outputFileName; string outputFolderName = Path.GetFileName(pOutputPath); if (pSwar.SampleOffsets.Length > 0) { if (!Directory.Exists(pOutputPath)) { Directory.CreateDirectory(pOutputPath); } } for (int i = 0; i < pSwar.SampleOffsets.Length; i++) { if (pSwar.SampleOffsets[i] > 0) { Swav.SwavInfo swavInfo = Swav.GetSwavInfo(pStream, pSwar.SampleOffsets[i]); UInt32 fileSize = (swavInfo.LoopOffset + swavInfo.NonLoopLength) * 4; if (includeOutputFolderInFileName) { outputFileName = Path.Combine(pOutputPath, String.Format("{0}_{1}", outputFolderName, i.ToString("X2")) + Swav.FILE_EXTENSION); } else { outputFileName = Path.Combine(pOutputPath, i.ToString("X2") + Swav.FILE_EXTENSION); } using (BinaryWriter bw = new BinaryWriter(File.Open(outputFileName, FileMode.Create, FileAccess.Write))) { bw.Write(Swav.ASCII_SIGNATURE); bw.Write(BitConverter.GetBytes(fileSize + 0x10 + 0x08 + Swav.SWAV_INFO_SIZE)); bw.Write(BitConverter.GetBytes((UInt16)0x10)); bw.Write(BitConverter.GetBytes((UInt16)0x01)); bw.Write(Swav.DATA_SIGNATURE); bw.Write(BitConverter.GetBytes(fileSize + 0x08 + Swav.SWAV_INFO_SIZE)); bw.Write(ParseFile.ParseSimpleOffset(pStream, pSwar.SampleOffsets[i], (int)Swav.SWAV_INFO_SIZE)); bw.Write(ParseFile.ParseSimpleOffset(pStream, pSwar.SampleOffsets[i] + Swav.SWAV_INFO_SIZE, (int)fileSize)); } } } }
public void LoadDirectories(FileStream isoStream) { byte[] rootDirectoryBytes; NintendoGameCubeDirectoryRecord rootDirectoryRecord; NintendoGameCubeDirectoryStructure rootDirectory; // Get name table offset rootDirectoryBytes = ParseFile.ParseSimpleOffset(isoStream, this.RootDirectoryOffset, 0xC); rootDirectoryRecord = new NintendoGameCubeDirectoryRecord(rootDirectoryBytes, this.OffsetBitShiftValue); this.NameTableOffset = this.RootDirectoryOffset + ((long)rootDirectoryRecord.FileSize * 0xC); rootDirectory = new NintendoGameCubeDirectoryStructure(isoStream, isoStream.Name, rootDirectoryRecord, this.ImageCreationTime, this.VolumeBaseOffset, this.RootDirectoryOffset, this.RootDirectoryOffset, this.NameTableOffset, String.Empty, String.Empty, this.OffsetBitShiftValue); this.DirectoryStructureArray.Add(rootDirectory); }
public async Task <Boolean> AddPost(string Description, byte[] Postpic) { try { ParseFile file = new ParseFile("postpic.jpg", Postpic); await file.SaveAsync(); ParseObject Post = new ParseObject("Post"); Post["Description"] = Description; Post["Image"] = file; Post["User"] = ParseUser.CurrentUser; await Post.SaveAsync(); return(true); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); return(false); } }
private SdatInfoSseq[] getInfoSseqEntries(Stream pStream, int pSectionOffset, SdatInfoRec pSdatInfoRec) { int entryCount = BitConverter.ToInt32(pSdatInfoRec.nCount, 0); SdatInfoSseq[] ret = new SdatInfoSseq[entryCount]; for (int i = 0; i < entryCount; i++) { ret[i] = new SdatInfoSseq(); int infoOffset = BitConverter.ToInt32(pSdatInfoRec.nEntryOffsets[i], 0); if (infoOffset > 0) { ret[i].fileId = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_FILEID_OFFSET, INFO_ENTRY_SEQ_FILEID_LENGTH); ret[i].unknown = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_UNKNOWN_OFFSET, INFO_ENTRY_SEQ_UNKNOWN_LENGTH); ret[i].bnk = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_BANKID_OFFSET, INFO_ENTRY_SEQ_BANKID_LENGTH); ret[i].vol = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_VOL_OFFSET, INFO_ENTRY_SEQ_VOL_LENGTH); ret[i].cpr = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_CPR_OFFSET, INFO_ENTRY_SEQ_CPR_LENGTH); ret[i].ppr = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_PPR_OFFSET, INFO_ENTRY_SEQ_PPR_LENGTH); ret[i].ply = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_PLY_OFFSET, INFO_ENTRY_SEQ_PLY_LENGTH); ret[i].unknown2 = ParseFile.ParseSimpleOffset(pStream, pSectionOffset + infoOffset + INFO_ENTRY_SEQ_UNKNOWN2_OFFSET, INFO_ENTRY_SEQ_UNKNOWN2_LENGTH); } } return(ret); }
public void ExtractToFile(Stream pStream, string pOutputDirectory, object Options) { string outputFileName = Path.GetFileName(this.filePath); int fileCount = 0; if (!Directory.Exists(pOutputDirectory)) { Directory.CreateDirectory(pOutputDirectory); } else { fileCount = Directory.GetFiles(pOutputDirectory, String.Format("{0}*", Path.GetFileNameWithoutExtension(outputFileName)), SearchOption.TopDirectoryOnly).Length; } outputFileName = String.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(outputFileName), fileCount.ToString("X4"), Midi.FILE_EXTENSION); outputFileName = Path.Combine(pOutputDirectory, outputFileName); ParseFile.ExtractChunkToFile(pStream, this.fileStartOffset, this.totalFileLength, outputFileName, true, true); }
public static bool IsSeqTypeSequence(string fileName) { bool ret = false; int numBytesRead; byte[] checkBytes = new byte[PsxSequence.ASCII_SIGNATURE_SEQ.Length]; using (FileStream fs = File.OpenRead(fileName)) { numBytesRead = fs.Read(checkBytes, 0, PsxSequence.ASCII_SIGNATURE_SEQ.Length); if (numBytesRead == PsxSequence.ASCII_SIGNATURE_SEQ.Length) { ret = ParseFile.CompareSegment(checkBytes, 0, PsxSequence.ASCII_SIGNATURE_SEQ); } } return(ret); }
public static bool IsSonyAdpcmRow(byte[] potentialAdpcm, bool doAdditionalChecks) { bool ret = true; if ((potentialAdpcm.Length != SONY_ADPCM_ROW_SIZE) || (potentialAdpcm[1] > 7) || (potentialAdpcm[0] > 0x4C) || (ParseFile.CompareSegment(potentialAdpcm, 0, VB_START_BYTES)) ) { ret = false; } else if (doAdditionalChecks && ((potentialAdpcm[0] == 0) && (potentialAdpcm[1] != 2) && (GetCountOfZeroBytes(potentialAdpcm) > 14))) { ret = false; } return(ret); }
// 등록 private async void btn_regist_Click_1(object sender, RoutedEventArgs e) { if (txt_caption1.Text.Equals("")) { MessageBoxResult result = MessageBox.Show("Please input caption."); return; } else if (txt_image1.Text.Equals("") || txt_image2.Text.Equals("")) { MessageBoxResult result = MessageBox.Show("Please select images."); return; } foreach (ParseObject PO in m_RegList) { if (txt_id.Text.Equals(PO.Get <string>("NFC_id"))) { MessageBoxResult result = MessageBox.Show("Current NFC id is already exist."); return; } } byte[] data1 = this.ConvertImageToByte(m_bitmap1); ParseFile file1 = new ParseFile("1.png", data1); await file1.SaveAsync(); byte[] data2 = this.ConvertImageToByte(m_bitmap2); ParseFile file2 = new ParseFile("2.png", data2); await file2.SaveAsync(); var NFCreg = new ParseObject("NFC_reg"); NFCreg["NFC_id"] = txt_id.Text; NFCreg["linked_user"] = "******"; NFCreg["Caption"] = txt_caption1.Text; NFCreg["File1"] = file1; NFCreg["File2"] = file2; await NFCreg.SaveAsync(); MessageBox.Show("Regist finish!"); RefreshList(); }
public static SwavInfo GetSwavInfo(Stream pStream, long pOffset) { SwavInfo ret = new SwavInfo(); ret.WaveType = (uint)ParseFile.ParseSimpleOffset(pStream, pOffset + SWAV_INFO_WAVETYPE_OFFSET, SWAV_INFO_WAVETYPE_LENGTH)[0]; ret.Loop = (uint)ParseFile.ParseSimpleOffset(pStream, pOffset + SWAV_INFO_LOOPFLAG_OFFSET, SWAV_INFO_LOOPFLAG_LENGTH)[0]; ret.SampleRate = BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(pStream, pOffset + SWAV_INFO_SAMPLERATE_OFFSET, SWAV_INFO_SAMPLERATE_LENGTH), 0); ret.Time = BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(pStream, pOffset + SWAV_INFO_SAMPLETIME_OFFSET, SWAV_INFO_SAMPLETIME_LENGTH), 0); ret.LoopOffset = BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(pStream, pOffset + SWAV_INFO_LOOPOFFSET_OFFSET, SWAV_INFO_LOOPOFFSET_LENGTH), 0); ret.NonLoopLength = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(pStream, pOffset + SWAV_INFO_NONLOOPLENGTH_OFFSET, SWAV_INFO_NONLOOPLENGTH_OFFSET), 0); return(ret); }
public override object VisitScript([NotNull] HtmlParser.ScriptContext context) { foreach (var item in context.htmlAttribute()) { var name = item.htmlAttributeName().TAG_NAME().GetText(); if (name.ToUpper() != "SRC") { continue; } var manager = new HtmlAttributeManager(item); var path = manager.Value; Entities.File searchFile = valueProvider.GetFile(path); if (searchFile != null) { if (searchFile.IsExternal) { manager.Value = searchFile.FileName; } return(null); } try { HttpWebRequest req = WebRequest.CreateHttp(path); req.Method = "GET"; var result = req.GetResponse(); var fileName = Path.GetRandomFileName() + ".js"; Entities.File file = new ParseFile().ToParse(fileName, result.GetResponseStream(), Entities.FileType.Js); valueProvider.AddFile(file); file = new Entities.File { Type = file.Type, FileName = file.FileName, SearchName = path, IsExternal = true, }; valueProvider.AddFile(file); manager.Value = fileName; } catch { return(null); } } return(null); }
public static byte[] RemoveChunkFromStream(MemoryStream source, long startingOffset, long length) { int bytesRead; byte[] bytes = new byte[1024]; var ret = ParseFile.ExtractChunkToMemoryStream(source, 0, startingOffset); // append remainder source.Position = startingOffset + length; bytesRead = source.Read(bytes, 0, bytes.Length); while (bytesRead > 0) { ret.Write(bytes, 0, bytesRead); bytesRead = source.Read(bytes, 0, bytes.Length); } return(ret.ToArray()); }
public static string[] SplitFile(string sourceFile, long startingOffset, ulong chunkSizeInBytes, string outputFolder) { string[] outputFileList; string outputFileName; var outputFiles = new ArrayList(); long fileLength; ulong currentOffset; int chunkCount; using (var sourceStream = File.OpenRead(sourceFile)) { // get file length fileLength = sourceStream.Length; // init counters chunkCount = 1; currentOffset = (ulong)startingOffset; while (currentOffset < (ulong)fileLength) { // construct output file name outputFileName = Path.Combine(outputFolder, string.Format("{0}.{1}", Path.GetFileName(sourceFile), chunkCount.ToString("D3"))); ParseFile.ExtractChunkToFile64(sourceStream, currentOffset, chunkSizeInBytes, outputFileName, true, true); outputFiles.Add(outputFileName); currentOffset += chunkSizeInBytes; chunkCount++; } } outputFileList = (string[])outputFiles.ToArray(typeof(string)); return(outputFileList); }
IEnumerator UploadImage(byte[] data) { LoadAlert.Instance.StartLoad("Uploading photo...", null, -1); ParseFile file = new ParseFile(_item.Name + ".png", data); Task task = file.SaveAsync(); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.Exception == null) { DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again"); } else { _item.Image = file; task = _item.SaveAsync(); while (!task.IsCompleted) { yield return(null); } if (task.Exception == null) { Texture2D tex = new Texture2D(1, 1); tex.LoadImage(data); Image.texture = tex; } else { DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again"); } } }
private ushort getBlockSize(Stream inStream, long hcaOffset) { ushort blockSize = 0; long decChunkOffset; long compChunkOffset; //---------------- // 'dec ' offset //---------------- // get 'dec' chunk offset, if exists (v1.3, maybe others?) decChunkOffset = ParseFile.GetNextOffsetWithLimitMasked(inStream, hcaOffset, hcaOffset + MAX_HEADER_SIZE, DEC_CHUNK_BYTES, MASK_BYTES, true); if (decChunkOffset > -1) { blockSize = ParseFile.ReadUshortBE(inStream, decChunkOffset + 4); } else { //---------------- // 'comp' offset //---------------- // get 'comp' chunk offset, if exists (v1.3, maybe others?) compChunkOffset = ParseFile.GetNextOffsetWithLimitMasked(inStream, hcaOffset, hcaOffset + MAX_HEADER_SIZE, COMP_CHUNK_BYTES, MASK_BYTES, true); if (compChunkOffset > -1) { blockSize = ParseFile.ReadUshortBE(inStream, compChunkOffset + 4); } else { throw new FormatException( String.Format("Cannot find 'dec' or 'comp' chunk to determine block size for HCA starting at 0x{0}", hcaOffset.ToString("X8"))); } } return(blockSize); }
public static bool IsPotentialAdpcm(Stream searchStream, long offset, int rowsToCheck, bool doAdditionalChecks, ref bool previousRowIsZeroes) { bool ret = true; byte[] checkBytes = new byte[0x10 * rowsToCheck]; int bytesRead; searchStream.Position = offset; bytesRead = searchStream.Read(checkBytes, 0, checkBytes.Length); // check for rows meeting criteria for (int i = 0; i < rowsToCheck; i++) { if (ParseFile.CompareSegmentUsingSourceOffset(checkBytes, (i * 0x10), Psf.SONY_ADPCM_ROW_SIZE, Psf.VB_START_BYTES)) { if (previousRowIsZeroes) { ret = false; break; } else { previousRowIsZeroes = true; } } else { previousRowIsZeroes = false; if ((bytesRead < ((i * 0x10) + 0x10)) || (!IsSonyAdpcmRow(checkBytes, doAdditionalChecks, i))) { ret = false; break; } } } return(ret); }
private PsfPsyQAddresses getAdditionalDriverInfo(PsfPsyQAddresses existingValues, PsfStubMakerStruct stubMakerParameters, string driverPath) { string checksum; byte[] jumpAddress; PsfPsyQAddresses ret = existingValues; using (FileStream checksumStream = File.OpenRead(driverPath)) { checksum = ChecksumUtil.GetCrc32OfFullFile(checksumStream); jumpAddress = ParseFile.ParseSimpleOffset(checksumStream, 0x10, 0x04); } ret.DriverTextString = stubMakerParameters.DriverText; ret.ExeFileNameCrc = String.Format(" (int)\"{0}\", 0x{1},", Path.GetFileName(driverPath), checksum); ret.JumpPatchAddress = String.Format("0x{0}", BitConverter.ToUInt32(jumpAddress, 0).ToString("X8")); return(ret); }
public static MovieType GetMobiclipStreamType(string path) { MovieType streamType = MovieType.Unknown; using (FileStream fs = File.OpenRead(path)) { byte[] typeBytes = ParseFile.ParseSimpleOffset(fs, 2, 2); if (ParseFile.CompareSegment(typeBytes, 0, MobiclipNdsStream.StreamTypeBytes)) { streamType = MovieType.NintendoDs; } else if (ParseFile.CompareSegment(typeBytes, 0, MobiclipWiiStream.StreamTypeBytes)) { streamType = MovieType.Wii; } } return(streamType); }
private static bool IsSilentBlock(byte[] pCdxaBlock, ExtractXaStruct pExtractXaStruct) { bool ret = false; int silentFrameCount = 0; long bufferOffset = 0; while ((bufferOffset = ParseFile.GetNextOffset(pCdxaBlock, bufferOffset, Cdxa.XA_SILENT_FRAME)) > -1) { silentFrameCount++; bufferOffset += 1; } // did we find enough silent frames? if (silentFrameCount >= pExtractXaStruct.SilentFramesCount) { ret = true; } return(ret); }