Advertisement
Chronos_Ouroboros

Lump code

Feb 16th, 2018
3,375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.47 KB | None | 0 0
  1. /// Defines a class that contains file data.
  2. public class Lump {
  3.     protected string _path;
  4.     protected byte [] _data;
  5.  
  6.     @property string path () { return _path; }
  7.     protected @property void path (string val) { _path = val; }
  8.  
  9.     @property byte [] data () { return _data; }
  10.     protected @property void data (byte [] val) { _data = val; }
  11.  
  12.     // D doesn't have streams in Phobos. What the fuck, man.
  13.     //public System.IO.Stream asStream { get { return new System.IO.MemoryStream (Data, false); } }
  14.  
  15.     // No default constructor.
  16.     @disable this ();
  17.  
  18.     /**
  19.      * Defines a new lump.
  20.      *
  21.      * Params:
  22.      *     path = The path of the lump.
  23.      *     data = The lump's data.
  24.      *     dispose = Whether the input stream should be closed and disposed.
  25.     **/
  26.     /*public this (string path, System.IO.Stream data, bool dispose = false) {
  27.         _path = path;
  28.         _data = new byte [data.Length];
  29.  
  30.         if (data.Position != 0)
  31.             data.Seek (0, System.IO.SeekOrigin.Begin);
  32.  
  33.         data.Read (Data, 0, (int) data.Length);
  34.  
  35.         if (dispose) {
  36.             data.Close ();
  37.             data.Dispose ();
  38.         }
  39.  
  40.         data = null;
  41.     }*/
  42.  
  43.     /**
  44.      * Defines a new lump.
  45.      *
  46.      * Params:
  47.      *     path = The path of the lump.
  48.      *     data = The lump's data.
  49.     **/
  50.     public this (string path, byte [] data) {
  51.         _path = path;
  52.         _data [] = data [];
  53.  
  54.         data = null;
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement