NAME
Filesys::SmbClient - Perl extension for access Samba filesystem with libsmclient.so
SYNOPSIS
use POSIX;
use Filesys::SmbClient;
my $smb = new Filesys::SmbClient("alian",10);
# Read a directory
my $fd = $smb->opendir("smb://jupiter/doc");
while ($smb->readdir($fd)) {print $_,"\n";}
close($fd);
# Read long info on a directory
my $fd = $smb->opendir("smb://jupiter/doc");
while (my $f = $smb->readdir_struct($fd))
{
if ($f->[0] == SMBC_DIR) {print "Directory ",$f->[1],"\n";}
elsif ($f->[0] == SMBC_FILE) {print "File ",$f->[1],"\n";}
# ...
}
close($fd);
# Create a directory
$smb->mkdir("smb://jupiter/doc/toto",'0666');
# Read a file
my $fd = $smb->open("smb://jupiter/doc/toto",O_RDONLY,'0666');
while (defined(my $l= $smb->read($fd,50))) {print $l; }
$smb->close(fd);
# Write a file
my $fd = $smb->open("smb://jupiter/doc/test",O_CREAT, 0666);
$smb->write($fd,"A test of write call") || print $!,"\n";
$smb->close(fd);
# Rename a file
$smb->rename("smb://jupiter/doc/toto","smb://jupiter/doc/tata"),"\n";
# Delete a file
$smb->unlink("smb://jupiter/doc/test");
# Stat a file
my @tab = $smb->stat("smb://jupiter/doc/tata");
for (10..12) {$tab[$_] = localtime($tab[$_]);}
print join("\n",@tab);
DESCRIPTION
Provide interface to access routine defined in libsmbclient.so. On 2001/01/21, this library is only available with CVS source of Samba (target head), See on samba.org web site, section download. This module is a beta version !
When a path is used, his scheme is :
smb://server/share/rep/doc
VERSION
$Revision: 0.2 $
FONCTIONS
- new($wgroup,$debug)
-
Init some things
$wgroup : Current workgroup $debug : level of debug
Return 0 on succes, errno else.
Directory
- mkdir($fname,$mode)
-
Create directory $fname with permissions set to $mode
- opendir($fname)
-
Open directory $fname and return file descriptor.
- readdir($fd)
-
Read a directory. In a list context, return the full content of the directory $fd, else return next element. Each elem is a name of a directory or files.
Return undef at end of directory.
- readdir_struct($fd)
-
Read a directory. In a list context, return the full content of the directory $fd, else return next element. Each element is a ref to an array with type and name. Type can be :
Return undef at end of directory.
- SMBC_WORKGROUP
- SMBC_SERVER
- SMBC_FILE_SHARE
- SMBC_PRINTER_SHARE
- SMBC_COMMS_SHARE
- SMBC_IPC_SHARE
- SMBC_DIR
- SMBC_FILE
- SMBC_LINK
- closedir($fd)
-
Close directory $fd.
Files
- unlink($fname)
-
Delete file $fname
Return 0 on succes, errno else.
- stat($fname)
-
Stat a file to get info via file $fname. Return a array with info on success, else errno is return and $! is set. Tab is made with:
device
inode
protection
number of hard links
user ID of owner
group ID of owner
device type (if inode device)
total size, in bytes
blocksize for filesystem I/O
number of blocks allocated
time of last access
time of last modification
time of last change
- rename($oname,$nname)
-
Rename $oname in $nname. Return 0 on success, else -1 is return and errno and $! is set.
- open($fname, $flags, $mode)
-
Open file $fname with flags $flags and mode $mode. Return file descriptor on success, else -1 is return and errno and $! is set.
- read($fd,$count)
-
Read $count bytes of data on file descriptor $fd. Return buffer read on success, undef at end of file, -1 is return on error and $! is set.
- write($fd,$buf)
-
Write $buf on file descriptor $fd. Return number of bytes wrote, else -1 is return and errno and $! is set.
- close($fd)
-
Close file descriptior $fd. Return 0 on success, else -1 is return and errno and $! is set.
AUTHOR
Alain BARBET, alian@alianwebserver.com