2016-03-14 02:50:14 +00:00
|
|
|
"use strict";
|
|
|
|
/// <reference path="./typings/main.d.ts" />
|
|
|
|
var plugins = require("./smartfile.plugins");
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param filePath
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
exports.fileExistsSync = function (filePath) {
|
|
|
|
var fileExistsBool = false;
|
|
|
|
try {
|
|
|
|
plugins.fs.readFileSync(filePath);
|
|
|
|
fileExistsBool = true;
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
fileExistsBool = false;
|
|
|
|
}
|
|
|
|
return fileExistsBool;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param filePath
|
|
|
|
* @returns {any}
|
|
|
|
*/
|
|
|
|
exports.fileExists = function (filePath) {
|
|
|
|
var done = plugins.q.defer();
|
|
|
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
|
|
|
err ? done.reject() : done.resolve();
|
|
|
|
});
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-03-20 23:28:29 +00:00
|
|
|
exports.isDirectory = function (pathArg) {
|
|
|
|
return plugins.fs.statSync(pathArg).isDirectory();
|
|
|
|
};
|
|
|
|
exports.isFile = function (pathArg) {
|
|
|
|
return plugins.fs.statSync(pathArg).isFile();
|
|
|
|
};
|
2016-03-14 02:50:14 +00:00
|
|
|
|
2016-05-01 21:19:54 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5jaGVja3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBRWhEOzs7O0dBSUc7QUFDUSxzQkFBYyxHQUFHLFVBQVMsUUFBUTtJQUN6QyxJQUFJLGNBQWMsR0FBVyxLQUFLLENBQUM7SU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