Filesys-Virtual-Async-inMemory

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    of some things.

    The way this module implements subclassing is to call a private method
    whenever it detects a subclass using this module as a superclass. Please
    don't override the ::Async API! What you need to do is define your own
    _method subs for the ones you want to override. All other methods that
    aren't defined will return ENOSYS to the ::Async API.

    Available methods to implement: _rmtree, _scandir, _move, _copy, _load,
    _readdir, _rmdir, _mkdir, _rename, _mknod, _unlink, _chmod, _truncate,
    _chown, _utime, _stat, _write, _open.

    Again, please look at the source for this module to see how it interacts
    with the subclass. Some of the methods have been "simplified" to reduce
    the pain of managing the data. Be sure to let this module create the
    object, because we need the "readonly" attribute to be present in the
    hash! If "readonly" is set, this module will take over the logic for
    certain methods and not call your method if there's a readonly violation
    ( write(), for example ).

  Debugging

lib/Filesys/Virtual/Async/inMemory.pm  view on Meta::CPAN

		# successful update of time!
		$callback->( 0 );
	} else {
		# path does not exist
		$callback->( -ENOENT() );
	}

	return;
}

sub chown {
	my( $self, $path, $uid, $gid, $callback ) = @_;

	# FIXME we don't support fh mode because it would require insane amounts of munging the paths
	if ( ref $path ) {
		if ( DEBUG ) {
			warn 'Passing a REF to chown() is not supported!';
		}
		$callback->( -ENOSYS() );
		return;
	}

	# are we readonly?
	if ( $self->readonly ) {
		$callback->( -EROFS() );
		return;
	}

	# FIXME fix relative path/sanitize path?

	# determine if we should be using callback mode
	if ( ref( $self ) ne __PACKAGE__ ) {
		if ( $self->can( '_chown' ) ) {
			$callback->( $self->_chown( $path, $uid, $gid ) );
		} else {
			$callback->( -ENOSYS() );
		}
		return;
	}

	if ( exists $self->_fs->{ $path } ) {
		# okay, update the ownerships!
		if ( defined $uid and $uid > -1 ) {
			$self->_fs->{ $path }{'uid'} = $uid;

lib/Filesys/Virtual/Async/inMemory.pm  view on Meta::CPAN


If you want to subclass this module, please read on! The primary reason for subclassing is so you have true "callbacks"
whenever the API is called, instead of providing a static filesystem structure. This module tries to do it's best
to reduce the pain, but you would need to be aware of some things.

The way this module implements subclassing is to call a private method whenever it detects a subclass using this
module as a superclass. Please don't override the ::Async API! What you need to do is define your own _method subs
for the ones you want to override. All other methods that aren't defined will return ENOSYS to the ::Async API.

Available methods to implement: _rmtree, _scandir, _move, _copy, _load, _readdir, _rmdir, _mkdir, _rename, _mknod,
_unlink, _chmod, _truncate, _chown, _utime, _stat, _write, _open.

Again, please look at the source for this module to see how it interacts with the subclass. Some of the methods have
been "simplified" to reduce the pain of managing the data. Be sure to let this module create the object, because
we need the "readonly" attribute to be present in the hash! If "readonly" is set, this module will take over the
logic for certain methods and not call your method if there's a readonly violation ( write(), for example ).

=head2 Debugging

You can enable debug mode which prints out some information ( and especially error messages ) by doing this:



( run in 1.980 second using v1.01-cache-2.11-cpan-71847e10f99 )