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

Sébastien Pouliot spouliot at videotron.ca
Fri Nov 5 08:35:50 EST 2004


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