- 1 NAME
- 2 DESCRIPTION
- 3 METHODS
- 3.1 Constructor Methods
- 3.2 Object Methods
- 3.2.1 init
- 3.2.2 chmod
- 3.2.3 chown
- 3.2.4 chown_for_eprints
- 3.2.5 getgrnam
- 3.2.6 getpwnam
- 3.2.7 current_uid
- 3.2.8 test_uid
- 3.2.9 mkdir
- 3.2.10 exec
- 3.2.11 read_exec
- 3.2.12 read_perl_script
- 3.2.13 free_space
- 3.2.14 proc_exists
- 3.2.15 get_hash_name
- 3.2.16 write_config_file
- 3.2.17 quotemeta
- 3.2.18 capture_stderr
- 3.2.19 restore_stderr
- 3.2.20 join_path
- 3.2.21 file_extension
- 3.2.22 sanitise
- 3.2.23 bin_paths
- 4 COPYRIGHT
EPrints::System - Wrappers for system calls.
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 /.
$sys = EPrints::System->new
Returns a new EPrints System object.
Perform any platform-specific initialisation.
$sys->chmod( $mode, @files )
Change the access control on @files listed to $mode.
$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).
$sys->chown_for_eprints( @files )
Change the user and group on @files to the current EPrints user and group.
$gid = $sys->getgrnam( $group )
Return the system group ID of the group $group.
($user, $crypt, $uid, $gid ) = $sys->getpwnam( $user )
Return the login name, password crypt, UID and GID for user $user.
Returns the current UID of the user running this process.
Test whether the current user is the same that is configured in EPrints::SystemSettings.
$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.
$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.
$rc = $sys->read_exec( $repo, $tmp, $cmd_id, %map )
Same as </exec> but write STDOUT and STDERR to the filename specified by $tmp.
$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.
$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.
$bool = $sys->proc_exists( $pid )
Returns true if a process exists for ID with $pid.
Returns undef if process identification is unsupported.
$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.)
$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.
$quoted = $sys->quotemeta( $path )
Quote $path so it is safe to be used in a shell call.
$tmpfile = $sys->capture_stderr
Captures STDERR output into a temporary file and return a file handle to it.
$sys->restore_stderr( $tmpfile )
Restores STDERR after capturing.
If $tmpfile is set, reset seek and sysseek to the start of this file.
$path = $sys->join_path( @parts )
Returns @parts joined together using the current system's path separator.
$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.
$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 /.
@paths = $sys->bin_paths
Get the list of absolute directories to search for system tools (e.g. convert).
© Copyright 2022 University of Southampton.
EPrints 3.4 is supplied by EPrints Services.
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/.