[Mono-devel-list] Flushing a FileStream to disk

Jeroen Frijters jeroen at sumatra.nl
Fri Nov 5 09:04:00 EST 2004


Thanks!

I ended up using reflection to call System.IO.MonoIO.Flush() (the one in Mono's mscorlib.dll). Hopefully that'll remain stable.

Regards,
Jeroen

> -----Original Message-----
> From: Sébastien Pouliot [mailto:spouliot at videotron.ca] 
> Sent: Friday, November 05, 2004 14:36
> To: Rodrigo B. de Oliveira; Jeroen Frijters; 
> mono-devel-list at lists.ximian.com
> Subject: RE: [Mono-devel-list] Flushing a FileStream to disk
> 
> Note that code outside the "core" (i.e. mscorlib, System a 
> very few others)
> class library shouldn't use the internal calls to the runtime.
> 
> Three good reasons:
> a) Internal calls can change between (even minor) releases of Mono;
> b) Internal calls differs between runtimes (e.g. Mono vs MS, ...);
> c) Code Access Security will not allow such calls from non-core, i.e.
> without ECMA public key, libraries.
> 
> In this case you better find a UNIX (Mono.Posix ?) way of doing so and
> switch calls (win32/posix) at runtime.
> 
> Sebastien
> 
> > -----Original Message-----
> > From: mono-devel-list-admin at lists.ximian.com
> > [mailto:mono-devel-list-admin at lists.ximian.com]On Behalf Of 
> Rodrigo B.
> > de Oliveira
> > Sent: 5 novembre 2004 09:01
> > To: Jeroen Frijters; mono-devel-list at lists.ximian.com
> > Subject: Re: [Mono-devel-list] Flushing a FileStream to disk
> >
> >
> > This was contributed to Bamboo.Prevalence by Rafael Teixera:
> >
> > namespace System.IO
> > {
> >  using System.Runtime.CompilerServices;
> >
> >  internal enum MonoIOError: int { ERROR_SUCCESS = 0, 
> ERROR_ERROR = -1 };
> >
> >  internal sealed class MonoIO
> >  {
> >   [MethodImplAttribute (MethodImplOptions.InternalCall)]
> >   public static extern bool Flush(IntPtr handle, out 
> MonoIOError error);
> >  }
> > }
> >
> > I'm not really sure how the InternalCall binding works but 
> it seems to do
> > the job well.
> >
> > cheers,
> > Rodrigo
> >
> > ----- Original Message -----
> > From: "Jeroen Frijters" <jeroen at sumatra.nl>
> > To: <mono-devel-list at lists.ximian.com>
> > Sent: Friday, November 05, 2004 8:27 AM
> > Subject: [Mono-devel-list] Flushing a FileStream to disk
> >
> >
> > Hi,
> >
> > In IKVM I need a way to flush a FileStream to disk (not 
> just flushing
> > the managed buffer to the OS, which is what FileStream.Flush does).
> >
> > On Windows I use:
> >
> > void FlushToDisk(FileStream fs)
> > {
> >   if(!FlushFileBuffers(fs.Handle))
> >     throw new IOException();
> > }
> >
> > [DllImport("kernel32")]
> > static extern bool FlushFileBuffers(IntPtr handle);
> >
> > What would be the equivalent on Mono on Linux?
> >
> > Thanks.
> >
> > Regards,
> > Jeroen
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 
> 



More information about the Mono-devel-list mailing list