Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const get = (path, callback) =>
{
fswin.getAttributes(path, result =>
{
if (result === null)
{
// fswin does not return an error -- problem could be ENOENT,EPERM,etc
callback( new Error("unknown error") );
return;
}
let attrs = {};
for (let i in result)
{
if (i.startsWith("IS_"))
{
attrs[i] = result[i];
}
const setSync = (path, attrs) =>
{
const success = fswin.setAttributesSync( path, convertAttrs.to(attrs) );
if (success === false)
{
// fswin does not return an error -- problem could be ENOENT,EPERM,etc
throw new Error("unknown erorr");
}
};
const getSync = path =>
{
const result = fswin.getAttributesSync(path);
if (result === null)
{
// fswin does not return an error -- problem could be ENOENT,EPERM,etc
throw new Error("unknown erorr");
}
return convertAttrs.from(result);
};
const set = (path, attrs, callback) =>
{
fswin.setAttributes(path, convertAttrs.to(attrs), success =>
{
// fswin does not return an error -- problem could be ENOENT,EPERM,etc
callback( success===true ? null : new Error("unknown error") );
});
};
return new Promise((resolve, reject) => {
fswin.getAttributes(pathToItem, result => {
if (!result) {
reject(`Could not retrieve attributes for ${pathToItem}`);
}
const attributes: IAttributes = {
hidden: result!.IS_HIDDEN
};
resolve(attributes);
});
});
}
deps.map(dep =>
fswin.setAttributesSync(dep.path, {IS_HIDDEN: hidden}) ?
Promise.resolve(Object.assign(dep, {hidden})) :
Promise.reject(new Error(`Failed to modify dir attr: ${dep.path}`))
)