Prima

 view release on metacpan or  search on metacpan

Prima/Utils.pm  view on Meta::CPAN

	get_os get_gui
	beep sound
	username
	xcolor
	find_image path
	alarm post last_error

	chdir chmod closedir getcwd link mkdir open_file open_dir
	read_dir rename rmdir unlink utime
	seekdir telldir rewinddir
	getenv setenv stat access getdir sv2local local2sv

	nearest_d nearest_i
);

sub xcolor {
# input: '#rgb' or '#rrggbb' or '#rrrgggbbb'
# output: internal color used by Prima
	my ($r,$g,$b,$d);
	$_ = $_[0];
	$d=1/16, ($r,$g,$b) = /^#([\da-fA-F]{3})([\da-fA-F]{3})([\da-fA-F]{3})/

Prima/Utils.pm  view on Meta::CPAN

Returns directory handle to be used on C<readdir>, C<closedir>, C<rewinddir>, C<telldir>, C<seekdir>.

=item rename OLDNAME, NEWNAME

Same as C<CORE::rename>

=item rmdir PATH

Same as C<CORE::rmdir>

=item setenv NAME, VAL

Directly sets environment variable, possibly bypassing C< %ENV >, depending on
how perl is built.  Also disregards thread local environment on Win32.

Note that effective synchronization between this call and C< %ENV > is not
always possible, since Win32 perl implementation simply does not allow that.
One is advised to assign to C< %ENV > manually, but only if both NAME and VAL
don't have their utf8 bit set, otherwise perl will warn about wide characters.

=item stat PATH

Prima/sys/FS.pm  view on Meta::CPAN

use warnings;
require Exporter;
use Symbol ();
use Scalar::Util qw(readonly);
use Encode;
use Fcntl qw(O_RDONLY O_WRONLY O_RDWR O_CREAT O_TRUNC O_APPEND);
use Prima;
use Prima::Utils qw(
	chdir chmod closedir getcwd link mkdir open_dir open_file
	read_dir rename rmdir unlink utime
	getenv setenv stat access getdir
	seekdir telldir rewinddir
);

use vars qw(@ISA @EXPORT @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(
	chdir chmod getcwd link mkdir open opendir readdir closedir 
	rename rmdir unlink utime
	getenv setenv abs_path stat lstat access getdir
	seekdir telldir rewinddir glob
	_r _w _x _o _R _W _X _O _e _z _s _f _d _l _p _S _b _c _t _u _g _k _M _A _C
);
@EXPORT = @EXPORT_OK;

sub open(*;$*)
{
	my ( $handle, @p ) = @_;
	goto NATIVE unless @p;
	$p[0] =~ m/^([\<\>\|\-\+\=\&]*])(.*)/ if 1 == @p;

Prima/sys/FS.pm  view on Meta::CPAN

  print "ls: ", getdir, "\n";
  print "pwd: ", getcwd, "\n";

=head1 API

The module exports by default three groups of functions:

These are described in L<Prima::Utils/API>:

  chdir chmod getcwd link mkdir open rename rmdir unlink utime
  getenv setenv stat access getdir
  opendir closedir rewinddir seekdir readdir telldir

The underscore-prefixed functions are same as the ones in L<perlfunc/-X> (all are present except -T and -B ).

  _r _w _x _o _R _W _X _O _e _z _s _f _d _l _p _S _b _c _t _u _g _k _M _A _C

The functions that are implemented in the module itself:

=over

class/Utils.c  view on Meta::CPAN

Bool
Utils_seekdir( SV * dh, long position )
{
	PDirHandleRec d;
	if (( d = get_dh("seekdir", dh)) == NULL )
		return false;
	return apc_fs_seekdir(d, position);
}

Bool
Utils_setenv(SV * varname, SV * value)
{
	return apc_fs_setenv(
		SvPV_nolen(varname), prima_is_utf8_sv(varname),
		SvOK(value) ? SvPV_nolen(value) : NULL,
		SvOK(value) ? prima_is_utf8_sv(value) : false
	);
}

XS(Utils_stat_FROMPERL) {
	dXSARGS;
	char *name;
	StatRec stats;

class/Utils.cls  view on Meta::CPAN

	SV*  local2sv(SV * text);
	Bool link( SV* oldname, SV * newname );
	Bool mkdir( SV* path, int mode = 0777);
	SV*  open_dir( SV* path);
	int  open_file( SV* path, int mode, int perms = 0666);
	SV*  read_dir( SV* dh);
	Bool rename( SV* oldpath, SV * newpath );
	Bool rewinddir( SV* dh );
	Bool rmdir( SV* path );
	Bool seekdir(SV * dh, long position);
	Bool setenv(SV * varname, SV * value);
	long telldir(SV * dh);
	Bool unlink( SV* path );
	SV*  sv2local(SV * text, Bool fail_if_cannot = true);
	Bool utime( double atime, double mtime, SV* path );
}

include/apricot.h  view on Meta::CPAN

extern Bool
apc_fs_rewinddir( PDirHandleRec dh );

extern Bool
apc_fs_rmdir( const char* path, Bool is_utf8 );

extern Bool
apc_fs_seekdir( PDirHandleRec dh, long position );

extern Bool
apc_fs_setenv(const char * varname, Bool is_name_utf8, const char * value, Bool is_value_utf8);

extern Bool
apc_fs_stat(const char *name, Bool is_utf8, Bool link, PStatRec statrec);

extern char *
apc_fs_to_local(const char * text, Bool fail_if_cannot, int * len);

extern long
apc_fs_telldir( PDirHandleRec dh );

t/misc/fs.t  view on Meta::CPAN


	@l = stat($dn);
	ok(scalar(@l), "$id: stat dir");
	diag($!) unless @l;
	ok( $l[2] & S_IFDIR, "$id: stat dir is dir");

	my $cwd = getcwd;
	ok( $ok = chdir($dn), "$id: chdir");
	diag($!) unless $ok;
	my $ncwd = getcwd;
	setenv( WHATEVER => $ncwd );
	is( getenv( 'WHATEVER' ), $ncwd, "$id: getenv");

	my $dn_local = Prima::Utils::sv2local($dn);
	if ( defined $dn_local ) {
		my $cwd = Cwd::getcwd();
		CORE::chdir $dn_local;
		like( Cwd::getcwd(), qr/\Q$dn_local\E/, "$id: chdir back-compat");
		CORE::chdir $cwd;
		chdir($ncwd);

unix/app.c  view on Meta::CPAN

	if ( strcmp( option, "no-x11") == 0) {
		if ( value) warn("`--no-x11' option has no parameters");
		do_x11 = false;
		return true;
	} else if ( strcmp( option, "yes-x11") == 0) {
		do_x11 = true;
		return true;
	} else if ( strcmp( option, "display") == 0) {
		free( do_display);
		do_display = duplicate_string( value);
		setenv("DISPLAY", value, 1);
		return true;
	} else if ( strcmp( option, "icccm") == 0) {
		if ( value) warn("`--icccm' option has no parameters");
		do_icccm_only = true;
		return true;
	} else if ( strcmp( option, "no-shmem") == 0) {
		if ( value) warn("`--no-shmem' option has no parameters");
		do_no_shmem = true;
		return true;
	} else if ( strcmp( option, "no-gtk") == 0) {

unix/file.c  view on Meta::CPAN

}

Bool
apc_fs_seekdir( PDirHandleRec dh, long position )
{
	seekdir(dh->handle, position);
	return true;
}

Bool
apc_fs_setenv(const char * varname, Bool is_name_utf8, const char * value, Bool is_value_utf8)
{
	Perl_my_setenv(aTHX_ varname, value);
	return true;
}

Bool
apc_fs_stat(const char *name, Bool is_utf8, Bool link, PStatRec statrec)
{
	struct stat statbuf;
	if ( link ) {
		if ( lstat(name, &statbuf) < 0 )
			return 0;

win32/files.c  view on Meta::CPAN

	SystemTime.wHour   = pTM->tm_hour;
	SystemTime.wMinute = pTM->tm_min;
	SystemTime.wSecond = pTM->tm_sec;
	SystemTime.wMilliseconds = ( Time - (int) Time ) * 1000;

	return SystemTimeToFileTime(&SystemTime, &LocalTime) &&
	       LocalFileTimeToFileTime(&LocalTime, pFileTime);
}

Bool
apc_fs_setenv(const char * varname, Bool is_name_utf8, const char * value, Bool is_value_utf8)
{
	WCHAR *buf1, *buf2;
	Bool ok = false;

	if ( !( buf1 = path2wchar(varname, is_name_utf8, NULL)))
		return false;
	if ( !( buf2 = path2wchar(value,   is_value_utf8, NULL))) {
		free(buf1);
		return false;
	}



( run in 0.472 second using v1.01-cache-2.11-cpan-a1d94b6210f )