1 /******************************************************************************* 2 3 Copyright: 4 Copyright (c) 2007 Kris Bell. 5 Some parts copyright (c) 2009-2016 dunnhumby Germany GmbH. 6 All rights reserved. 7 8 License: 9 Tango Dual License: 3-Clause BSD License / Academic Free License v3.0. 10 See LICENSE_TANGO.txt for details. 11 12 Version: Initial release: Nov 2007 13 14 Authors: Kris 15 16 *******************************************************************************/ 17 18 module ocean.io.stream.DataFile; 19 20 import ocean.io.device.File; 21 22 import ocean.io.stream.Data; 23 24 /******************************************************************************* 25 26 Composes a seekable file with buffered binary input. A seek causes 27 the input buffer to be cleared. 28 29 *******************************************************************************/ 30 31 class DataFileInput : DataInput 32 { 33 private File conduit; 34 35 /*********************************************************************** 36 37 Compose a FileStream. 38 39 ***********************************************************************/ 40 41 this (char[] path, File.Style style = File.ReadExisting) 42 { 43 this (new File (path, style)); 44 } 45 46 /*********************************************************************** 47 48 Wrap a File instance. 49 50 ***********************************************************************/ 51 52 this (File file) 53 { 54 super (conduit = file); 55 } 56 57 /*********************************************************************** 58 59 Return the underlying conduit. 60 61 ***********************************************************************/ 62 63 final File file () 64 { 65 return conduit; 66 } 67 } 68 69 70 /******************************************************************************* 71 72 Composes a seekable file with buffered binary output. A seek causes 73 the output buffer to be flushed first. 74 75 *******************************************************************************/ 76 77 class DataFileOutput : DataOutput 78 { 79 private File conduit; 80 81 /*********************************************************************** 82 83 Compose a FileStream. 84 85 ***********************************************************************/ 86 87 this (char[] path, File.Style style = File.WriteCreate) 88 { 89 this (new File (path, style)); 90 } 91 92 /*********************************************************************** 93 94 Wrap a FileConduit instance. 95 96 ***********************************************************************/ 97 98 this (File file) 99 { 100 super (conduit = file); 101 } 102 103 /*********************************************************************** 104 105 Return the underlying conduit. 106 107 ***********************************************************************/ 108 109 final File file () 110 { 111 return conduit; 112 } 113 }