Link | file->setattr |
Author | Ke Carlton |
Category | File |
Version | 9.x |
License | Public Domain |
Posted | 09 Jul 2013 |
Updated | 09 Jul 2013 |
More by this author... |
local(f) = file('///tmp/myfile.txt') #f->setattr('user.checksum'='xyz','user.example'='abc') #f->getattr('user.checksum') // xyz
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
/* --------------------------------------------------------------- // // Extended file attributes // // Reference: http://en.wikipedia.org/wiki/Extended_file_attributes */ define file->setattr(name::string,value::string,silent::boolean=true) => { // Linux / OSX only, adjust setfattr path accordingly // Namespaces: user, trusted, security and system // Example usage: file->setattr('user.checksum','xyz') local( p = sys_process('/usr/bin/setfattr',staticarray('-n',#name,'-v',#value,file_forceroot(.path)->replace('//','/')&))->wait &, e = #p->readerror, s = #p->readstring ) handle => {#p->close} not #silent && #e ? fail(-1,#e->asstring) return #s } define file->setattr(p::pair,...) => { // Example usage: file->setattr('user.checksum'='xyz','user.example'='abc') .setattr(#p->name,#p->value) with p in #rest do { #p->isa(::pair) ? .setattr(#p->name,#p->value) } }
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft