/*
     * Creates a fake bin in incoming directory
     */
    public void GenerateBin(string name, long size, int nSlices)
    {
        string binPath = ExplodedPrefs.IncomingBin(name);
        string cloudPath = ExplodedPrefs.IncomingCloud(name);

        if (!Directory.Exists(ExplodedPrefs.IncomingPath)) {
            Directory.CreateDirectory(ExplodedPrefs.IncomingPath);
        }

        using( FileStream fs = new FileStream( binPath, FileMode.Create ) ) {

            Vector3 scale = 2.0f * Vector3.one + Random.insideUnitSphere;

            CloudStream.Writer writer = new CloudStream.Writer(fs);
            for(int i = 0; i<size; ++i) {
                Vector3 v = Random.insideUnitSphere;

                v.x *= scale.x;
                v.y *= scale.y;
                v.z *= scale.z;

                Color c = RandomExt.color;
                writer.WritePoint(v, c);
            }
        }

        using( StreamWriter writer = new StreamWriter(cloudPath) ) {
            writer.WriteLine(binPath);
            long sliceSize = size / nSlices;
            for(int i = 0; i<nSlices; i ++) {
                writer.WriteLine(string.Format("{0}\t{1}\t{2}",
                                               i,
                                               i * sliceSize,
                                               // the last slice may be larger
                                               (i==nSlices-1)? size - i*sliceSize : sliceSize ));
            }
        }
    }
Beispiel #2
0
 public WriterTest()
 {
     writer = new CloudStream.Writer( TmpFileStream(FileMode.Truncate) );
     Assert_Equal(0, writer.BaseStream.Length);
     foreach(ColoredPoint cp in mockCloud) {
         writer.WritePoint(cp.v, cp.c);
     }
 }