client/ops/getxattr.js

26 lines
777 B
JavaScript

const Fuse = require('fuse-native')
const Errors = require('../../shared/Errors')
const Message = require('../../shared/Message')
const connector = require('../connector')
const { Buffer } = require('buffer')
module.exports = exports = function (path, name, position, cb) {
connector.send(
Message.route('fs.xattr.get')
.data({ path, name })
.expect_response(msg => {
if ( msg.error() ) {
return Errors.toCallback(cb, msg.error())
}
const { value } = msg.data()
if ( !value ) {
return process.nextTick(cb, 0, null)
}
return process.nextTick(cb, 0, Buffer.from(value, 'base64'))
})
)
}