2016-05-19 22:31:53 +00:00
|
|
|
/// <reference path="./typings/index.d.ts" />
|
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();
|
|
|
|
};
|