Fix a potential crash in html parsing code. How come it was never reported ?
[beagle.git] / bludgeon / FileObject.cs
blob1bad915eff096de1b438d7e95a555e530a24d7ae
2 using System;
3 using System.Collections;
4 using System.IO;
6 using Mono.Unix.Native;
8 using Beagle.Util;
9 using Beagle;
11 namespace Bludgeon {
13 abstract public class FileObject : FileSystemObject {
15 public FileObject ()
17 timestamp = FileSystemObject.PickTimestamp ();
20 abstract public void AddToStream (Stream stream, EventTracker tracker);
22 override public void AddOnDisk (EventTracker tracker)
24 FileStream stream;
25 stream = new FileStream (FullName,
26 FileMode.Create,
27 FileAccess.Write,
28 FileShare.ReadWrite);
29 AddToStream (stream, tracker);
30 stream.Close ();
32 // Stamp the right timestamp onto the file
33 FileInfo info;
34 info = new FileInfo (FullName);
35 info.LastWriteTime = Timestamp;
38 override public void DeleteOnDisk (EventTracker tracker)
40 Syscall.unlink (FullName);
41 // FIXME: adjust tracker
44 override public void MoveOnDisk (string old_full_name, EventTracker tracker)
46 Syscall.rename (old_full_name, FullName);
47 // FIXME: adjust tracker
50 override public bool VerifyOnDisk ()
52 if (! File.Exists (FullName)) {
53 Log.Failure ("Missing file '{0}'", FullName);
54 return false;
56 return true;