7 XSLoader::load 'OS2::ExtAttr', $VERSION;
9 # Preloaded methods go here.
11 # Format of the array:
12 # 0 ead, 1 file name, 2 file handle. 3 length, 4 position, 5 need to write.
16 my $ea = _create() || die "Cannot create EA: $!";
19 if (ref $file eq 'GLOB' or ref \$file eq 'GLOB') {
20 die "File handle is not opened" unless $handle = fileno $file;
21 _read($ea, undef, $handle, 0);
24 _read($ea, $name, 0, 0);
26 bless [$ea, $name, $handle, 0, 0, 0], $class;
31 # 0 means: discard eas which are not in $eas->[0].
32 _write( $eas->[0], $eas->[1], $eas->[2], 0) and die "Cannot write EA: $!"
34 _destroy( $eas->[0] );
39 $eas->[3] = _count($eas->[0]);
41 return undef if $eas->[4] > $eas->[3];
42 return _get_name($eas->[0], $eas->[4]);
48 return undef if $eas->[4] > $eas->[3];
49 return _get_name($eas->[0], $eas->[4]);
54 my $index = _find($eas->[0], shift);
55 return undef if $index <= 0;
56 return value($eas->[0], $index);
61 return _find($eas->[0], shift) > 0;
67 add($eas->[0], shift, shift) > 0 or die "Error setting EA: $!";
72 my $index = _find($eas->[0], shift);
73 return undef if $index <= 0;
74 my $value = value($eas->[0], $index);
75 _delete($eas->[0], $index) and die "Error deleting EA: $!";
86 # Here are additional methods:
94 if (ref $file eq 'GLOB' or ref \$file eq 'GLOB') {
95 die "File handle is not opened" unless $handle = fileno $file;
96 _write($eas->[0], undef, $handle, 0) or die "Cannot write EA: $!";
99 _write($eas->[0], $name, 0, 0) or die "Cannot write EA: $!";
105 # 0 means: discard eas which are not in $eas->[0].
106 _write( $eas->[0], $eas->[1], $eas->[2], 0) and die "Cannot write EA: $!";
109 # Autoload methods go after =cut, and are processed by the autosplit program.
113 # Below is the stub of documentation for your module. You better edit it!
117 OS2::ExtAttr - Perl access to extended attributes.
122 tie %ea, 'OS2::ExtAttr', 'my.file';
124 $ea{myfield} = 'value';
130 The package provides low-level and high-level interface to Extended
131 Attributes under OS/2.
133 =head2 High-level interface: C<tie>
135 The only argument of tie() is a file name, or an open file handle.
137 Note that all the changes of the tied hash happen in core, to
138 propagate it to disk the tied hash should be untie()ed or should go
139 out of scope. Alternatively, one may use the low-level C<update>
140 method on the corresponding object. Example:
144 Note also that setting/getting EA flag is not supported by the
145 high-level interface, one should use the low-level interface
146 instead. To use it on a tied hash one needs undocumented way to find
147 C<eas> give the tied hash.
149 =head2 Low-level interface
151 Two low-level methods are supported by the objects: copy() and
152 update(). The copy() takes one argument: the name of a file to copy
153 the attributes to, or an opened file handle. update() takes no
154 arguments, and is discussed above.
156 Three convenience functions are provided:
159 add($eas, $key, $value [, $flag])
160 replace($eas, $key, $value [, $flag])
162 The default value for C<flag> is 0.
164 In addition, all the C<_ea_*> and C<_ead_*> functions defined in EMX
165 library are supported, with leading C<_ea/_ead> stripped.
169 Ilya Zakharevich, ilya@math.ohio-state.edu