SharedFile Class

class smb.base.SharedFile(create_time, last_access_time, last_write_time, last_attr_change_time, file_size, alloc_size, file_attributes, short_name, filename, file_id=None)[source]

Contain information about a file/folder entry that is shared on the shared device.

As an application developer, you should not need to instantiate a SharedFile instance directly in your application. These SharedFile instances are usually returned via a call to listPath method in smb.SMBProtocol.SMBProtocolFactory.

If you encounter SharedFile instance where its short_name attribute is empty but the filename attribute contains a short name which does not correspond to any files/folders on your remote shared device, it could be that the original filename on the file/folder entry on the shared device contains one of these prohibited characters: “/[]:+|<>=;?,* (see [MS-CIFS]: 2.2.1.1.1 for more details).

The following attributes are available:

  • create_time : Float value in number of seconds since 1970-01-01 00:00:00 to the time of creation of this file resource on the remote server

  • last_access_time : Float value in number of seconds since 1970-01-01 00:00:00 to the time of last access of this file resource on the remote server

  • last_write_time : Float value in number of seconds since 1970-01-01 00:00:00 to the time of last modification of this file resource on the remote server

  • last_attr_change_time : Float value in number of seconds since 1970-01-01 00:00:00 to the time of last attribute change of this file resource on the remote server

  • file_size : File size in number of bytes

  • alloc_size : Total number of bytes allocated to store this file

  • file_attributes : A SMB_EXT_FILE_ATTR integer value. See [MS-CIFS]: 2.2.1.2.3. You can perform bit-wise tests to determine the status of the file using the ATTR_xxx constants in smb_constants.py.

  • short_name : Unicode string containing the short name of this file (usually in 8.3 notation)

  • filename : Unicode string containing the long filename of this file. Each OS has a limit to the length of this file name. On Windows, it is 256 characters.

  • file_id : Long value representing the file reference number for the file. If the remote system does not support this field, this field will be None or 0. See [MS-FSCC]: 2.4.17

alloc_size

Total number of bytes allocated to store this file

create_time

Float value in number of seconds since 1970-01-01 00:00:00 to the time of creation of this file resource on the remote server

file_attributes

A SMB_EXT_FILE_ATTR integer value. See [MS-CIFS]: 2.2.1.2.3. You can perform bit-wise tests to determine the status of the file using the ATTR_xxx constants in smb_constants.py.

file_id

Long value representing the file reference number for the file. If the remote system does not support this field, this field will be None or 0. See [MS-FSCC]: 2.4.17

file_size

File size in number of bytes

filename

Unicode string containing the long filename of this file. Each OS has a limit to the length of this file name. On Windows, it is 256 characters.

property isDirectory

A convenience property to return True if this file resource is a directory on the remote server

property isNormal

A convenient property to return True if this is a normal file.

Note that pysmb defines a normal file as a file entry that is not read-only, not hidden, not system, not archive and not a directory. It ignores other attributes like compression, indexed, sparse, temporary and encryption.

property isReadOnly

A convenient property to return True if this file resource is read-only on the remote server

last_access_time

Float value in number of seconds since 1970-01-01 00:00:00 to the time of last access of this file resource on the remote server

last_attr_change_time

Float value in number of seconds since 1970-01-01 00:00:00 to the time of last attribute change of this file resource on the remote server

last_write_time

Float value in number of seconds since 1970-01-01 00:00:00 to the time of last modification of this file resource on the remote server

short_name

Unicode string containing the short name of this file (usually in 8.3 notation)