Extract content locally from the file system used fs.readFile()
function _readFile(fileName, callback) {
fs.readFile(fileName, "utf8", function (err, data) {
var content = "";
if (!err) {
content = data;
}
callback.apply(null, [fileName, content]);
});
}
Clears the cache for dirty file paths
function clearDirtyFilesCache() {
_dirtyFilesCache = {};
}
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
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;
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
function updateDirtyFilesCache(name, action) {
if (action) {
_dirtyFilesCache[name] = true;
} else {
if (_dirtyFilesCache[name]) {
delete _dirtyFilesCache[name];
}
}
}