<commit_before>var path = require('path'),
    fs = require('fs'),
    util = require('util');

function WorkingDirectory(directory) {
    this.cwd = path.resolve(directory);
}

WorkingDirectory.prototype.mkdir = function (userPath, mode, callback) {
    if (typeof userPath !== "string") throw new Error("path must be a string");
    userPath = path.resolve(this.cwd, userPath);
    if (typeof mode === "function") {
        callback = mode;
        mode = 0777 & (~process.umask());
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof mode !== "number") {
        mode = 0777 & (~process.umask());
    } else {
        mode = mode & (~process.umask());
    }
    function cb(err) {
        if (err) return callback(err);
        return callback(null, new WorkingDirectory(userPath));
    }
    fs.mkdir(userPath, mode, cb);
};

WorkingDirectory.prototype.rmdir = function(userPath, callback) {
    if (typeof userPath !== "string") throw new Error("path must be a string");
    userPath = path.resolve(this.cwd, userPath);
    if (typeof callback !== "function") throw new Error("callback must be a function");
    fs.rmdir(userPath, function (err) {
        if (err) return callback(err);
        return callback(null);
    });
};

WorkingDirectory.prototype.readFile = function(fileName, options, callback) {
    if (typeof fileName !== "string") throw new Error("path must be a string");
    fileName = path.resolve(this.cwd, fileName);
    if (typeof options === "function") {
        callback = options;
        options = {};
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof options !== "object") {
        throw new Error("options must be an object");
    } else {
        options = {};
    }
    function cb(err, data) {
        if (err) return callback(err);
        return callback(null, data);
    }
    fs.readFile(fileName, options, cb);
};

WorkingDirectory.prototype.writeFile = function(fileName, data, options, callback) {
    if (typeof fileName !== "string") throw new Error("path must be a string");
    fileName = path.resolve(this.cwd, fileName);
    if (typeof options === "function") {
        callback = options;
        options = {};
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof options !== "object") {
        throw new Error("options must be an object");
    } else {
        options = {};
    }
    function cb(err, data) {
        if (err) return callback(err);
        return callback(null, data);
    }
    fs.writeFile(fileName, data, options, cb);
};

module.exports = WorkingDirectory;<commit_msg>Add appendFile functionality<commit_after>var path = require('path'),
    fs = require('fs'),
    util = require('util');

function WorkingDirectory(directory) {
    this.cwd = path.resolve(directory);
}

WorkingDirectory.prototype.mkdir = function (userPath, mode, callback) {
    if (typeof userPath !== "string") throw new Error("path must be a string");
    userPath = path.resolve(this.cwd, userPath);
    if (typeof mode === "function") {
        callback = mode;
        mode = 0777 & (~process.umask());
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof mode !== "number") {
        mode = 0777 & (~process.umask());
    } else {
        mode = mode & (~process.umask());
    }
    function cb(err) {
        if (err) return callback(err);
        return callback(null, new WorkingDirectory(userPath));
    }
    fs.mkdir(userPath, mode, cb);
};

WorkingDirectory.prototype.rmdir = function(userPath, callback) {
    if (typeof userPath !== "string") throw new Error("path must be a string");
    userPath = path.resolve(this.cwd, userPath);
    if (typeof callback !== "function") throw new Error("callback must be a function");
    fs.rmdir(userPath, function (err) {
        if (err) return callback(err);
        return callback(null);
    });
};

WorkingDirectory.prototype.readFile = function(fileName, options, callback) {
    if (typeof fileName !== "string") throw new Error("path must be a string");
    fileName = path.resolve(this.cwd, fileName);
    if (typeof options === "function") {
        callback = options;
        options = {};
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof options !== "object") {
        throw new Error("options must be an object");
    } else {
        options = {};
    }
    function cb(err, data) {
        if (err) return callback(err);
        return callback(null, data);
    }
    fs.readFile(fileName, options, cb);
};

WorkingDirectory.prototype.writeFile = function(fileName, data, options, callback) {
    if (typeof fileName !== "string") throw new Error("path must be a string");
    fileName = path.resolve(this.cwd, fileName);
    if (typeof options === "function") {
        callback = options;
        options = {};
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof options !== "object") {
        throw new Error("options must be an object");
    } else {
        options = {};
    }
    function cb(err, data) {
        if (err) return callback(err);
        return callback(null, data);
    }
    fs.writeFile(fileName, data, options, cb);
};

WorkingDirectory.prototype.appendFile = function(fileName, data, options, callback) {
    if (typeof fileName !== "string") throw new Error("path must be a string");
    fileName = path.resolve(this.cwd, fileName);
    if (typeof options === "function") {
        callback = options;
        options = {};
    } else if (typeof callback !== "function") {
        throw new Error("callback must be a function");
    } else if (typeof options !== "object") {
        throw new Error("options must be an object");
    } else {
        options = {};
    }
    function cb(err, data) {
        if (err) return callback(err);
        return callback(null, data);
    }
    fs.appendFile(fileName, data, options, cb);
};

module.exports = WorkingDirectory;
{'fraction_non_alphanumeric': 0.14427066709224384, 'fraction_numerical': 0.0025534631343759975, 'mean_word_length': 2.9415094339622643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4831330', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1754, 'n_words': 557}