Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (process.platform !== 'linux') {
return Promise.reject(new Error('Only Linux systems are supported'));
}
if (!filePath) {
return Promise.resolve(path.join(xdgBasedir.data, 'Trash'));
}
const [homeMountPoint, fileMountPoint] = await Promise.all([
mountPoint(userHome),
// Ignore errors in case `file` is a dangling symlink
mountPoint(filePath).catch(() => {})
]);
if (!fileMountPoint || fileMountPoint === homeMountPoint) {
return path.join(xdgBasedir.data, 'Trash');
}
return check(path.join(fileMountPoint, '.Trash'));
};
const os = require('os');
const mkdirp = require('mkdirp');
const path = require('path');
const fs = require('fs');
const splitFile = require('split-file');
const async = require('async');
const xdgBasedir = require('xdg-basedir');
const md5File = require('md5-file');
const request = require('request');
const send = require('send');
const configDir = path.join(xdgBasedir.config || path.join(os.tmpdir(), '.config'), 'freeshare');
const storeDir = path.join(xdgBasedir.data || path.join(os.tmpdir(), '.local'), 'free-share-store');
let instance = null;
class FileStore {
constructor() {
if (!instance) {
instance = this;
}
return instance;
}
init() {
this.fileMap = new Map();
return new Promise((resolve, reject) => {
function exportToFile (exportFilepath, printToConsole) {
var fs = require('fs');
var xdgBasedir = require('xdg-basedir');
var logSymbols = require('log-symbols');
var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv';
var contents = fs.readFileSync(expensesFilepath);
var prettyDate = require('date-format').asString('yyyy-MM-dd', new Date());
var defaultExportFilepath = xdgBasedir.data +
'/wallet/exported/export-' +
prettyDate + '.csv';
exportFilepath = exportFilepath || defaultExportFilepath;
fs.writeFileSync(exportFilepath, 'Date,Remarks,Category,Credit,Debit\n');
fs.appendFileSync(exportFilepath, contents);
if (printToConsole === undefined) {
console.log();
console.log(logSymbols.success + ' Your file can be found at :-');
function writeExpense (expenseObjectParam) {
var xdgBasedir = require('xdg-basedir');
var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv';
var fs = require('fs');
var logSymbols = require('log-symbols');
var prettyDate = require('date-format').asString('yyyy-MM-dd', new Date());
var record = [
prettyDate,
expenseObjectParam.reason,
expenseObjectParam.category,
expenseObjectParam.credit,
expenseObjectParam.debit
].join(delimiter);
fs.appendFile(expensesFilepath, record + '\n', function (err) {
if (err) {
throw (err);
} else {
function getBalance (cb) {
var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv';
var stream = fs.createReadStream(expensesFilepath);
var totalCredit = 0.0;
var totalDebit = 0.0;
csv
.fromStream(stream)
.transform(function (data) {
return {
'date': data[0],
'reason': data[1],
'category': data[2],
'credit': numberIsNan(parseFloat(data[3])) ? 0.0 : parseFloat(data[3]),
'debit': numberIsNan(parseFloat(data[4])) ? 0.0 : parseFloat(data[4])
};
})
function createFileIfDoesNotExist (filepath) {
var touch = require('touch');
var xdg = require('xdg-basedir');
var mkdirp = require('mkdirp');
filepath = filepath || (xdg.data + '/wallet/expenses.csv');
mkdirp.sync(xdg.data + '/wallet/exported');
mkdirp.sync(xdg.data + '/wallet/closed');
touch.sync(xdg.data + '/wallet/expenses.csv');
}
var xdg = require('xdg-basedir');
exports.LOCAL_FILE_PATH = xdg.data + '/cube/times.csv';
exports.PUSHED_FILE_PATH = xdg.data + '/cube/pushed.csv';
var xdg = require('xdg-basedir');
exports.LOCAL_FILE_PATH = xdg.data + '/cube/times.csv';
exports.PUSHED_FILE_PATH = xdg.data + '/cube/pushed.csv';
const stickyBitMode = 17407;
try {
const stats = await fs.lstat(filePath);
if (stats.isSymbolicLink() || stats.mode !== stickyBitMode) {
return topuid;
}
return path.join(filePath, String(process.getuid()));
} catch (error) {
if (error.code === 'ENOENT') {
return topuid;
}
return path.join(xdgBasedir.data, 'Trash');
}
};
get globalDir() {
return Fs.join(xdgBaseDir.data, '.gtt');
}