// jpegio.c (618, 1) // fgetJpegResolution(fp, pxres, pyres) as int // fgetJpegResolution(FILE *, l_int32 *, l_int32 *) as l_int32 /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/fgetJpegResolution/*"/> /// <returns></returns> public static int fgetJpegResolution( FILE fp, object pxres, object pyres) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (pxres == null) { throw new ArgumentNullException("pxres cannot be Nothing"); } if (pyres == null) { throw new ArgumentNullException("pyres cannot be Nothing"); } IntPtr fpPtr = IntPtr.Zero; if (fp != null) { fpPtr = fp.Pointer; } int _Result = Natives.fgetJpegResolution(fp.Pointer, pxres, pyres); return(_Result); }
private void Load(string fileName) { var fileBytes = File.ReadAllBytes(fileName); using (var ms = new MemoryStream(fileBytes)) { using (var reader = new BinaryReaderExt(ms)) { reader.ReadBytes(16); var fileCount = reader.ReadInt32(); reader.ReadInt32(); for (var i = 0; i < fileCount; i++) { var file = new FILE(); file.Index = reader.ReadInt32(); reader.ReadBytes(21); file.FileName = reader.ReadAscii(); file.FileName = file.FileName.Substring(0, file.FileName.IndexOf('\0')); // Otherwise windows will crap out reader.ReadBytes(12); var filePos = reader.ReadInt32(); var fileLength = reader.ReadInt32(); var pos = reader.BaseStream.Position; reader.BaseStream.Seek(filePos, SeekOrigin.Begin); file.File = reader.ReadBytes(fileLength); reader.BaseStream.Seek(pos, SeekOrigin.Begin); Files.Add(file); } } } }
private static void WriteBytes(Options OPT, Command C) { if (FILE == null) { Status(OPT, "No file open", RESULT.NOFILE); } else if (C.Arguments.Length > 0) { var Operations = GetByteOperations(C.Arguments); if (Operations == null) { Status(OPT, "Unable to convert arguments to byte instructions", RESULT.INVALID_ARG); } else { foreach (var Opt in Operations) { if (!Opt.ProcessBytes(FILE)) { FILE.Flush(); Status(OPT, $"Error writing to file", RESULT.IO_ERROR); return; } } FILE.Flush(); Status(OPT, $"Written={Operations.Sum(m => m.Bytes.LongLength)} Position={FILE.Position}", RESULT.OK); } } else { Status(OPT, "'w' requires at least one argument", RESULT.ARGUMENT_MISMATCH); } }
private static void Concat(Options OPT, Command C) { if (FILE == null) { Status(OPT, "No file open", RESULT.NOFILE); } else { if (C.Arguments.Length > 0) { try { using (var FS = File.OpenRead(C.Arguments.First())) { FS.CopyTo(FILE); FILE.Flush(); Status(OPT, $"Written={FS.Length} Position={FILE.Position}", RESULT.OK); } } catch (Exception ex) { Status(OPT, $"Unable to concat files. {ex.Message}", RESULT.IO_ERROR); } } else { Status(OPT, "cat requires one argument", RESULT.ARGUMENT_MISMATCH); } } }
public static int fread(Uint8Array data, int size, int count, FILE file) { var reader = new BinaryReader(file.stream); Uint8Array buf = reader.ReadBytes(size); Buffer.BlockCopy(buf, 0, data, 0, size); return count; }
public static double GetArrival(FILE fp) // read an arrival time { double a; fscanf(fp, "%lf", a); return(a); }
public static int fread(out int data, int size, int count, FILE file) { BinaryReader reader = new BinaryReader(file.stream); data = reader.ReadInt32(); return(count); }
/* ** Function to open a file to be input unit. ** Return 0 on success or 1 on error. */ public static int lua_openfile(CharPtr fn) { if (false) { fprintf(stdout, "=============>lua_openfile %s\n", fn); } lua_linenumber = 1; lua_setinput(fileinput); if (false) { fprintf(stdout, "=============>lua_openfile 2 %s\n", fn); } fp = fopen(fn, "r"); if (false) { fprintf(stdout, "=============>lua_openfile 3 %s\n", fn); } if (fp == null) { return(1); } if (false) { fprintf(stdout, "=============>lua_openfile 4 %s\n", fn); } if (lua_addfile(fn) != 0) { return(1); } if (false) { fprintf(stdout, "=============>lua_openfile 5 %s\n", fn); } return(0); }
// jpegio.c (270, 1) // pixReadStreamJpeg(fp, cmapflag, reduction, pnwarn, hint) as Pix // pixReadStreamJpeg(FILE *, l_int32, l_int32, l_int32 *, l_int32) as PIX * /// <summary> /// (1) The jpeg comment, if it exists, is not stored in the pix. /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixReadStreamJpeg/*"/> /// <param name="fp">[in] - file stream</param> /// <param name="cmapflag">[in] - 0 for no colormap in returned pix 1 to return an 8 bpp cmapped pix if spp = 3 or 4</param> /// <param name="reduction">[in] - scaling factor: 1, 2, 4 or 8</param> /// <param name="pnwarn">[out][optional] - number of warnings</param> /// <param name="hint">[in] - a bitwise OR of L_JPEG_ values 0 for default</param> /// <returns>pix, or NULL on error Usage: see pixReadJpeg</returns> public static Pix pixReadStreamJpeg( FILE fp, int cmapflag, int reduction, out int pnwarn, int hint = 0) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (reduction < 2 || reduction > 16) { throw new ArgumentException("scaling factor: 1, 2, 4 or 8"); } IntPtr _Result = Natives.pixReadStreamJpeg(fp.Pointer, cmapflag, reduction, out pnwarn, hint); if (_Result == IntPtr.Zero) { return(null); } return(new Pix(_Result)); }
// gifiostub.c (59, 6) // pixWriteStreamGif(fp, pix) as int // pixWriteStreamGif(FILE *, PIX *) as l_ok /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteStreamGif/*"/> /// <returns></returns> public static int pixWriteStreamGif( FILE fp, Pix pix) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (pix == null) { throw new ArgumentNullException("pix cannot be Nothing"); } IntPtr fpPtr = IntPtr.Zero; if (fp != null) { fpPtr = fp.Pointer; } IntPtr pixPtr = IntPtr.Zero; if (pix != null) { pixPtr = pix.Pointer; } int _Result = Natives.pixWriteStreamGif(fp.Pointer, pix.Pointer); return(_Result); }
public static int fread(out double data, int size, int count, FILE file) { BinaryReader reader = new BinaryReader(file.stream); data = (size == 4) ? reader.ReadSingle() : reader.ReadDouble(); return(count); }
// pngio.c (805, 1) // fgetPngColormapInfo(fp, pcmap, ptransparency) as int // fgetPngColormapInfo(FILE *, PIXCMAP **, l_int32 *) as l_ok /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/fgetPngColormapInfo/*"/> /// <returns></returns> public static int fgetPngColormapInfo( FILE fp, PixColormap pcmap, object ptransparency) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (pcmap == null) { throw new ArgumentNullException("pcmap cannot be Nothing"); } if (ptransparency == null) { throw new ArgumentNullException("ptransparency cannot be Nothing"); } IntPtr fpPtr = IntPtr.Zero; if (fp != null) { fpPtr = fp.Pointer; } IntPtr pcmapPtr = IntPtr.Zero; if (pcmap != null) { pcmapPtr = pcmap.Pointer; } int _Result = Natives.fgetPngColormapInfo(fp.Pointer, pcmapPtr, ptransparency); return(_Result); }
// webpiostub.c (83, 6) // pixWriteStreamWebP(fp, pixs, quality, lossless) as int // pixWriteStreamWebP(FILE *, PIX *, l_int32, l_int32) as l_ok /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteStreamWebP/*"/> /// <returns></returns> public static int pixWriteStreamWebP( FILE fp, Pix pixs, int quality, int lossless) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (pixs == null) { throw new ArgumentNullException("pixs cannot be Nothing"); } IntPtr fpPtr = IntPtr.Zero; if (fp != null) { fpPtr = fp.Pointer; } IntPtr pixsPtr = IntPtr.Zero; if (pixs != null) { pixsPtr = pixs.Pointer; } int _Result = Natives.pixWriteStreamWebP(fp.Pointer, pixs.Pointer, quality, lossless); return(_Result); }
/// Load a file using the given filename. Returns true if successful. public bool LoadFile(string filename, TiXmlEncoding encoding /*= TIXML_DEFAULT_ENCODING*/) { // There was a really terrifying little bug here. The code: // value = filename // in the STL case, cause the assignment method of the PG_string to // be called. What is strange, is that the PG_string had the same // address as it's c_str() method, and so bad things happen. Looks // like a bug in the Microsoft STL implementation. // Add an extra string to avoid the crash. value = filename; // reading in binary mode so that tinyxml can normalize the EOL FILE file = TiXmlFOpen(value.c_str(), "rb"); if (file != null) { bool result = LoadFile(file, encoding); fclose(file); return(result); } else { SetError(ErrorType.TIXML_ERROR_OPENING_FILE, null, 0, null, TiXmlEncoding.TIXML_ENCODING_UNKNOWN); return(false); } }
public static int fread(ref byte[] data, int size, int count, FILE file) { BinaryReader reader = new BinaryReader(file.stream); byte[] buf = reader.ReadBytes(size); Buffer.BlockCopy(buf, 0, data, 0, size); return count; }
public static double GetService(FILE fp) // read a service time { double s; fscanf(fp, "%lf\n", s); return(s); }
public static void fwrite(float value, int size, int count, FILE file) { if (size != 4) throw new NotImplementedException("writing float with size other than 4"); var writer = new BinaryWriter(file.stream); writer.Write(value); }
public void ListLoad() { Sales.Clear(); var lines = FILE.read(path_sale); if (lines == null) { return; } foreach (string line in lines) { try { var datas = line.Split(','); Sales.Add(new Sale { date = datas[0], count = datas[1], total = Convert.ToInt32(datas[2]), product = new Product() { code = datas[3], category = datas[4], name = datas[5], price = Convert.ToInt32(datas[6]), comment = datas[7], } }); } catch { continue; } } ListADD(); }
/// <summary> /// 파일 읽어서 컬렉션에 추가하는 함수 /// </summary> public void productLoad() { products.Clear(); var lines = FILE.read(path_product); if (lines == null) { return; } foreach (string line in lines) { try { var datas = line.Split(','); products.Add(new Product { code = datas[0], category = datas[1], name = datas[2], price = Convert.ToInt32(datas[3]), comment = datas[4] }); } catch { continue; } } }
public static void ps_expand_file_config(Pointer <ps_decoder_t> ps, Pointer <byte> arg, Pointer <byte> extra_arg, Pointer <byte> hmmdir, Pointer <byte> file) { Pointer <byte> val; if ((val = cmd_ln.cmd_ln_str_r(ps.Deref.config, arg)).IsNonNull) { cmd_ln.cmd_ln_set_str_extra_r(ps.Deref.config, extra_arg, val); } else if (hmmdir.IsNull) { cmd_ln.cmd_ln_set_str_extra_r(ps.Deref.config, extra_arg, PointerHelpers.NULL <byte>()); } else { string path = System.IO.Path.Combine(cstring.FromCString(hmmdir), cstring.FromCString(file)); Pointer <byte> tmp = cstring.ToCString(path); if (FILE.file_exists(tmp)) { cmd_ln.cmd_ln_set_str_extra_r(ps.Deref.config, extra_arg, tmp); } else { cmd_ln.cmd_ln_set_str_extra_r(ps.Deref.config, extra_arg, PointerHelpers.NULL <byte>()); } ckd_alloc.ckd_free(tmp); } }
public static int swap_check(FILE fp) { Pointer <byte> magic_buf = PointerHelpers.Malloc <byte>(4); Pointer <uint> magic = magic_buf.ReinterpretCast <uint>(); if (fp.fread(magic_buf, 4, 1) != 1) { err.E_ERROR("Cannot read BYTEORDER MAGIC NO.\n"); return(-1); } if (+magic != BYTE_ORDER_MAGIC) { /* either need to swap or got bogus magic number */ byteorder.SWAP_INT32(magic); if (+magic == BYTE_ORDER_MAGIC) { return(1); } byteorder.SWAP_INT32(magic); err.E_ERROR(string.Format("Bad BYTEORDER MAGIC NO: {0:x8}, expecting {1:x8}\n", magic, BYTE_ORDER_MAGIC)); return(-1); } return(0); }
public bool AddFile(int id, FileManager.File file) { var dbNote = db.NOTEs.Find(id); if (dbNote != null) { //create a file var newFile = new FILE(); string targetFolder = HttpContext.Current.Server.MapPath("~/Uploads"); file.Rename(); file.Save(targetFolder); newFile.FileName = file.FullName; var size = ByteSize.FromBytes(file.ContentLengthBytes); newFile.FileSize = Convert.ToInt32(size.MegaBytes); newFile.FileStorePath = Path.Combine(targetFolder, file.FullName); //link file newFile.NOTE_ID = dbNote.ID; db.FILEs.Add(newFile); db.SaveChanges(); return(true); } else { return(false); } }
public async Task <IHttpActionResult> FilesCreate(int publishid) { int userid = UserInf.GetUser(); List <string> path = new List <string>(); var fileuploadPath = HttpContext.Current.Server.MapPath("~/UploadedFilesPublish"); var multiFormDataStreamProvider = new MultiFileUploadProvider(fileuploadPath); await Request.Content.ReadAsMultipartAsync(multiFormDataStreamProvider); path = multiFormDataStreamProvider.FileData.Select(x => x.LocalFileName).ToList(); foreach (var item in path) { using (MynoteDBEntities db = new MynoteDBEntities()) { FILE file = new FILE { PublishId = publishid, FileName = Path.GetFileName(item), UserId = userid, CreatedTime = DateTime.Now, FilePath = item, IsActive = 1 }; db.FILES.Add(file); db.SaveChanges(); } } return(Ok()); }
// tiffio.c (790, 1) // pixWriteStreamTiffWA(fp, pix, comptype, modestr) as int // pixWriteStreamTiffWA(FILE *, PIX *, l_int32, const char *) as l_ok /// <summary> /// pixWriteStreamTiffWA() /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteStreamTiffWA/*"/> /// <param name="fp">[in] - file stream opened for append or write</param> /// <param name="pix">[in] - </param> /// <param name="comptype">[in] - IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP</param> /// <param name="modestr">[in] - "w" or "a"</param> /// <returns>0 if OK, 1 on error</returns> public static int pixWriteStreamTiffWA( FILE fp, Pix pix, int comptype, String modestr) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (pix == null) { throw new ArgumentNullException("pix cannot be Nothing"); } if (modestr == null) { throw new ArgumentNullException("modestr cannot be Nothing"); } int _Result = Natives.pixWriteStreamTiffWA(fp.Pointer, pix.Pointer, comptype, modestr); return(_Result); }
public MainWin() { this.InitializeComponent(); this.Icon = Properties.Resources.Icon; this.Text = string.Format(this.Text, Program.ProductName); this.cbRestart.Text = string.Format(this.cbRestart.Text, Program.ProductName); this.lblInfo.Text = string.Format(this.lblInfo.Text, Program.ComName); this.cbRestart.Enabled = !string.IsNullOrEmpty(Program.ExecutiveName); this.reports = new Dictionary <FILE, FileStream>(); if (Program.ReportFiles == null || Program.ReportFiles.Length == 0) { this.lbReports.Enabled = false; this.lbReports.BackColor = SystemColors.Control; this.lbReports.Items.Add("<空>"); } else { foreach (string reportFile in Program.ReportFiles) { FILE file = reportFile; this.lbReports.Items.Add(file); this.reports.Add(file, File.OpenRead(file.FullName)); } } this.notifyIcon.Text = $"{Program.ProductName} 错误报告"; this.notifyIcon.Icon = Properties.Resources.Icon; }
public static void ungetc(int c, FILE fp) { if (fp.stream.Position > 0) { fp.stream.Seek(-1, SeekOrigin.Current); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { textBox2.Text = CONVERT.ToASCII(textBox1.Text, checkBox1.Checked); } else { MessageBox.Show("不可以转换空值。", "警告"); } if (checkBox2.Checked) { Clipboard.SetDataObject(textBox2.Text); } if (checkBox3.Checked) { if (textBox3.Text != null) { FILE.Create(textBox3.Text, textBox2.Text); } else { MessageBox.Show("路径为空或非法", "警告"); } } }
// jp2kiostub.c (71, 6) // pixWriteStreamJp2k(fp, pix, quality, nlevels, hint, debug) as int // pixWriteStreamJp2k(FILE *, PIX *, l_int32, l_int32, l_int32, l_int32) as l_ok /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteStreamJp2k/*"/> /// <returns></returns> public static int pixWriteStreamJp2k( FILE fp, Pix pix, int quality, int nlevels, int hint, Enumerations.DebugOnOff debug) { if (fp == null) { throw new ArgumentNullException("fp cannot be Nothing"); } if (pix == null) { throw new ArgumentNullException("pix cannot be Nothing"); } IntPtr fpPtr = IntPtr.Zero; if (fp != null) { fpPtr = fp.Pointer; } IntPtr pixPtr = IntPtr.Zero; if (pix != null) { pixPtr = pix.Pointer; } int _Result = Natives.pixWriteStreamJp2k(fp.Pointer, pix.Pointer, quality, nlevels, hint, (int)debug); return(_Result); }
/* ---------------------------------- */ public static bool isOlder(FILE first, FILE second) { int comp = System.DateTime.Compare( System.IO.File.GetLastWriteTime(first.path), System.IO.File.GetLastWriteTime(second.path) ); return comp == -1; }
/* ** Function to close an opened file */ public static void lua_closefile() { if (fp != null) { fclose(fp); fp = null; } }
public static int fread(ref byte[] data, int size, int count, FILE file) { BinaryReader reader = new BinaryReader(file.stream); byte[] buf = reader.ReadBytes(size); Buffer.BlockCopy(buf, 0, data, 0, size); return(count); }
private static void FindContent(Options OPT, Command C) { if (FILE == null) { Status(OPT, "No file open", RESULT.NOFILE); } else { var Pos = FILE.Position; if (C.Arguments.Length > 0) { var Operations = GetByteOperations(C.Arguments); if (Operations == null) { Status(OPT, "Unable to convert arguments to byte instructions", RESULT.INVALID_ARG); } else if (Operations.Any(m => m.Mode != ByteMode.Overwrite)) { Status(OPT, "Find does not support Byte modes", RESULT.INVALID_ARG); } else { var Bytes = Operations.SelectMany(m => m.Bytes).ToArray(); var Buffer = new byte[Bytes.Length]; if (FILE.Read(Buffer, 0, Buffer.Length) == Buffer.Length) { while (FILE.Position < FILE.Length) { //Check if content found by comparing the byte arrays if (memcmp(Buffer, Bytes, (UIntPtr)Buffer.Length) == 0) { //Set proper file position FILE.Position -= Buffer.Length; Status(OPT, $"Content found Position={FILE.Position}", RESULT.OK); return; } else { //Shift bytes to the left for (var i = 1; i < Buffer.Length; i++) { Buffer[i - 1] = Buffer[i]; } //Add new byte Buffer[Buffer.Length - 1] = (byte)FILE.ReadByte(); } } } Status(OPT, "Content not found", RESULT.PART_OK); FILE.Position = Pos; } } else { Status(OPT, "'f' requires at least one argument", RESULT.ARGUMENT_MISMATCH); } } }
/* ---------------------------------- */ public static void CloseFile(FILE cpf) { if (cpf.strW != null) { cpf.strW.Close(); // Close does automatic Flush() } if (cpf.strR != null) { cpf.strR.Close(); } }
/* ---------------------------------- */ public static bool isOlder(FILE first, FILE second) { int comp = System.DateTime.Compare( System.IO.File.GetLastWriteTime(first.path), System.IO.File.GetLastWriteTime(second.path) ); return(comp == -1); }
public static void fclose(FILE fp) { try { fp.stream.Flush(); fp.stream.Close(); } catch { } }
public static int fclose(FILE* stream) { var Stream = stream->GetStream(); Stream.Close(); stream->FreeStream(); CAlloc.free(stream); return 0; }
/* ---------------------------------- */ public static FILE createFile(char[] fileName) { FILE cpf = new FILE(); try { System.String name = mkStr(fileName); System.IO.FileStream fStr = System.IO.File.Create(name); cpf.path = name; cpf.strW = new System.IO.StreamWriter(fStr); return cpf; } catch { return null; } }
/* ---------------------------------- */ public static FILE createFile(char[] arr) { FILE cpf = new FILE(); try { System.String name = mkStr(arr); System.IO.FileStream fStr = System.IO.File.Create(name); cpf.path = name; cpf.bufS = new System.IO.BufferedStream(fStr); return cpf; } catch { return null; } }
/* ---------------------------------- */ public static FILE createPath(char[] fileName) { System.String fName = mkStr(fileName); try { int ix = fName.LastIndexOf(GPFiles.GPFiles.fileSep); if (ix > 0) { System.String path = fName.Substring(0,ix); if (!System.IO.Directory.Exists(path)) { System.IO.DirectoryInfo junk = System.IO.Directory.CreateDirectory(path); } } FILE cpf = new FILE(); cpf.path = fName; System.IO.FileStream fStr = System.IO.File.Create(fName); cpf.strW = new System.IO.StreamWriter(fStr); return cpf; } catch { return null; } }
//public FILE GetFile(String name); // get an array of file children from the passed folder public FILE[] GetFiles(FOLDER folder) { FILE[] files; long curTOCOfs = 0; // index into TOC byte[] fileOfs = new byte[4]; files = new FILE[folder.numFiles]; inStream.Seek(folder.fileTOCOfs, SeekOrigin.Begin); curTOCOfs = inStream.Position; for (int i = 0; i < folder.numFiles; i++) { inStream.Read(fileOfs, 0, 4); curTOCOfs = inStream.Position; files[i] = GetFileFromOfs(BitConverter.ToUInt32(fileOfs, 0)); inStream.Seek(curTOCOfs, SeekOrigin.Begin); } return (files); }
public static int fread(out double data, int size, int count, FILE file) { BinaryReader reader = new BinaryReader(file.stream); data = (size == 4) ? reader.ReadSingle() : reader.ReadDouble(); return count; }
public static void fclose(FILE file) { file.stream.Close(); file.stream = null; file = null; }
public static extern bool GetVolumeInformation( [In] [MarshalAs(UnmanagedType.LPTStr)] string lpRootPathName, [Out] [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpVolumeNameBuffer, uint nVolumeNameSize, IntPtr lpVolumeSerialNumber, IntPtr lpMaximumComponentLength, out FILE lpFileSystemFlags, [Out] [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpFileSystemNameBuffer, uint nFileSystemNameSize);
public String GetName(FILE file) { return (GetNameFromOfs(file.filenameOfs)); }
public byte[] ExtractFile(FILE file) { return (wad.GetFileFromOfs(file.offset, file.size)); }
/* ** Turn tracing on or off */ static void sqlite3VdbeTrace( Vdbe p, FILE trace ) { p.trace = trace; }
Vector3d ReadVector( FILE *fp );
public static void fseek(FILE file, int position, int seek) { file.stream.Seek(position, SeekOrigin.Begin); }
int ReadInt( FILE *fp );
bool WriteVector( FILE *fp, Vector3d& vec );
bool WriteDouble( FILE *fp, double val );
bool WriteInt( FILE *fp, int val );
public static int fread(out int data, int size, int count, FILE file) { BinaryReader reader = new BinaryReader(file.stream); data = reader.ReadInt32(); return count; }
private FILE UnMarshalFile(byte[] arr) { FILE str = new FILE(); int size = Marshal.SizeOf(str); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, size); str = (FILE)Marshal.PtrToStructure(ptr, str.GetType()); Marshal.FreeHGlobal(ptr); return str; }
// simple replacement, no rebuild of the WAD public void ReplaceFile(FILE inFile, byte[] buf, UInt32 size) { inStream.Seek(inFile.thisOffset, SeekOrigin.Begin); inFile.size = size; byte[] marshalled = MarshalFile(inFile); inStream.Write(marshalled, 0, Marshal.SizeOf(inFile)-104); UnMarshalFile(marshalled); wad.ReplaceFile(buf, inFile.offset, inFile.size, inFile.sizeInBlocks); }
double ReadDouble( FILE *fp );
public static char getc(FILE file) { return (char)file.stream.ReadByte(); }
private FILE GetFile() { FILE file = new FILE(); byte[] marshalled; file.thisOffset = inStream.Position; marshalled = MarshalFile(file); inStream.Read(marshalled, 0, 0x10); file = UnMarshalFile(marshalled); file.fileName = GetNameFromOfs(file.filenameOfs); return (file); }
private byte[] MarshalFile(FILE str) { int size = Marshal.SizeOf(str); byte[] arr = new byte[size]; IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(str, ptr, true); Marshal.Copy(ptr, arr, 0, size); Marshal.FreeHGlobal(ptr); return arr; }
/* ** Print a single opcode. This routine is used for debugging only. */ static void sqlite3VdbePrintOp( FILE pOut, int pc, Op pOp ) { string zP4; string zPtr = null; string zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; if ( pOut == null ) pOut = System.Console.Out; zP4 = displayP4( pOp, zPtr, 50 ); StringBuilder zOut = new StringBuilder( 10 ); sqlite3_snprintf( 999, zOut, zFormat1, pc, sqlite3OpcodeName( pOp.opcode ), pOp.p1, pOp.p2, pOp.p3, zP4, pOp.p5, #if SQLITE_DEBUG pOp.zComment != null ? pOp.zComment : "" #else "" #endif ); pOut.Write( zOut ); //fflush(pOut); }