filePathService = angular.module('filePathService', []);
/**
* The filePathService provides an interface to find the paths of specific files on the computer. These files, so far, will survive through updates and re-installs.
*
* The data path is determined through the node.js expression:
*
* dataPath = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/' : process.env.HOME);
*
* @ngdoc service
* @memberof HCCGo
* @class filePathService
*/
filePathService.service('filePathService', function() {
var path = require('path');
/**
* Get the job history path. The job history is a nedb database.
* @method getJobHistory
* @memberof HCCGo.filePathService
* @return {String} Path to job history DB.
*/
var getJobHistory = function() {
return path.join(getDataPath(), 'jobHistory.db');
}
/**
* Get the data path where things can be stored through updates.
* @method getDataPath
* @memberof HCCGo.filePathService
* @return {String} Path to the data path on the computer.
*/
var getDataPath = function() {
var dataPath = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library' : process.env.HOME);
dataPath = path.join(dataPath, 'HCCGo');
return dataPath;
}
/**
* Get the submitted jobs DB. The submitted jobs is a nedb database.
* @method getSubmittedJobs
* @memberof HCCGo.filePathService
* @return {String} Path to the submitted jobs DB.
*/
var getSubmittedJobs = function() {
return path.join(getDataPath(), 'submittedJobs.db');
}
/**
* Get the preferences JSON filepath.
* @method getPreferences
* @memberof HCCGo.filePathService
* @return {String} Path to the preferences json file.
*/
var getPreferencePath = function() {
return path.join(getDataPath(), 'preferences.json');
}
return {
getJobHistory: getJobHistory,
getDataPath: getDataPath,
getSubmittedJobs: getSubmittedJobs,
getPreferencePath: getPreferencePath
}
});