HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/@akryum/winattr/lib/binding/index.js
'use strict'
const fswin = require('fswin')

const convertAttrs = require('./convertAttrs')

function get (path, callback) {
  fswin.getAttributes(path, function (result) {
    if (result === undefined) {
      // 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.indexOf('IS_') === 0) {
        attrs[i] = result[i]
      }
    }

    callback(null, convertAttrs.from(attrs))
  })
}

function getSync (path) {
  const result = fswin.getAttributesSync(path)

  if (result === undefined) {
    // fswin does not return an error -- problem could be ENOENT,EPERM,etc
    throw new Error('unknown erorr')
  }

  return convertAttrs.from(result)
}

function set (path, attrs, callback) {
  fswin.setAttributes(path, convertAttrs.to(attrs), function (success) {
    // fswin does not return an error -- problem could be ENOENT,EPERM,etc
    callback(success === true ? null : new Error('unknown error'))
  })
}

function 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')
  }
}

module.exports = {
  get,
  getSync,
  set,
  setSync,
}