2016-05-23 06:15:47 +00:00
|
|
|
import "typings-global";
|
2016-03-14 02:50:14 +00:00
|
|
|
import plugins = require("./smartfile.plugins");
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param filePath
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export let fileExistsSync = function(filePath):boolean {
|
|
|
|
let fileExistsBool:boolean = false;
|
|
|
|
try {
|
|
|
|
plugins.fs.readFileSync(filePath);
|
|
|
|
fileExistsBool = true
|
|
|
|
}
|
|
|
|
catch(err){
|
|
|
|
fileExistsBool = false;
|
|
|
|
}
|
|
|
|
return fileExistsBool;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param filePath
|
|
|
|
* @returns {any}
|
|
|
|
*/
|
|
|
|
export let fileExists = function(filePath){
|
|
|
|
let 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
|
|
|
|
|
|
|
export let isDirectory = function(pathArg):boolean{
|
|
|
|
return plugins.fs.statSync(pathArg).isDirectory();
|
|
|
|
};
|
|
|
|
|
|
|
|
export let isFile = function(pathArg):boolean{
|
|
|
|
return plugins.fs.statSync(pathArg).isFile();
|
|
|
|
};
|