How to use the fs-xattr.get function in fs-xattr

To help you get started, we’ve selected a few fs-xattr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github viddo / atom-textual-velocity / lib / service-consumers / NVTags.js View on Github external
read: function(path, stats, callback) {
        if (!xattr)
          return callback(
            new Error(
              "xattr no longer available, probably due to package being deactivated while in transit"
            )
          );

        xattr.get(path, XATTR_KEY, function(err, plistBuf) {
          if (err) {
            if (err.code === "ENOATTR") {
              callback(null, null); // no xattrs set; return empty list
            } else {
              callback(err); // e.g. file path does not exist or such
            }
          } else {
            bplist.parseBuffer(plistBuf, function(err, list) {
              if (err) {
                callback(err);
              } else {
                callback(null, list[0]);
              }
            });
          }
        });
github wisnuc / appifi / testpic / a.js View on Github external
import fs from 'fs';
import xattr from 'fs-xattr';


let target = '/home/laraine/Projects/appifi/testpic/20141213.jpg'
xattr.get(target, 'user.fruitmix', (err, attr) => {
  console.log(JSON.parse(attr))
  console.log(JSON.parse(attr).hasOwnProperty('uuid'))
  console.log(JSON.parse(attr).hasOwnProperty('hash'))
  console.log(JSON.parse(attr).hasOwnProperty('htime'))
  console.log(JSON.parse(attr).hasOwnProperty('hash') === JSON.parse(attr).hasOwnProperty('htime'))
})
github wisnuc / appifi / test / unit / vfs / underlying-clone.js View on Github external
clone('tmptest/a/b', stats.uuid, 'tmptest/c/d', (err, xstat) => {
      if (err) return done(err)
      xattr.get('tmptest/c/d', 'user.fruitmix', err => {
        expect(err.code).to.equal('ENODATA')
        done()
      })
    })
  })
github wisnuc / appifi / test / fruitmix / unit / file / xstat.js View on Github external
readXstat(picpath, (err, xstat) => {
            if(err) return done(err)
            xattr.get(picpath, FRUITMIX, (err, attr) => {
              if(err) return done(err)
              let attrObj = JSON.parse(attr)
              expect(attrObj.htime).to.equal(stats.mtime.getTime())

              expect(xstat.uuid).to.deep.equal(uuid_1)
              expect(xstat.isFile()).to.be.true
              expect(xstat.writelist).to.be.an('undefined')
              expect(xstat.readlist).to.be.an('undefined')
              expect(xstat.hash).to.deep.equal(hash_1)
              expect(xstat.htime).to.be.an('undefined')
              expect(xstat.magic).to.deep.equal('JPEG')
              expect(xstat.abspath).to.deep.equal(picpath)
              done()
            })
          })
        })
github wisnuc / appifi / test / fruitmix / unit / file / xstat.js View on Github external
copyXattr(copypath, filepath, err => {
        if(err) return done(err)
        xattr.get(copypath, FRUITMIX, (err, attr) => {
          if(err) return done(err)
          let attrObj = JSON.parse(attr)
          expect(attrObj.uuid).to.deep.equal(uuid_1)
          expect(attrObj.hash).to.deep.equal(hash_1)
          done()
        })
      })
    })
github wisnuc / appifi / src / fruitmix / cluster / lib / filemap.js View on Github external
const readFileMap = (userUUID, taskId, callback) => {
  let fpath = path.join(paths.get('filemap'), userUUID, taskId)
  if(fs.existsSync(fpath)){
    xattr.get(fpath, FILEMAP, (err, attr) => {
      if(err) return callback(err)
      try{
        return callback(null, Object.assign({}, JSON.parse(attr), {taskid: taskId}))
      }catch(e){
        callback(e)
      }
    })
  }else
    return callback(new Error('filemap not find'))
}

fs-xattr

Node.js module for manipulating extended attributes.

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Similar packages