protected override void DoOpen(FileInfo info) { if (!gmime_initialized) { gmime_initialized = true; // Only try initialization once; if it fails, it'll never work. try { GMime.Global.Init(); } catch (Exception e) { Log.Error(e, "Unable to initialize GMime"); gmime_broken = true; Error(); return; } } if (gmime_broken) { Error(); return; } int mail_fd = Mono.Unix.Native.Syscall.open(info.FullName, Mono.Unix.Native.OpenFlags.O_RDONLY); if (mail_fd == -1) { throw new IOException(String.Format("Unable to read {0} for parsing mail", info.FullName)); } GMime.StreamFs stream = new GMime.StreamFs(mail_fd); GMime.Parser parser = new GMime.Parser(stream); this.message = parser.ConstructMessage(); stream.Dispose(); parser.Dispose(); if (this.message == null) { Error(); } }
protected override void DoOpen (FileInfo info) { if (!gmime_initialized) { gmime_initialized = true; // Only try initialization once; if it fails, it'll never work. try { GMime.Global.Init (); } catch (Exception e) { Log.Error (e, "Unable to initialize GMime"); gmime_broken = true; Error (); return; } } if (gmime_broken) { Error (); return; } int mail_fd = Mono.Unix.Native.Syscall.open (info.FullName, Mono.Unix.Native.OpenFlags.O_RDONLY); if (mail_fd == -1) throw new IOException (String.Format ("Unable to read {0} for parsing mail", info.FullName)); GMime.StreamFs stream = new GMime.StreamFs (mail_fd); GMime.Parser parser = new GMime.Parser (stream); this.message = parser.ConstructMessage (); stream.Dispose (); parser.Dispose (); if (this.message == null) Error (); }