Bases: fs.FilePath, winsys.core._WinSysObject
Heart of the fs module. This is a subtype of FilePath and therefore of the base unicode type and is the parent of the Dir and File classes and contains all the functionality common to both. It is rarely instantiated itself, altho’ it’s possible to do so.
Attributes: * readable * filepath * created_at * accessed_at * written_at * uncompressed_size * size * attributes * id * n_links * attributes - an :class:`_Attributes object representing combinations of FILE_ATTRIBUTE
Common functionality:
Iterate over this entry’s ancestors, yielding the Dir object corresponding to each one.
Returns: | yield a Dir object for each ancestor |
---|
Compress this entry; if it is a file, it will be compressed, if it is a directory it will be marked so that any new files added to it will be compressed automatically.
Returns: | self |
---|
FIXME: Need to work out how to create certificates for this
Returns: | self |
---|
FIXME: Need to work out how to create certificates for this
Get and store the latest access time from the filesystem
Get and store the latest file attributes from the filesystem
Get and store the latest creation time from the filesystem
Get and store the latest (possibly compressed) size from the filesystem
Get and store the latest modification time from the filesystem
Return true if this filename’s name (not the path) matches pattern according to fnmatch, eg:
from winsys import fs
for f in fs.files ():
if f.directory and f.like ("test_*"):
print f
Parameters: | pattern – an fnmatch pattern |
---|---|
Returns: | True if this file matches pattern |
Move this entry to the file/directory represented by other. If other is a directory, self
Parameters: |
|
---|---|
Returns: | a File object corresponding to the target file |
Move this entry to the file/directory represented by other. If other is a directory, self
Parameters: |
|
---|---|
Returns: | a File object corresponding to the target file |
Return a security.Security object corresponding to this entry’s security attributes. Note that the returning object is a context manager so a common pattern is:
#
# Find all private key files and ensure that only
# the owner has any access.
#
from winsys import fs
for f in fs.flat ("*.ppk"):
with f.security () as s:
s.break_inheritance ()
s.dacl = [(s.owner, "F", "ALLOW")]
Parameters: | options – cf security.security() |
---|---|
Returns: | a security.Security object which may be used as a context manager |
Give the logged-on user full control to a file. This may need to be preceded by a call to take_ownership() so that the user gains WRITE_DAC permissions.
Parameters: | principal – anything accepted by principal() [logged-on user] |
---|
Set the new owner of the file to be the logged-on user. This is no more than a slight shortcut to the equivalent security operations.
If you specify a principal (other than the logged-in user, the default) you may need to have enabled SE_RESTORE privilege. Even the logged-in user may need to have enabled SE_TAKE_OWNERSHIP if that user has not been granted the appropriate security by the ACL.
Parameters: | principal – anything accepted by principal() [logged-on user] |
---|
Uncompress this entry; if it is a file, it will be uncompressed, if it is a directory it will be marked so that any new files added to it will not be compressed automatically.
Returns: | self |
---|
FIXME: Need to work out how to create certificates for this
Returns: | self |
---|
Get the access time from the original file read or the latest from the filesystem if none was stored.
Is the archive bit set on the file?
Get and store the file attributes from the original file read or the latest from the filesystem if none was stored.
Is the file compressed?
Get the creation time from the original file read or the latest from the filesystem if none was stored.
Is the file a directory?
Is the file encrypted?
Is the file hidden?
Return an id for this file which can be used to compare it to another while both files are open to determine if both are the same physical file.
Determine how many links point to this file. >1 indicates that the file is hardlinked.
Is the file normal?
Should the file’s content not be indexed?
Is the file offline?
Is the file readonly?
Is the file a reparse point?
Get and store the (possibly compressed) size from the original file read or the latest from the filesystem if none was stored.
Is the file sparse?
Is the file a system file?
Is the file a temporary file?
Get the size of the file data, ignoring any filesystem compression which may have been applied.
Is the file a virtual file?
Get and store the modification time from the original file read or the latest from the filesystem if none was stored.