Modules (188)

ExtractFileContent

Description

Dependencies

Functions

Private

_readFile

Extract content locally from the file system used fs.readFile()

fileName String
fullpath of the document
callback Function
callback handle to post the content back
function _readFile(fileName, callback) {
    fs.readFile(fileName, "utf8", function (err, data) {
        var content = "";
        if (!err) {
            content = data;
        }
        callback.apply(null, [fileName, content]);
    });
}

clearDirtyFilesCache

Clears the cache for dirty file paths

function clearDirtyFilesCache() {
    _dirtyFilesCache = {};
}
Public API

extractContent

Extracts file content for the given file name(1st param) and invokes the callback handle(2nd param) with extracted file content. Content can be extracted locally from the file system used fs.readFile() or conditionally from main context(brackets main thread) by using the 3rd param

fileName String
fullpath of the document
callback Function
callback handle to post the content back
extractFromMainContext Object
content request handle wrapper from main thread
function extractContent(fileName, callback, extractFromMainContext) {
    // Ask the main thread context to provide the updated file content
    // We can't yet use node io to read, to utilize shells encoding detection
    extractFromMainContext.apply(null, [fileName]);
}

exports.extractContent = extractContent;
exports.clearFilesCache = clearDirtyFilesCache;
exports.updateFilesCache = updateDirtyFilesCache;

updateDirtyFilesCache

Updates the files cache with fullpath when dirty flag changes for a document If the doc is being marked as dirty then an entry is created in the cache If the doc is being marked as clean then the corresponsing entry gets cleared from cache

name String
fullpath of the document
action boolean
whether the document is dirty
function updateDirtyFilesCache(name, action) {
    if (action) {
        _dirtyFilesCache[name] = true;
    } else {
        if (_dirtyFilesCache[name]) {
            delete _dirtyFilesCache[name];
        }
    }
}