MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / SharedFile

Class SharedFile

pager_lib/smb/base.py:3043–3101  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

3041
3042
3043class SharedFile:
3044 """
3045 Contain information about a file/folder entry that is shared on the shared device.
3046
3047 As an application developer, you should not need to instantiate a *SharedFile* instance directly in your application.
3048 These *SharedFile* instances are usually returned via a call to *listPath* method in :doc:`smb.SMBProtocol.SMBProtocolFactory<smb_SMBProtocolFactory>`.
3049
3050 If you encounter *SharedFile* instance where its short_name attribute is empty but the filename attribute contains a short name which does not correspond
3051 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
3052 one of these prohibited characters: "\\/[]:+|<>=;?,* (see [MS-CIFS]: 2.2.1.1.1 for more details).
3053
3054 The following attributes are available:
3055
3056 * 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
3057 * 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
3058 * 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
3059 * 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
3060 * file_size : File size in number of bytes
3061 * alloc_size : Total number of bytes allocated to store this file
3062 * 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.
3063 * short_name : Unicode string containing the short name of this file (usually in 8.3 notation)
3064 * 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.
3065 * 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
3066 """
3067
3068 def __init__(self, create_time, last_access_time, last_write_time, last_attr_change_time, file_size, alloc_size, file_attributes, short_name, filename, file_id=None):
3069 self.create_time = 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
3070 self.last_access_time = 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
3071 self.last_write_time = 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
3072 self.last_attr_change_time = 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
3073 self.file_size = file_size #: File size in number of bytes
3074 self.alloc_size = alloc_size #: Total number of bytes allocated to store this file
3075 self.file_attributes = 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.
3076 self.short_name = short_name #: Unicode string containing the short name of this file (usually in 8.3 notation)
3077 self.filename = 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.
3078 self.file_id = 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
3079
3080 @property
3081 def isDirectory(self):
3082 """A convenience property to return True if this file resource is a directory on the remote server"""
3083 return bool(self.file_attributes & ATTR_DIRECTORY)
3084
3085 @property
3086 def isReadOnly(self):
3087 """A convenient property to return True if this file resource is read-only on the remote server"""
3088 return bool(self.file_attributes & ATTR_READONLY)
3089
3090 @property
3091 def isNormal(self):
3092 """
3093 A convenient property to return True if this is a normal file.
3094
3095 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.
3096 It ignores other attributes like compression, indexed, sparse, temporary and encryption.
3097 """
3098 return (self.file_attributes==ATTR_NORMAL) or ((self.file_attributes & 0xff)==0)
3099
3100 def __unicode__(self):

Callers 4

decodeQueryStructMethod · 0.85
createCBMethod · 0.85
decodeFindStructMethod · 0.85
queryCBMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected