API:EPrints/System

From EPrints Documentation
Revision as of 23:11, 9 January 2022 by Pod2wiki (talk | contribs) (Created page with "<!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints 3.4 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment'...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::System - Wrappers for system calls.

User Comments


DESCRIPTION

When you call a method in this class, it is sent to the appropriate EPrints::System sub-module:

EPrints::System::darwin
EPrints::System::freebsd
EPrints::System::linux
EPrints::System::MSWin32
EPrints::System::openbsd
EPrints::System::solaris
 

By default this will be EPrints::System::linux.

Which module is used is configured by the platform setting in EPrints::SystemSettings

All file and directory names are absolute and joined by the UNIX separator character /.

User Comments


METHODS

User Comments


Constructor Methods

User Comments


new

$sys = EPrints::System->new

Returns a new EPrints System object.

User Comments


Object Methods

User Comments


init

$sys->init

Perform any platform-specific initialisation.

User Comments


chmod

$sys->chmod( $mode, @files )

Change the access control on @files listed to $mode.

User Comments


chown

$sys->chown( $uid, $gid, @files )

Change the user and group on @files to $uid and $gid. $uid and $gid are as returned by getpwnam (usually numeric).

User Comments


chown_for_eprints

$sys->chown_for_eprints( @files )

Change the user and group on @files to the current EPrints user and group.

User Comments


getgrnam

$gid = $sys->getgrnam( $group )

Return the system group ID of the group $group.

User Comments


getpwnam

($user, $crypt, $uid, $gid ) = $sys->getpwnam( $user )

Return the login name, password crypt, UID and GID for user $user.

User Comments


current_uid

$sys->current_uid

Returns the current UID of the user running this process.

User Comments


test_uid

$sys->test_uid

Test whether the current user is the same that is configured in EPrints::SystemSettings.

User Comments


mkdir

$sys->mkdir( $full_path, $perms )

Create a directory $full_path (including parent directories as necessary) set permissions described by $perms. If $perms is undefined defaults to dir_perms in EPrints::SystemSettings.

User Comments


exec

$sys->exec( $repository, $cmd_id, %map )

Executes certain named task $cmd_id on $repository, which were once (and may be) handled by external binaries. This allows a per-platform solution to each task. E.g. unpacking a .tar.gz file.

%map includes variable names and values that need to be mapped into the task command.

Returns the numerical return code from the executed command.

User Comments


read_exec

$rc = $sys->read_exec( $repo, $tmp, $cmd_id, %map )

Same as </exec> but write STDOUT and STDERR to the filename specified by $tmp.

User Comments


read_perl_script

$rc = $sys->read_perl_script( $repo, $tmp, @args )

Executes Perl with arguments from @args, including the current EPrints library path. Writes STDOUT and STDERR from the script to file with name $tmp.

Returns 0 on success.

User Comments


free_space

$sys->free_space( $dir )

Return the amount of free space (in bytes) available at $dir. $dir may contain a drive (e.g. C:) on Windows platforms.

User Comments


proc_exists

$bool = $sys->proc_exists( $pid )

Returns true if a process exists for ID with $pid.

Returns undef if process identification is unsupported.

User Comments


get_hash_name

$filename = $sys->get_hash_name

Returns the last part of the filename of the hashfile for a document. (yes, it's a bad function name.)

User Comments


write_config_file

$backup = write_config_file( $path, $content, [ %opts ] )

Write a config file containing $content to the file located at $path.

If $content is undefined no file will be written.

%opts not currently used but reserved for future use.

User Comments


quotemeta

$quoted = $sys->quotemeta( $path )

Quote $path so it is safe to be used in a shell call.

User Comments


capture_stderr

$tmpfile = $sys->capture_stderr

Captures STDERR output into a temporary file and return a file handle to it.

User Comments


restore_stderr

$sys->restore_stderr( $tmpfile )

Restores STDERR after capturing.

If $tmpfile is set, reset seek and sysseek to the start of this file.

User Comments


join_path

$path = $sys->join_path( @parts )

Returns @parts joined together using the current system's path separator.

User Comments


file_extension

$ext = $sys->file_extension( $filename )

Returns the file extension of $filename including the leading . e.g. .tar.gz.

Returns empty string if there is no file extension.

User Comments


sanitise

$filepath = $sys->sanitise( $filepath )

Replaces restricted file system characters and control characters in $filepath with _.

Removes path-walking elements (. and ..) from the front of any path components and removes the leading /.

User Comments


bin_paths

@paths = $sys->bin_paths

Get the list of absolute directories to search for system tools (e.g. convert).

User Comments


COPYRIGHT

© Copyright 2022 University of Southampton.

EPrints 3.4 is supplied by EPrints Services.

http://www.eprints.org/eprints-3.4/

LICENSE

This file is part of EPrints 3.4 http://www.eprints.org/.

EPrints 3.4 and this file are released under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation unless otherwise stated.

EPrints 3.4 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints 3.4. If not, see http://www.gnu.org/licenses/.

User Comments