SMB::File - Remote or local file abstraction for SMB
use SMB::File; # create local file object for server my $file = SMB::File->new( name => $create_request->file_name, share_root => $tree->root, is_ipc => $tree->is_ipc, ); say $file->name; # "john\\file.txt" say $file->filename; # "/my/shares/Users/john/file.txt" # acquire remote file object(s) for client my $file = $create_response->openfile->file; my @files = @{$querydirectory_response->files};
This class implements an SMB file abstraction for a client or a server.
This class inherits from SMB, so msg, err, mem, dump, auto-created field accessor and other methods are available as well.
The following constants are available as SMB::File::CONSTANT_NAME.
ATTR_READONLY ATTR_HIDDEN ATTR_SYSTEM ATTR_DIRECTORY ATTR_ARCHIVE ATTR_DEVICE ATTR_NORMAL ATTR_TEMPORARY ATTR_SPARSE_FILE ATTR_REPARSE_POINT ATTR_COMPRESSED ATTR_OFFLINE ATTR_NOT_CONTENT_INDEXED ATTR_ENCRYPTED DISPOSITION_SUPERSEDE DISPOSITION_OPEN DISPOSITION_CREATE DISPOSITION_OPEN_IF DISPOSITION_OVERWRITE DISPOSITION_OVERWRITE_IF ACTION_NONE ACTION_SUPERSEDED ACTION_OPENED ACTION_CREATED ACTION_OVERWRITTEN
Class constructor. Creates an instance of SMB::File.
The following keys of OPTIONS hash are recognized in addition to the ones recognized by superclass SMB:
name SMB name, no need to start with a backslash is_directory for remote file, this is an attribute hint share_root for local file, this is the share directory is_ipc for local or remote file in IPC tree
Updates corresponding file times (each uint64), sizes (each uint64) and attributes (uint32). Flag SWAPPED indicates that the sizes are swapped (first end_of_file, then allocation_size).
Returns true when the file is marked or stat'd as a directory.
Returns file creation_time as unix time.
Returns file last_access_time as unix time.
Returns file last_write_time as unix time.
Returns file change_time as unix time.
Returns file creation_time as string using function time_to_string.
Returns file last_access_time as string using function time_to_string.
Returns file last_write_time as string using function time_to_string.
Returns file change_time as string using function time_to_string.
Returns file size in bytes. This is just an alias to end_of_file.
Returns file size in human readable form that is always not longer than 9 characters, like: "314159265", "34.567 G", "234.567 T" or "785634e12".
Create and return an SMB::OpenFile object using supplied HANDLE and ACTION, intended for local files on server side. HANDLE may be undef for special open files (like IPC files srvsvc and wkssvc). Increments the number of open files for this file object.
The opposite of add_openfile, closes handle if needed and decrements the number of open files for this file object.
Opens local file by given disposition (using NTFS / SMB semantics). Returns an SMB::OpenFile object on success or undef on failure. The openfile object is created by calling add_openfile internally.
Returns an array ref of SMB::File objects corresponding to the files in this local file object that is a directory. PARAMS is a hash with optional keys "pattern" (default "*") and "start_idx" (default 0).
None of the following functions are exported. But they may be called as SMB::File::FUNC_NAME.
Converts from NTFS attributes (uint32) to Unix mode (unsigned int).
Converts from Unix mode (unsigned int) to NTFS attributes (uint32).
Returns human readable representation of unix time (uint32).
SMB::OpenFile, SMB::Tree, SMB::Client, SMB::Server, SMB.
Mikhael Goikhman <migo@cpan.org>
To install SMB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SMB
CPAN shell
perl -MCPAN -e shell install SMB
For more information on module installation, please visit the detailed CPAN module installation guide.