<commit_before># File System

This interface describes the filesystem interface used in the js-git project.

All examples use `yield` to consume [continuables][], assuming generators with [gen-run][] wrapping, but can be used with ES5 code as well.  Streams are in [simple-stream][] format.

```js
// ES6 syntax
var target = yield fs.readlink("/path/to/symlink");

// ES5 syntax
fs.readlink("/path/to/symlink")(function (err, target) {
  if (err) throw err;
  // do something with target
});
```

## stat(path) -> continuable&lt;stat>

Stat a file getting mtime, ctime, size, mode, etc as a JS object with the following structure:

  - ctime [seconds, nanoseconds]
  - mtime [seconds, nanoseconds]
  - dev
  - ino
  - mode 1000,1010,1110 | 0755,0644
  - uid
  - gid
  - size

```js
var stat = yield fs.stat("/path/to/my/file.txt");
```

## read(path, [encoding]) -> continuable<binary_or_string>

Read a file as a single string or binary buffer

## write(path, value, [encoding]) -> continuable

Write a file as a single string or binary buffer

## readStream(path, [options]) -> stream&lt;binary>

Open a file by path for reading and return a simple-stream.

  - options.start - start at offset
  - options.end - end at offset

```js
var input = fs.readStream("/path/to/my/file.txt");
```

## writeStream(path, [options]) -> sink -> continuable

Create a simple-stream sink that saves the stream to disk.

  - options.mode - create file with custom mode (base 8 string or integer)

```js
var save = fs.writeStream("/path/to/output.txt");
console.log("Saving input to disk...");
yield save(input);
console.log("Saved");
```

## unlink(path) -> continuable

Delete a file from working directory by path.  returns a continuable.

```js
yield fs.unlink("/file/i/want/to/delete.log");
```

## readlink(path) -> continuable&lt;target>

Read a symlink and give the string it points to.

```js
var target = yield fs.readlink("/path/to/symlink");
```

## symlink(path, target) -> continuable

Create a symlink at path with given target.

```js
yield fs.symlink("/path.to/symlink", "../target");
```

## readdir(path) -> stream&lt;name>

Returns a stream of filenames in the target path.

```js
var nameStream = fs.readdir("..");
```

## rmdir(path) -> continuable

Delete a directory.

```js
yield fs.rmdir("/directory/to/kill");
```

## mkdir(path) -> continuable

Create a directory

```js
yield fs.mkdir("/path/to/create");
```

## rename(old, new) -> continuable

Rename a file or directory.

```js
yield fs.rename("/.git/1ae5mir17t298lcu.tmp", ".git/objects/e7/aecb2c038b16c2ef544b1413d41cbe40aa514d");
```

## Chroot Capabilities

The exports object is also itself a chroot function.  This returns a new version of the fs with a path prefix added.

```js
var fs = require('my-fs-implementation')('/home/tim/Code/js-git');
var metaFs = fs(".git");
// fs now points to the working tree and metaFs points to the .git folder inside it.
```

# Concrete Implementations

 - [simple-fs](https://github.com/creationix/simple-fs) - Implementation for Node.JS

[gen-run]: https://github.com/creationix/gen-run
[continuables]: https://github.com/creationix/js-git/blob/master/specs/continuable.md
[simple-stream]: https://github.com/creationix/js-git/blob/master/specs/simple-stream.md
<commit_msg>Update fs spec to return continuables for everything.<commit_after># File System

This interface describes the filesystem interface used in the js-git project.

All examples use `yield` to consume [continuables][], assuming generators with [gen-run][] wrapping, but can be used with ES5 code as well.  Streams are in [simple-stream][] format.

```js
// ES6 syntax
var target = yield fs.readlink("/path/to/symlink");

// ES5 syntax
fs.readlink("/path/to/symlink")(function (err, target) {
  if (err) throw err;
  // do something with target
});
```

## stat(path) -> continuable&lt;stat>

Stat a file getting mtime, ctime, size, mode, etc as a JS object with the following structure:

  - ctime [seconds, nanoseconds]
  - mtime [seconds, nanoseconds]
  - dev
  - ino
  - mode 1000,1010,1110 | 0755,0644
  - uid
  - gid
  - size

```js
var stat = yield fs.stat("/path/to/my/file.txt");
```

## read(path, [encoding]) -> continuable<binary_or_string>

Read a file as a single string or binary buffer

## write(path, value, [encoding]) -> continuable

Write a file as a single string or binary buffer

## readStream(path, [options]) -> continuable&lt;stream>

Open a file by path for reading and return a simple-stream.

  - options.start - start at offset
  - options.end - end at offset

```js
var input = yield fs.readStream("/path/to/my/file.txt");
```

## writeStream(path, [options]) -> continuable&lt;sink>

Create a simple-stream sink that saves the stream to disk.

  - options.mode - create file with custom mode (base 8 string or integer)

```js
var save = yield fs.writeStream("/path/to/output.txt");
console.log("Saving input to disk...");
yield save(input);
console.log("Saved");
```

## unlink(path) -> continuable

Delete a file from working directory by path.  returns a continuable.

```js
yield fs.unlink("/file/i/want/to/delete.log");
```

## readlink(path) -> continuable&lt;target>

Read a symlink and give the string it points to.

```js
var target = yield fs.readlink("/path/to/symlink");
```

## symlink(path, target) -> continuable

Create a symlink at path with given target.

```js
yield fs.symlink("/path.to/symlink", "../target");
```

## readdir(path) -> continuable&lt;<stream>

Returns a stream of filenames in the target path.

```js
var nameStream = yield fs.readdir("..");
```

## rmdir(path) -> continuable

Delete a directory.

```js
yield fs.rmdir("/directory/to/kill");
```

## mkdir(path) -> continuable

Create a directory

```js
yield fs.mkdir("/path/to/create");
```

## rename(old, new) -> continuable

Rename a file or directory.

```js
yield fs.rename("/.git/1ae5mir17t298lcu.tmp", ".git/objects/e7/aecb2c038b16c2ef544b1413d41cbe40aa514d");
```

## Chroot Capabilities

The exports object is also itself a chroot function.  This returns a new version of the fs with a path prefix added.

```js
var fs = require('my-fs-implementation')('/home/tim/Code/js-git');
var metaFs = fs(".git");
// fs now points to the working tree and metaFs points to the .git folder inside it.
```

# Concrete Implementations

 - [simple-fs](https://github.com/creationix/simple-fs) - Implementation for Node.JS

[gen-run]: https://github.com/creationix/gen-run
[continuables]: https://github.com/creationix/js-git/blob/master/specs/continuable.md
[simple-stream]: https://github.com/creationix/js-git/blob/master/specs/simple-stream.md

{'fraction_non_alphanumeric': 0.15281541704305932, 'fraction_numerical': 0.015959048479373683, 'mean_word_length': 3.99849510910459, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 39, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6455697', 'n_tokens_mistral': 2331, 'n_tokens_neox': 2179, 'n_words': 683}