fio ~master

IO streams implemented from the ground up.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

:rotatinglight: **This library is unmaintained. Please see https://github.com/MartinNowak/io instead.** :rotatinglight:

IO Streams Build Status

This is a POSIX and Windows compatible IO stream library for D.

The primary purpose of this package is to provide a better API than what is currently available in the D standard library. Secondly, it is meant to be fast. All file operations are implemented using the low-level system calls provided by the operating system.

Features

  • File streams
  • Memory mapped files
  • Pipes
  • Temporary files
  • Generic stream buffering
  • Text serialization to streams

Examples

Sorting Lines

import io, std.array, std.algorithm;

void main()
{
    stdin
        .byLineCopy
        .array
        .sort()
        .each!println;
}

Temporary Files

import io;

void main()
{
    // Create a temporary file to write to. This returns the path to the file
    // and its file handle. The file is automatically deleted when the file
    // handle is closed. The file handle is closed when it falls out of scope.
    auto temp = tempFile();

    // Print to standard output.
    println("Temporary file path: ", temp.path);

    // Write an arbitrary array to the stream.
    temp.file.write("Hello world!");

    // Seek to the beginning.
    temp.file.position = 0;

    // Read in 5 characters.
    char[5] buf;
    temp.file.read(buf);
    assert(buf == "Hello");
}

Memory Maps

import io;
import std.parallelism, std.random;

void main()
{
    // Creates a 1 GiB file
    auto f = File("big_random_file", FileFlags.writeNew);
    f.length = 1024^^3; // 1 GiB

    // Fill the file with random data using a memory map.
    auto map = f.memoryMap!size_t(Access.write);
    foreach (i, ref e; parallel(map[]))
        e = uniform!"[]"(size_t.min, size_t.max);
}

Documentation

Documentation can be found here.

License

Boost license

Authors:
  • Jason White
Dependencies:
none
Versions:
0.0.9 2018-Nov-14
~master 2018-Nov-14
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 30 downloads total

Score:
1.8
Short URL:
fio.dub.pm