protected virtual void Dispose(bool disposing) #endif { if (handle != MonoIO.InvalidHandle) { FlushBuffer(); if (owner) { MonoIOError error; MonoIO.Close(handle, out error); if (error != MonoIOError.ERROR_SUCCESS) { // don't leak the path information for isolated storage throw MonoIO.GetException(GetSecureFileName(name), error); } handle = MonoIO.InvalidHandle; } } canseek = false; access = 0; if (disposing) { buf = null; } if (disposing) { GC.SuppressFinalize(this); } }
public static bool SetFileTime(string path, int type, long creation_time, long last_access_time, long last_write_time, DateTime dateTime, out MonoIOError error) { IntPtr intPtr = MonoIO.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, FileOptions.None, out error); if (intPtr == MonoIO.InvalidHandle) { return(false); } switch (type) { case 1: creation_time = dateTime.ToFileTime(); break; case 2: last_access_time = dateTime.ToFileTime(); break; case 3: last_write_time = dateTime.ToFileTime(); break; } bool result = MonoIO.SetFileTime(intPtr, creation_time, last_access_time, last_write_time, out error); MonoIOError monoIOError; MonoIO.Close(intPtr, out monoIOError); return(result); }
protected override void Dispose(bool disposing) { Exception exc = null; if (handle != MonoIO.InvalidHandle) { try { FlushBuffer(); } catch (Exception e) { exc = e; } if (owner) { MonoIOError error; MonoIO.Close(handle, out error); if (error != MonoIOError.ERROR_SUCCESS) { // don't leak the path information for isolated storage throw MonoIO.GetException(GetSecureFileName(name), error); } handle = MonoIO.InvalidHandle; } } canseek = false; access = 0; if (disposing && buf != null) { if (buf.Length == DefaultBufferSize && buf_recycle == null) { lock (buf_recycle_lock) { if (buf_recycle == null) { buf_recycle = buf; } } } buf = null; GC.SuppressFinalize(this); } if (exc != null) { throw exc; } }
protected override void Dispose(bool disposing) { Exception exc = null; if (safeHandle != null && !safeHandle.IsClosed) { try { // If the FileStream is in "exposed" status // it means that we do not have a buffer(we write the data without buffering) // therefor we don't and can't flush the buffer becouse we don't have one. FlushBuffer(); } catch (Exception e) { exc = e; } if (owner) { MonoIOError error; MonoIO.Close(safeHandle.DangerousGetHandle(), out error); if (error != MonoIOError.ERROR_SUCCESS) { // don't leak the path information for isolated storage throw MonoIO.GetException(GetSecureFileName(name), error); } safeHandle.DangerousRelease(); } } canseek = false; access = 0; if (disposing && buf != null) { if (buf.Length == DefaultBufferSize && buf_recycle == null) { lock (buf_recycle_lock) { if (buf_recycle == null) { buf_recycle = buf; } } } buf = null; GC.SuppressFinalize(this); } if (exc != null) { throw exc; } }