Add operations for extended attributes
This commit is contained in:
parent
ecc35f94f6
commit
9c2bf35bd2
4
index.js
4
index.js
@ -18,6 +18,10 @@ const ops = {
|
||||
rename: require('./ops/rename'),
|
||||
write: require('./ops/write'),
|
||||
flush: require('./ops/flush'),
|
||||
getxattr: require('./ops/getxattr'),
|
||||
setxattr: require('./ops/setxattr'),
|
||||
removexattr: require('./ops/removexattr'),
|
||||
listxattr: require('./ops/listxattr'),
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
|
25
ops/getxattr.js
Normal file
25
ops/getxattr.js
Normal file
@ -0,0 +1,25 @@
|
||||
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'))
|
||||
})
|
||||
)
|
||||
}
|
19
ops/listxattr.js
Normal file
19
ops/listxattr.js
Normal file
@ -0,0 +1,19 @@
|
||||
const Fuse = require('fuse-native')
|
||||
const Errors = require('../../shared/Errors')
|
||||
const Message = require('../../shared/Message')
|
||||
const connector = require('../connector')
|
||||
|
||||
module.exports = exports = function (path, name, cb) {
|
||||
connector.send(
|
||||
Message.route('fs.xattr.list')
|
||||
.data({ path, name })
|
||||
.expect_response(msg => {
|
||||
if ( msg.error() ) {
|
||||
return Errors.toCallback(cb, msg.error())
|
||||
}
|
||||
|
||||
const { names } = msg.data()
|
||||
return process.nextTick(cb, 0, names)
|
||||
})
|
||||
)
|
||||
}
|
18
ops/removexattr.js
Normal file
18
ops/removexattr.js
Normal file
@ -0,0 +1,18 @@
|
||||
const Fuse = require('fuse-native')
|
||||
const Errors = require('../../shared/Errors')
|
||||
const Message = require('../../shared/Message')
|
||||
const connector = require('../connector')
|
||||
|
||||
module.exports = exports = function (path, name, cb) {
|
||||
connector.send(
|
||||
Message.route('fs.xattr.remove')
|
||||
.data({ path, name })
|
||||
.expect_response(msg => {
|
||||
if ( msg.error() ) {
|
||||
return Errors.toCallback(cb, msg.error())
|
||||
}
|
||||
|
||||
return process.nextTick(cb, 0)
|
||||
})
|
||||
)
|
||||
}
|
22
ops/setxattr.js
Normal file
22
ops/setxattr.js
Normal file
@ -0,0 +1,22 @@
|
||||
const Fuse = require('fuse-native')
|
||||
const Errors = require('../../shared/Errors')
|
||||
const Message = require('../../shared/Message')
|
||||
const connector = require('../connector')
|
||||
|
||||
module.exports = exports = function (path, name, value, position, flags, cb) {
|
||||
connector.send(
|
||||
Message.route('fs.xattr.set')
|
||||
.data({
|
||||
path,
|
||||
name,
|
||||
value: value.toString('base64'), // value is a Buffer of binary data
|
||||
})
|
||||
.expect_response(msg => {
|
||||
if ( msg.error() ) {
|
||||
return Errors.toCallback(cb, msg.error())
|
||||
}
|
||||
|
||||
return process.nextTick(cb, 0)
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user