Module: ExtAttr
- Defined in:
- lib/extattr.rb,
ext/extattr.c
Overview
Add operation methods of filesystem extended attributes to File.
名前空間の指定について
拡張属性の名前空間を指定する場合、以下の値が利用できます:
-
ExtAttr::USER, ExtAttr::SYSTEM
-
文字列又はシンボルで
user、system(大文字小文字を区別しません)
これらの値は内部で変換、または処理が分岐されます。
- extattr
-
整数値に変換されて処理されます。
- xattr
-
拡張属性名に “user.” または “system.” を追加して処理されます。
- Windows
-
ExtAttr::USER の場合は NTFS Alternative Data Stream (ADS) として処理されます。
ExtAttr::SYSTEM の場合は NTFS Extended Attribute (EA) として処理されます。
Defined Under Namespace
Classes: Accessor
Constant Summary collapse
- ExtAttr =
self- USER =
ID2SYM(rb_intern("user"))
- SYSTEM =
ID2SYM(rb_intern("system"))
Class Method Summary collapse
- .delete(path, namespace, name) ⇒ nil
- .delete!(path, namespace, name) ⇒ nil
-
.each(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq: each(path, namespace = ExtAttr::USER) -> Enumerator each(path, namespace = ExtAttr::USER) { |name| … } -> path.
-
.each!(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq: each!(path, namespace = ExtAttr::USER) -> Enumerator each!(path, namespace = ExtAttr::USER) { |name| … } -> path.
-
.each_pair(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq: each_pair(path, namespace = ExtAttr::USER) -> Enumerator each_pair(path, namespace = ExtAttr::USER) { |name, data| … } -> path.
-
.each_pair!(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq: each_pair!(path, namespace = ExtAttr::USER) -> Enumerator each_pair!(path, namespace = ExtAttr::USER) { |name, data| … } -> path.
- .get(path, namespace, name) ⇒ Object
- .get!(path, namespace, name) ⇒ Object
- .list(path, namespace) ⇒ Object
- .list!(path, namespace) ⇒ Object
- .open(path) ⇒ Object
- .set(path, namespace, name, data) ⇒ nil
- .set!(path, namespace, name, data) ⇒ nil
- .size(path, namespace, name) ⇒ Object
- .size!(path, namespace, name) ⇒ Object
Class Method Details
.delete(path, namespace, name) ⇒ nil
474 475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'ext/extattr.c', line 474
static VALUE
ext_s_delete(VALUE mod, VALUE path, VALUE namespace, VALUE name)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
return file_extattr_delete_main(path, file2fd(path), conv_namespace(namespace),
aux_should_be_string(name));
} else {
ext_check_path_security(path, name, Qnil);
return file_s_extattr_delete_main(aux_to_path(path), conv_namespace(namespace),
aux_should_be_string(name));
}
}
|
.delete!(path, namespace, name) ⇒ nil
492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'ext/extattr.c', line 492
static VALUE
ext_s_delete_link(VALUE mod, VALUE path, VALUE namespace, VALUE name)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
return file_extattr_delete_main(path, file2fd(path), conv_namespace(namespace),
aux_should_be_string(name));
} else {
ext_check_path_security(path, name, Qnil);
return file_s_extattr_delete_link_main(aux_to_path(path), conv_namespace(namespace),
aux_should_be_string(name));
}
}
|
.each(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq:
each(path, namespace = ExtAttr::USER) -> Enumerator
each(path, namespace = ExtAttr::USER) { |name| ... } -> path
58 59 60 61 62 63 64 |
# File 'lib/extattr.rb', line 58 def self.each(path, namespace = ExtAttr::USER, &block) return to_enum(:each, path, namespace) unless block list(path, namespace, &block) self end |
.each!(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq:
each!(path, namespace = ExtAttr::USER) -> Enumerator
each!(path, namespace = ExtAttr::USER) { |name| ... } -> path
71 72 73 74 75 76 77 |
# File 'lib/extattr.rb', line 71 def self.each!(path, namespace = ExtAttr::USER, &block) return to_enum(:each!, path, namespace) unless block list!(path, namespace, &block) self end |
.each_pair(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq:
each_pair(path, namespace = ExtAttr::USER) -> Enumerator
each_pair(path, namespace = ExtAttr::USER) { |name, data| ... } -> path
84 85 86 87 88 89 90 |
# File 'lib/extattr.rb', line 84 def self.each_pair(path, namespace = ExtAttr::USER, &block) return to_enum(:each_pair, path, namespace) unless block list(path, namespace) { |name| yield(name, get(path, namespace, name)) } self end |
.each_pair!(path, namespace = ExtAttr::USER, &block) ⇒ Object
call-seq:
each_pair!(path, namespace = ExtAttr::USER) -> Enumerator
each_pair!(path, namespace = ExtAttr::USER) { |name, data| ... } -> path
97 98 99 100 101 102 103 |
# File 'lib/extattr.rb', line 97 def self.each_pair!(path, namespace = ExtAttr::USER, &block) return to_enum(:each_pair!, path, namespace) unless block list!(path, namespace) { |name| yield(name, get!(path, namespace, name)) } self end |
.get(path, namespace, name) ⇒ Object
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'ext/extattr.c', line 388
static VALUE
ext_s_get(VALUE mod, VALUE path, VALUE namespace, VALUE name)
{
VALUE v;
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
v = file_extattr_get_main(path, file2fd(path), conv_namespace(namespace),
aux_should_be_string(name));
} else {
ext_check_path_security(path, name, Qnil);
v = file_s_extattr_get_main(aux_to_path(path), conv_namespace(namespace),
aux_should_be_string(name));
}
rb_obj_infect(v, path);
return v;
}
|
.get!(path, namespace, name) ⇒ Object
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'ext/extattr.c', line 410
static VALUE
ext_s_get_link(VALUE mod, VALUE path, VALUE namespace, VALUE name)
{
VALUE v;
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
v = file_extattr_get_main(path, file2fd(path), conv_namespace(namespace),
aux_should_be_string(name));
} else {
ext_check_path_security(path, name, Qnil);
v = file_s_extattr_get_link_main(aux_to_path(path), conv_namespace(namespace),
aux_should_be_string(name));
}
rb_obj_infect(v, path);
return v;
}
|
.list(path, namespace) ⇒ Object .list(path, namespace) {|name| ... } ⇒ nil
313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'ext/extattr.c', line 313
static VALUE
ext_s_list(VALUE mod, VALUE path, VALUE namespace)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, Qnil, Qnil);
return file_extattr_list_main(path, file2fd(path),
conv_namespace(namespace));
} else {
ext_check_path_security(path, Qnil, Qnil);
return file_s_extattr_list_main(aux_to_path(path),
conv_namespace(namespace));
}
}
|
.extattr_list!(path, namespace) ⇒ Object .extattr_list!(path, namespace) {|name| ... } ⇒ nil
332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'ext/extattr.c', line 332
static VALUE
ext_s_list_link(VALUE mod, VALUE path, VALUE namespace)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, Qnil, Qnil);
return file_extattr_list_main(path, file2fd(path),
conv_namespace(namespace));
} else {
ext_check_path_security(path, Qnil, Qnil);
return file_s_extattr_list_link_main(aux_to_path(path),
conv_namespace(namespace));
}
}
|
.open(path) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/extattr.rb', line 38 def self.open(path) if path.kind_of?(File) ea = ExtAttr::Accessor[path, path.to_path] block_given? ? yield(ea) : ea else if block_given? ::File.open(path) do |file| return yield(ExtAttr::Accessor[file, path]) end else ExtAttr::Accessor[::File.open(path), path] end end end |
.set(path, namespace, name, data) ⇒ nil
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'ext/extattr.c', line 433
static VALUE
ext_s_set(VALUE mod, VALUE path, VALUE namespace, VALUE name, VALUE data)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
return file_extattr_set_main(path, file2fd(path),
conv_namespace(namespace),
aux_should_be_string(name), aux_should_be_string(data));
} else {
ext_check_path_security(path, name, Qnil);
return file_s_extattr_set_main(aux_to_path(path),
conv_namespace(namespace),
aux_should_be_string(name), aux_should_be_string(data));
}
}
|
.set!(path, namespace, name, data) ⇒ nil
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'ext/extattr.c', line 453
static VALUE
ext_s_set_link(VALUE mod, VALUE path, VALUE namespace, VALUE name, VALUE data)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
return file_extattr_set_main(path, file2fd(path),
conv_namespace(namespace),
aux_should_be_string(name), aux_should_be_string(data));
} else {
ext_check_path_security(path, name, Qnil);
return file_s_extattr_set_link_main(aux_to_path(path),
conv_namespace(namespace),
aux_should_be_string(name), aux_should_be_string(data));
}
}
|
.size(path, namespace, name) ⇒ Object
351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'ext/extattr.c', line 351
static VALUE
ext_s_size(VALUE mod, VALUE path, VALUE namespace, VALUE name)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
return file_extattr_size_main(path, file2fd(path), conv_namespace(namespace),
aux_should_be_string(name));
} else {
ext_check_path_security(path, name, Qnil);
return file_s_extattr_size_main(aux_to_path(path), conv_namespace(namespace),
aux_should_be_string(name));
}
}
|
.size!(path, namespace, name) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'ext/extattr.c', line 369
static VALUE
ext_s_size_link(VALUE mod, VALUE path, VALUE namespace, VALUE name)
{
if (rb_obj_is_kind_of(path, rb_cFile)) {
ext_check_file_security(path, name, Qnil);
return file_extattr_size_main(path, file2fd(path), conv_namespace(namespace),
aux_should_be_string(name));
} else {
ext_check_path_security(path, name, Qnil);
return file_s_extattr_size_link_main(aux_to_path(path), conv_namespace(namespace),
aux_should_be_string(name));
}
}
|