
    h                    .   S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJrJ	r	  SSK
JrJrJrJrJrJrJrJrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"  SSK#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3  SSK4J5r5J6r6J7r7  SS	K8J9r9  SS
K:J;r;J<r<  SSK=J>r>  SSK?J@r@  SSKAJBrBJCrCJDrDJErEJFrF  \R                  \R                  -  \R                  -  \F-  rJ\0" SSS9rK\R                  rM\R                  rO " S S\65      rP " S S\Q5      rR " S S\Q5      rS " S S\T5      rUS'S jrV\0" S\W\X5      rY\9S   rZ " S S\*\'   5      r[ " S S\@5      r\ " S  S!\@5      r]S(S)S" jjr^S*S+S# jjr_ S*       S,S$ jjr`\<\7" \P5       " S% S&\[\'   5      5       5       rag)-z1
Object-oriented filesystem path representation.
    )annotationsN)listdirstatutime)	abspathbasenamedirnameexistsisabsislinkjoinnormpathsplitext)S_IMODES_IRGRPS_IROTHS_IRUSRS_ISBLKS_ISDIRS_ISREGS_ISSOCKS_IWGRPS_IWOTHS_IWUSRS_IXGRPS_IXOTHS_IXUSR)IOTYPE_CHECKINGAnyAnyStrCallableDictGenericIterableListOptionalSequenceTupleTypeVarUnioncastoverload)	Attribute	Interfaceimplementer)Literal)cmp
comparable)platform)FancyEqMixin)ERROR_DIRECTORYERROR_FILE_NOT_FOUNDERROR_INVALID_NAMEERROR_PATH_NOT_FOUNDO_BINARY_SelfzAbstractFilePath[Any]boundc                      \ rS rSrSr\" S5      rSS jrSSS jjrSS jr	SS jr
SS jrSS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)	IFilePathZ   a:  
File path object.

A file path represents a location for a file-like-object and can be
organized into a hierarchy; a file path can can children which are
themselves file paths.

A file path has a name which unique identifies it in the context of its
parent (if it has one); a file path can not have two children with the same
name.  This name is referred to as the file path's "base name".

A series of such names can be used to locate nested children of a file
path; such a series is referred to as the child's "path", relative to the
parent.  In this case, each name in the path is referred to as a "path
segment"; the child's base name is the segment in the path.

When representing a file path as a string, a "path separator" is used to
delimit the path segments within the string.  For a file system path, that
would be C{os.sep}.

Note that the values of child names may be restricted.  For example, a file
system path will not allow the use of the path separator in a name, and
certain names (e.g. C{"."} and C{".."}) may be reserved or have special
meanings.

@since: 12.1
z3The path separator to use in string representationsc                    g)aq  
Obtain a direct child of this file path.  The child may or may not
exist.

@param name: the name of a child of this path. C{name} must be a direct
    child of this path and may not contain a path separator.
@return: the child of this path with the given C{name}.
@raise InsecurePath: if C{name} describes a file path that is not a
    direct child of this file path.
N names    ^/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/filepath.pychildIFilePath.childy           c                    g)z
Opens this file path with the given mode.

@return: a file-like object.
@raise Exception: if this file path cannot be opened.
NrB   )modes    rE   openIFilePath.open   rH   rI   c                     g)zD
Clear any cached information about the state of this path on disk.
NrB   rB   rI   rE   changedIFilePath.changed   rH   rI   c                     g)z
Retrieve the size of this file in bytes.

@return: the size of the file at this file path in bytes.
@raise Exception: if the size cannot be obtained.
NrB   rB   rI   rE   getsizeIFilePath.getsize   rH   rI   c                     g)q
Retrieve the time of last access from this file.

@return: a number of seconds from the epoch.
@rtype: L{float}
NrB   rB   rI   rE   getModificationTimeIFilePath.getModificationTime   rH   rI   c                     g){
Retrieve the time of the last status change for this file.

@return: a number of seconds from the epoch.
@rtype: L{float}
NrB   rB   rI   rE   getStatusChangeTimeIFilePath.getStatusChangeTime   rH   rI   c                     g)t
Retrieve the time that this file was last accessed.

@return: a number of seconds from the epoch.
@rtype: L{float}
NrB   rB   rI   rE   getAccessTimeIFilePath.getAccessTime   rH   rI   c                     g)z
Check if this file path exists.

@return: C{True} if the file at this file path exists, C{False}
    otherwise.
@rtype: L{bool}
NrB   rB   rI   rE   r
   IFilePath.exists   rH   rI   c                     g)z
Check if this file path refers to a directory.

@return: C{True} if the file at this file path is a directory, C{False}
    otherwise.
NrB   rB   rI   rE   isdirIFilePath.isdir   rH   rI   c                     g)z
Check if this file path refers to a regular file.

@return: C{True} if the file at this file path is a regular file,
    C{False} otherwise.
NrB   rB   rI   rE   isfileIFilePath.isfile   rH   rI   c                     g)z
List the children of this path object.

@return: a sequence of the children of the directory at this file path.
@raise Exception: if the file at this file path is not a directory.
NrB   rB   rI   rE   childrenIFilePath.children   rH   rI   c                     g)aM  
Retrieve the final component of the file path's path (everything after
the final path separator).

@note: In implementors, the return type should be generic, i.e.
    C{AbstractFilePath[str].basename()} is a C{str}.  However,
    L{Interface} objects cannot be generic as of this writing.

@return: the base name of this file path.
NrB   rB   rI   rE   r   IFilePath.basename   rH   rI   c                     g)zF
A file path for the directory containing the file at this file path.
NrB   rB   rI   rE   parentIFilePath.parent   rH   rI   c                    g)z
A file path for the directory containing the file at this file path.

@param name: the name of a sibling of this path.  C{name} must be a
    direct sibling of this path and may not contain a path separator.

@return: a sibling file path of this one.
NrB   rC   s    rE   siblingIFilePath.sibling   rH   rI   rB   N)rD   r!   returnr?   rrK   FileModers   	IO[bytes]rs   Noners   intrs   floatrs   bool)rs   zIterable[IFilePath])rs   Union[str, bytes])rs   r?   )__name__
__module____qualname____firstlineno____doc__r.   seprF   rL   rO   rR   rV   rZ   r^   r
   rc   rf   ri   r   rn   rq   __static_attributes__rB   rI   rE   r?   r?   Z   sZ    8 I
JC



rI   r?   c                      \ rS rSrSrSrg)InsecurePath   zH
Error that is raised when the path provided to L{FilePath} is invalid.
rB   Nr   r   r   r   r   r   rB   rI   rE   r   r      s    rI   r   c                      \ rS rSrSrSrg)	LinkError   zv
An error with symlinks - either that there are cyclical symlinks or that
symlink are not supported on this platform.
rB   Nr   rB   rI   rE   r   r      s    rI   r   c                  "    \ rS rSrSrSS jrSrg)UnlistableError   aQ  
An exception which is used to distinguish between errors which mean 'this
is not a directory you can list' and other, more catastrophic errors.

This error will try to look as much like the original error as possible,
while still being catchable as an independent type.

@ivar originalException: the actual original exception instance.
c                Z    U R                   R                  UR                   5        Xl        g)zY
Create an UnlistableError exception.

@param originalException: an instance of OSError.
N)__dict__updateoriginalException)selfr   s     rE   __init__UnlistableError.__init__  s#     	.778!2rI   )r   N)r   OSError)r   r   r   r   r   r   r   rB   rI   rE   r   r      s    3rI   r   c                F    [        [        S5      5      SS n[        X5      $ )z
Compute a string usable as a new, temporary filename.

@param path: The path that the new temporary filename should be able to be
    concatenated with.

@return: A pseudorandom, 16 byte string for use in secure filenames.
@rtype: the type of C{path}
   N)armorrandomBytes_coerceToFilesystemEncoding)pathsecureishStrings     rE   _secureEnoughStringr     s$     KO,Sb1O&t==rI   OtherAnyStr)ru   wazr+zw+za+c                     \ rS rSr% Sr\" SSS9rS\S'   SS jrSS	 jr	SS
 jr
SS S jjrS!S jrS"S jrS#S jrS$S jrS%S jrS&S jrS'S jrS(S jr S)     S*S jjrS+S jr    S,S jrS-S jrS.S jrS.S jrS.S jrS.S jrSrg)/AbstractFilePathi#  aE  
Abstract implementation of an L{IFilePath}; must be completed by a
subclass.

This class primarily exists to provide common implementations of certain
methods in L{IFilePath}. It is *not* a required parent class for
L{IFilePath} implementations, just a useful starting point.

@ivar path: Subclasses must set this variable.
SelfishAbstractFilePath[AnyStr]r<   r!   r   c                    [        5       e)zB
Subclasses must implement this.

@see: L{FilePath.getAccessTime}
NotImplementedErrorr   s    rE   r^   AbstractFilePath.getAccessTime3       "##rI   c                    [        5       e)zH
Subclasses must implement this.

@see: L{FilePath.getModificationTime}
r   r   s    rE   rV   $AbstractFilePath.getModificationTime;  r   rI   c                    [        5       e)zH
Subclasses must implement this.

@see: L{FilePath.getStatusChangeTime}
r   r   s    rE   rZ   $AbstractFilePath.getStatusChangeTimeC  r   rI   c                    [        5       ez!
Subclasses must implement this.
r   r   rK   s     rE   rL   AbstractFilePath.openK       "##rI   c                    [        5       er   r   r   s    rE   rc   AbstractFilePath.isdirQ  r   rI   c                    [        5       er   r   r   s    rE   r   AbstractFilePath.basenameW  r   rI   c                    [        5       er   r   r   s    rE   rn   AbstractFilePath.parent]  r   rI   c                    [        5       er   r   r   s    rE   r   AbstractFilePath.listdirc  r   rI   c                    [        5       er   r   r   r   s     rE   rF   AbstractFilePath.childi  r   rI   c                x    U R                  5        nUR                  5       sSSS5        $ ! , (       d  f       g= f)ze
Retrieve the contents of the file at this path.

@return: the contents of the file
@rtype: L{bytes}
N)rL   read)r   fps     rE   
getContentAbstractFilePath.getContento  s"     YY[B779 [[s   +
9c              #  v   #    U nUR                  5       nX:w  a  Uv   UnUR                  5       nX:w  a  M  gg7f)z
Retrieve an iterator of all the ancestors of this path.

@return: an iterator of all the ancestors of this path, from the most
recent (its immediate parent) to the root of its filesystem.
N)rn   )r   r   rn   s      rE   parentsAbstractFilePath.parentsy  s8      nLD]]_F ns   399c                z    U R                  5       n/ nU H%  nU R                  U5      nUR                  U5        M'     U$ ! [         ao  n[        USS5      [        [        [
        [        4;   a  [        U5      eUR                  [        R                  [        R                  4;   a  [        U5      ee SnAff = f)aI  
List the children of this path object.

@raise OSError: If an error occurs while listing the directory.  If the
error is 'serious', meaning that the operation failed due to an access
violation, exhaustion of some kind of resource (file descriptors or
memory), OSError or a platform-specific variant will be raised.

@raise UnlistableError: If the inability to list the directory is due
to this path not existing or not being a directory, the more specific
OSError subclass L{UnlistableError} is raised instead.

@return: an iterable of all currently-existing children of this object.
winerrorN)r   r   getattrr9   r7   r8   r6   r   errnoENOENTENOTDIRrF   append)r   subnamesoseresultrD   rF   s         rE   ri   AbstractFilePath.children  s    	%)\\^H2 D  ::d+EMM%   ?  	 sJ-$$"	2  &c**yyU\\5==99%c** /	s   A 
B:A*B55B:Nc              #    #    U v   U R                  5       (       a  U R                  5        H  nUb  U" U5      (       a  UR                  U5       Hv  n[        R                  R                  U R                  5      R                  [        R                  R                  UR                  5      5      (       a  [        S5      eUv   Mx     M  Uv   M     gg7f)a[  
Yield myself, then each of my children, and each of those children's
children in turn.

The optional argument C{descend} is a predicate that takes a FilePath,
and determines whether or not that FilePath is traversed/descended
into.  It will be called with each path for which C{isdir} returns
C{True}.  If C{descend} is not specified, all directories will be
traversed (including symbolic links which refer to directories).

@param descend: A one-argument callable that will return True for
    FilePaths that should be traversed, False otherwise.

@return: a generator yielding FilePath-like objects.
NzCycle in file graph.)rc   ri   walkosr   realpath
startswithr   )r   descendcsubcs       rE   r   AbstractFilePath.walk  s     & 
::<<]]_ ?gajj !w77++DII6AAGG,,TYY7  #,,B"CC"
 !0 G % s   CCc                @    U R                  5       R                  U5      $ )as  
Return a L{FilePath} with the same directory as this instance but with
a basename of C{path}.

@note: for type-checking, subclasses should override this signature to
    make it clear that it returns the subclass and not
    L{AbstractFilePath}.

@param path: The basename of the L{FilePath} to return.
@type path: L{str}

@return: The sibling path.
@rtype: L{FilePath}
)rn   rF   r   s     rE   rq   AbstractFilePath.sibling  s     {{}""4((rI   c                >    U nU H  nUR                  U5      nM     U$ )a  
Retrieve a child or child's child of this path.

@note: for type-checking, subclasses should override this signature to
    make it clear that it returns the subclass and not
    L{AbstractFilePath}.

@param segments: A sequence of path segments as L{str} instances.

@return: A L{FilePath} constructed by looking up the C{segments[0]}
    child of this path, the C{segments[1]} child of that path, and so
    on.

@since: 10.2
)rF   )r   segmentsr   rD   s       rE   
descendantAbstractFilePath.descendant  s&    $ /3D::d#D rI   c                    U nUR                  5       n/ nX!:w  a7  X2:w  a2  UR                  5       /USS& UnUR                  5       nX!:w  a  X2:w  a  M2  X!:X  a	  U(       a  U$ [        U< SU < 35      e)a  
Return a list of segments between a child and its ancestor.

For example, in the case of a path X representing /a/b/c/d and a path Y
representing /a/b, C{Y.segmentsFrom(X)} will return C{['c',
'd']}.

@param ancestor: an instance of the same class as self, ostensibly an
ancestor of self.

@raise ValueError: If the C{ancestor} parameter is not actually an
ancestor, i.e. a path for /x/y/z is passed as an ancestor for /a/b/c/d.

@return: a list of strs
r   z not parent of )rn   r   
ValueError)r   ancestorfpr   s        rE   segmentsFromAbstractFilePath.segmentsFrom  st    & 88:!#mZZ\NHQqMA
A m =XOH<th?@@rI   c                D    [        U R                  U R                  45      $ )zJ
Hash the same as another L{AbstractFilePath} with the same path as mine.
)hash	__class__r   r   s    rE   __hash__AbstractFilePath.__hash__#  s     T^^TYY/00rI   c                4    [        U R                  5       5      $ )z/
Deprecated.  Use getModificationTime instead.
)r|   rV   r   s    rE   getmtimeAbstractFilePath.getmtime*       4++-..rI   c                4    [        U R                  5       5      $ )z)
Deprecated.  Use getAccessTime instead.
)r|   r^   r   s    rE   getatimeAbstractFilePath.getatime0  s     4%%'((rI   c                4    [        U R                  5       5      $ )z/
Deprecated.  Use getStatusChangeTime instead.
)r|   rZ   r   s    rE   getctimeAbstractFilePath.getctime6  r   rI   rB   r}   rt   rv   r   rs   r!   )rs   r   rs   List[AnyStr])r   r   rs   AbstractFilePath[OtherAnyStr])rs   bytes)rs   z"Iterable[AbstractFilePath[AnyStr]])r   r;   rs   Iterable[_Self]N)r   r;   r   z!Optional[Callable[[_Self], bool]]rs   r  )r   r;   r   r   rs   r   )r   Sequence[OtherAnyStr]rs   r   )r   r;   r   r;   rs   r   r{   )r   r   r   r   r   r*   r   __annotations__r^   rV   rZ   rL   rc   r   rn   r   rF   r   r   ri   r   rq   r   r   r   r   r   r   r   rB   rI   rE   r   r   #  s    	 i'ABG
L$$$$$$$$$%0h 6:  2  
 D)"-	&.A>1/)/rI   r   c                  :    \ rS rSrSrSrS	S jrS
S jrS
S jrSr	g)RWXi=  a  
A class representing read/write/execute permissions for a single user
category (i.e. user/owner, group, or other/world).  Instantiate with
three boolean values: readable? writable? executable?.

@type read: C{bool}
@ivar read: Whether permission to read is given

@type write: C{bool}
@ivar write: Whether permission to write is given

@type execute: C{bool}
@ivar execute: Whether permission to execute is given

@since: 11.1
r   writeexecutec                (    Xl         X l        X0l        g r  r  )r   readablewritable
executables       rE   r   RWX.__init__Q  s    	
!rI   c                d    SR                  U R                  U R                  U R                  5      $ )Nz"RWX(read={}, write={}, execute={}))formatr   r  r	  r   s    rE   __repr__RWX.__repr__V  s*    3::IIJJLL
 	
rI   c                    / SQnSnU R                   U R                  U R                  4 H  nU(       d  SX'   US-  nM     SR                  U5      $ )z
Returns a short string representing the permission bits.  Looks like
part of what is printed by command line utilities such as 'ls -l'
(e.g. 'rwx')

@return: The shorthand string.
@rtype: L{str}
)ru   r   xr   -    )r   r  r	  r   )r   	returnvalivals       rE   	shorthandRWX.shorthand]  sO     $	IItzz4<<8C"	FA 9 wwy!!rI   )r	  r   r  N)r  r   r  r   r  r   rs   rz   rs   str
r   r   r   r   r   compareAttributesr   r  r  r   rB   rI   rE   r  r  =  s    " 5"

"rI   r  c                  :    \ rS rSrSrSrS	S jrS
S jrS
S jrSr	g)Permissionsio  a=  
A class representing read/write/execute permissions.  Instantiate with any
portion of the file's mode that includes the permission bits.

@type user: L{RWX}
@ivar user: User/Owner permissions

@type group: L{RWX}
@ivar group: Group permissions

@type other: L{RWX}
@ivar other: Other/World permissions

@since: 11.1
)usergroupotherc                   ^ U4S j[         [        [        /[        [        [
        /[        [        [        /4 5       u  U l	        U l
        U l        g )Nc              3  H   >#    U  H  n[        U4S  jU 5       6 v   M     g7f)c              3  4   >#    U  H  nTU-  S :  v   M     g7f)r   NrB   ).0bitstatModeInts     rE   	<genexpr>1Permissions.__init__.<locals>.<genexpr>.<genexpr>  s     <8C+#a'8s   N)r  )r)  bitGroupr+  s     rE   r,  'Permissions.__init__.<locals>.<genexpr>  s'      -
 <8<=s   ")r   r   r   r   r   r   r   r   r   r#  r$  r%  )r   r+  s    `rE   r   Permissions.__init__  sA    -
 '7+'7+'7+-
)	4:tzrI   c                    S[        U R                  5       S[        U R                  5       S[        U R                  5       S3$ )N[z | ])r  r#  r$  r%  r   s    rE   r  Permissions.__repr__  s8    3tyy>"#c$**o%6c#djj/9J!LLrI   c                    SR                  U R                  U R                  U R                  4 Vs/ s H  oR	                  5       PM     sn5      $ s  snf )z
Returns a short string representing the permission bits.  Looks like
what is printed by command line utilities such as 'ls -l'
(e.g. 'rwx-wx--x')

@return: The shorthand string.
@rtype: L{str}
r  )r   r#  r$  r%  r  )r   r  s     rE   r  Permissions.shorthand  s>     ww		4::tzz/RS/R!/RSTTSs   A)r$  r%  r#  N)r+  r|   rs   rz   r  r  rB   rI   rE   r"  r"  o  s       3
M	UrI   r"  c                    [        U [        5      (       a  U $ U(       d  [        R                  " 5       nU R	                  USS9$ )a2  
Return C{path} as a string of L{bytes} suitable for use on this system's
filesystem.

@param path: The path to be made suitable.
@type path: L{bytes} or L{unicode}
@param encoding: The encoding to use if coercing to L{bytes}. If none is
    given, L{sys.getfilesystemencoding} is used.

@return: L{bytes}
surrogateescapeerrors)
isinstancer   sysgetfilesystemencodingencoder   encodings     rE   _asFilesystemBytesrA    s;     $002H{{8,={>>rI   c                    [        U [        5      (       a  U $ Uc  [        R                  " 5       nU R	                  USS9$ )a9  
Return C{path} as a string of L{unicode} suitable for use on this system's
filesystem.

@param path: The path to be made suitable.
@type path: L{bytes} or L{unicode}

@param encoding: The encoding to use if coercing to L{unicode}. If none
    is given, L{sys.getfilesystemencoding} is used.

@return: L{unicode}
r8  r9  )r;  r  r<  r=  decoder?  s     rE   _asFilesystemTextrD    s>     $002H{{8,={>>rI   c                P    [        U [        5      (       a	  [        XS9$ [        XS9$ )a  
Return a C{newpath} that is suitable for joining to C{path}.

@param path: The path that it should be suitable for joining to.
@param newpath: The new portion of the path to be coerced if needed.
@param encoding: If coerced, the encoding that will be used.
r@  )r;  r   rA  rD  )r   newpathr@  s      rE   r   r     s'     $!'== <<rI   c                  h   \ rS rSr% SrSrS\S'   SJSKS jjr\(       a-  SLS jr	SMS jr
SNS	 jrSOS
 jrSOS jrSOS jrSOS jrSOS jrSOS jr SJ     SPS jjrSQS jr\SRS j5       rSSSTS jjrSSSUS jjrSSSVS jjrSSSWS jjrSXS jrSYS jrSYS jr    SZS jr    S[S jrS\S jrS]S jr S^S jr!S_S`S jjr"SaSbS  jjr#ScS! jr$SdS" jr%SeS# jr&SfS$ jr'SfS% jr(SfS& jr)SeS' jr*SeS( jr+SeS) jr,SeS* jr-SeS+ jr.SgS, jr/ShS- jr0ShS. jr1ShS/ jr2ShS0 jr3ShS1 jr4ShS2 jr5ShS3 jr6SiS4 jr7SjS5 jr8SkS6 jr9ScS7 jr:ScS8 jr;SJSlS9 jjr<SmS: jr=SRS; jr>SRS< jr?S\S= jr@SnSoS> jjrASpS? jrBScS@ jrCSaSqSA jjrDSrSB jrE\FS\SC j5       rG\F    SsSD j5       rG SS   SsSE jjrGSFrH Sa     StSG jjrI Sa     StSH jjrJSIrKg)uFilePathi  aG  
I am a path on the filesystem that only permits 'downwards' access.

Instantiate me with a pathname (for example,
FilePath('/home/myuser/public_html')) and I will attempt to only provide
access to files which reside inside that path.  I may be a path to a file,
a directory, or a file which does not exist.

The correct way to use me is to instantiate me, and then do ALL filesystem
access through me.  In other words, do not import the 'os' module; if you
need to open a file, call my 'open' method.  If you need to list a
directory, call my 'path' method.

Even if you pass me a relative path, I will convert that to an absolute
path internally.

The type of C{path} when instantiating decides the mode of the L{FilePath}.
That is, C{FilePath(b"/")} will return a L{bytes} mode L{FilePath}, and
C{FilePath(u"/")} will return a L{unicode} mode L{FilePath}.
C{FilePath("/")} will return a L{bytes} mode L{FilePath} on Python 2, and a
L{unicode} mode L{FilePath} on Python 3.

Methods that return a new L{FilePath} use the type of the given subpath to
decide its mode. For example, C{FilePath(b"/").child(u"tmp")} will return a
L{unicode} mode L{FilePath}.

@type alwaysCreate: L{bool}
@ivar alwaysCreate: When opening this file, only succeed if the file does
    not already exist.

@ivar path: The path from which 'downward' traversal is permitted.
Nr!   r   c                0    [        U5      U l        X l        g)zh
Convert a path string to an absolute path if necessary and initialize
the L{FilePath} with the result.
N)r   r   alwaysCreater   r   rK  s      rE   r   FilePath.__init__  s    
 DM	(rI   c                    g r  rB   r   s     rE   rq   FilePath.sibling      rI   c                    g r  rB   )r   r   s     rE   r   FilePath.descendant  rP  rI   c                    g r  rB   r   s    rE   r   FilePath.parents  rP  rI   c                    g r  rB   r   r%  s     rE   __gt__FilePath.__gt__  rP  rI   c                    g r  rB   rV  s     rE   __ge__FilePath.__ge__  rP  rI   c                    g r  rB   rV  s     rE   __lt__FilePath.__lt__  rP  rI   c                    g r  rB   rV  s     rE   __le__FilePath.__le__  rP  rI   c                    g r  rB   rV  s     rE   __eq__FilePath.__eq__  rP  rI   c                    g r  rB   rV  s     rE   __ne__FilePath.__ne__  rP  rI   c                    [        U5      $ )zM
Make an object of the same type as this FilePath, but with path of
C{path}.
)rI  rL  s      rE   	clonePathFilePath.clonePath!  s     ~rI   c                L    U R                   R                  5       nSU;   a  US	 U$ )z^
Support serialization by discarding cached L{os.stat} results and
returning everything else.
	_statinfo)r   copy)r   ds     rE   __getstate__FilePath.__getstate__*  s*    
 MM !+rI   c                J    [        U R                  [        R                  5      $ )zw
Return a filesystem separator.

@return: The native filesystem separator.
@returntype: The same type as C{self.path}.
)r   r   r   r   r   s    rE   r   FilePath.sep4  s     +499bff==rI   c                *    [        U R                  US9$ )z
Return the path of this L{FilePath} as bytes.

@param encoding: The encoding to use if coercing to L{bytes}. If none is
    given, L{sys.getfilesystemencoding} is used.

@return: L{bytes}
rF  )rA  r   r   r@  s     rE   _asBytesPathFilePath._asBytesPath>  s     "$))h??rI   c                *    [        U R                  US9$ )z
Return the path of this L{FilePath} as text.

@param encoding: The encoding to use if coercing to L{unicode}. If none
    is given, L{sys.getfilesystemencoding} is used.

@return: L{unicode}
rF  )rD  r   rt  s     rE   _asTextPathFilePath._asTextPathI  s     !X>>rI   c                    [        U R                  [        5      (       a  U R                  U R	                  US95      $ U $ )z
Return this L{FilePath} in L{bytes}-mode.

@param encoding: The encoding to use if coercing to L{bytes}. If none is
    given, L{sys.getfilesystemencoding} is used.

@return: L{bytes} mode L{FilePath}
rF  )r;  r   r  ri  ru  rt  s     rE   asBytesModeFilePath.asBytesModeT  s7     dii%%>>$"3"3X"3"FGGrI   c                    [        U R                  [        5      (       a  U R                  U R	                  US95      $ U $ )z
Return this L{FilePath} in L{unicode}-mode.

@param encoding: The encoding to use if coercing to L{unicode}. If none
    is given, L{sys.getfilesystemencoding} is used.

@return: L{unicode} mode L{FilePath}
rF  )r;  r   r   ri  rx  rt  s     rE   
asTextModeFilePath.asTextModea  s7     dii''>>$"2"2H"2"EFFrI   c                l    [        U[        5      (       a  U R                  5       $ U R                  5       $ )z
If C{pattern} is C{bytes}, return L{FilePath.path} as L{bytes}.
Otherwise, return L{FilePath.path} as L{unicode}.

@param pattern: The new element of the path that L{FilePath.path} may
    need to be coerced to match.
)r;  r   ru  rx  )r   patterns     rE   _getPathAsSameTypeAsFilePath._getPathAsSameTypeAsn  s/     gu%%$$&&##%%rI   c                   [        US5      n[        U[        R                  5      nU R                  U5      n[        R
                  " 5       (       a%  UR                  U5      (       a  [        U< S35      e[        U5      nX5;   a  [        U< S35      e[        [        XE5      5      nUR                  U5      (       d  [        U< SU< 35      eU R                  U5      $ )a  
Create and return a new L{FilePath} representing a path contained by
C{self}.

@param path: The base name of the new L{FilePath}.  If this contains
    directory separators or parent references it will be rejected.
@type path: L{bytes} or L{unicode}

@raise InsecurePath: If the result of combining this path with C{path}
    would result in a path which is not a direct child of this path.

@return: The child path.
@rtype: L{FilePath} with a mode equal to the type of C{path}.
:z contains a colon.z* contains one or more directory separators is not a child of )r   r   r   r  r4   	isWindowscountr   r   r   joinpathr   ri  )r   r   colonr   ourPathnormrG  s          rE   rF   FilePath.child{  s     ,D#6)$7++D1DJJu$5$5$);<==~;$)STUU(712!!'**',?{KLL~~g&&rI   c                    U R                  U5      n[        [        U[        U5      5      5      nUR	                  U5      (       d  [        U< SU< 35      eU R                  U5      $ )aL  
Use me if C{path} might have slashes in it, but you know they're safe.

@param path: A relative path (ie, a path not starting with C{"/"})
    which will be interpreted as a child or descendant of this path.
@type path: L{bytes} or L{unicode}

@return: The child path.
@rtype: L{FilePath} with a mode equal to the type of C{path}.
r  )r  r   r  r   r   r   ri  )r   r   r  rG  s       rE   preauthChildFilePath.preauthChild  s`     ++D1(7HTN;<!!'**',?{KLL~~g&&rI   c                    U HB  nU R                  U5      n[        X25      n[        U5      (       d  M1  U R                  U5      s  $    g)a`  
Return my first existing child with a name in C{paths}.

C{paths} is expected to be a list of *pre-secured* path fragments;
in most cases this will be specified by a system administrator and not
an arbitrary user.

If no appropriately-named children exist, this will return L{None}.

@return: L{None} or the child path.
@rtype: L{None} or L{FilePath}
N)r  r  r
   ri  )r   pathsrF   r   jps        rE   childSearchPreauthFilePath.childSearchPreauth  sE     E))%0A!#Bbzz~~b))	 
 rI   c           	     
   U H  nU(       d7  U R                  5       (       a"  U R                  U R                  U5      5      s  $ U R                  U5      n[        US5      n[        US5      nX$:X  ag  [	        U5      U-   n[        [        U5      5       HA  nUR                  U5      (       d  M  U R                  [        [        U5      U5      5      s  s  $    X2-   n[        U5      (       d  M  U R                  U5      s  $    g)a  
Attempt to return a path with my name, given multiple possible
extensions.

Each extension in C{exts} will be tested and the first path which
exists will be returned.  If no path exists, L{None} will be returned.
If C{''} is in C{exts}, then if the file referred to by this path
exists, C{self} will be returned.

The extension '*' has a magic meaning, which means "any path that
begins with C{self.path + '.'} is acceptable".
*.N)	r
   ri  r  r   r   r   r	   r   r  )	r   extsextr   stardotbasedotfnp2s	            rE   siblingExtensionSearchFilePath.siblingExtensionSearch  s     C4;;==~~d&?&?&DEE))#.A.sC8D-c37C{"1++!'!*-B}}W--#~~hwqz2.FGG . Bbzz~~b))   rI   c                    U R                  5       (       aT  [        R                  R                  U R                  5      nXR                  :X  a  [	        S5      eU R                  U5      $ U $ )ag  
Returns the absolute target as a L{FilePath} if self is a link, self
otherwise.

The absolute link is the ultimate file or directory the
link refers to (for instance, if the link refers to another link, and
another...).  If the filesystem does not support symlinks, or
if the link is cyclical, raises a L{LinkError}.

Behaves like L{os.path.realpath} in that it does not resolve link
names in the middle (ex. /x/y/z, y is a link to w - realpath on z
will return /x/y/z, not /x/w/z).

@return: L{FilePath} of the target path.
@rtype: L{FilePath}
@raises LinkError: if links are not supported or links are cyclical.
z!Cyclical link - will loop forever)r   r   r   r   r   ri  )r   r   s     rE   r   FilePath.realpath  sQ    $ ;;==WW%%dii0F" CDD>>&))rI   c                J    U R                  U5      nU R                  X!-   5      $ )z
Attempt to return a path with my name, given the extension at C{ext}.

@param ext: File-extension to search for.
@type ext: L{bytes} or L{unicode}

@return: The sibling path.
@rtype: L{FilePath} with the same mode as the type of C{ext}.
)r  ri  )r   r  r  s      rE   siblingExtensionFilePath.siblingExtension  s%     ++C0~~gm,,rI   c                Z    [         R                  " U R                  UR                  5        g)av  
Creates a symlink to self to at the path in the L{FilePath}
C{linkFilePath}.

Only works on posix systems due to its dependence on
L{os.symlink}.  Propagates L{OSError}s up from L{os.symlink} if
C{linkFilePath.parent()} does not exist, or C{linkFilePath} already
exists.

@param linkFilePath: a FilePath representing the link to be created.
@type linkFilePath: L{FilePath}
N)r   symlinkr   )r   linkFilePaths     rE   linkToFilePath.linkTo
  s     	

499l//0rI   c                    U R                   (       a  SU;  d   S5       eU R                  5       $ [        U R                  UR	                  SS5      S-   5      $ )as  
Open this file using C{mode} or for writing if C{alwaysCreate} is
C{True}.

In all cases the file is opened in binary mode, so it is not necessary
to include C{"b"} in C{mode}.

@param mode: The mode to open the file in.  Default is C{"r"}.
@raises AssertionError: If C{"a"} is included in the mode and
    C{alwaysCreate} is C{True}.
@return: An open file-like object.
r   z1Appending not supported when alwaysCreate == Truebr  )rK  createrL   r   replacer   s     rE   rL   FilePath.open  sR     d? F? ;;= DIIt||C4s:;;rI   c                x     [        U R                  5      U l        g! [         a    SU l        U(       a  e  gf = f)a  
Re-calculate cached effects of 'stat'.  To refresh information on this
path after you know the filesystem may have changed, call this method.

@param reraise: a boolean.  If true, re-raise exceptions from
    L{os.stat}; otherwise, mark this path as not existing, and remove
    any cached stat information.

@raise Exception: If C{reraise} is C{True} and an exception occurs
    while reloading metadata.
N)r   r   rl  r   )r   reraises     rE   restatFilePath.restat0  s7    	!$))_DN 	!DN 	s    99c                    SU l         g)zT
Clear any cached information about the state of this path on disk.

@since: 10.1.0
N)rl  r   s    rE   rO   FilePath.changedC  s     rI   c                F    [         R                  " U R                  U5        g)z
Changes the permissions on self, if possible.  Propagates errors from
L{os.chmod} up.

@param mode: integer representing the new permissions desired (same as
    the command line chmod)
@type mode: L{int}
N)r   chmodr   r   s     rE   r  FilePath.chmodK  s     	D!rI   c                    U R                   nU(       d  U R                  5         U R                   nUc   eUR                  $ )z
Retrieve the size of this file in bytes.

@return: The size of the file at this file path in bytes.
@raise Exception: if the size cannot be obtained.
@rtype: L{int}
)rl  r  st_sizer   sts     rE   rR   FilePath.getsizeV  s6     ^^KKMB~~zzrI   c                    U R                   nU(       d  U R                  5         U R                   nUc   e[        UR                  5      $ )rU   )rl  r  r~   st_mtimer  s     rE   rV   FilePath.getModificationTimee  ;     ^^KKMB~~R[[!!rI   c                    U R                   nU(       d  U R                  5         U R                   nUc   e[        UR                  5      $ )rY   )rl  r  r~   st_ctimer  s     rE   rZ   FilePath.getStatusChangeTimes  r  rI   c                    U R                   nU(       d  U R                  5         U R                   nUc   e[        UR                  5      $ )r]   )rl  r  r~   st_atimer  s     rE   r^   FilePath.getAccessTime  r  rI   c                    [         R                  " 5       (       a  [        eU R                  nU(       d  U R	                  5         U R                  nUc   eUR
                  $ )aY  
Retrieve the file serial number, also called inode number, which
distinguishes this file from all other files on the same device.

@raise NotImplementedError: if the platform is Windows, since the
    inode number would be a dummy value for all files in Windows
@return: a number representing the file serial number
@rtype: L{int}
@since: 11.0
)r4   r  r   rl  r  st_inor  s     rE   getInodeNumberFilePath.getInodeNumber  sK     %%^^KKMB~~yyrI   c                    [         R                  " 5       (       a  [        eU R                  nU(       d  U R	                  5         U R                  nUc   eUR
                  $ )a  
Retrieves the device containing the file.  The inode number and device
number together uniquely identify the file, but the device number is
not necessarily consistent across reboots or system crashes.

@raise NotImplementedError: if the platform is Windows, since the
    device number would be 0 for all partitions on a Windows platform

@return: a number representing the device
@rtype: L{int}

@since: 11.0
)r4   r  r   rl  r  st_devr  s     rE   	getDeviceFilePath.getDevice  sK     %%^^KKMB~~yyrI   c                    [         R                  " 5       (       a  [        eU R                  nU(       d  U R	                  5         U R                  nUc   eUR
                  $ )a$  
Retrieves the number of hard links to the file.

This count keeps track of how many directories have entries for this
file. If the count is ever decremented to zero then the file itself is
discarded as soon as no process still holds it open.  Symbolic links
are not counted in the total.

@raise NotImplementedError: if the platform is Windows, since Windows
    doesn't maintain a link count for directories, and L{os.stat} does
    not set C{st_nlink} on Windows anyway.
@return: the number of hard links to the file
@rtype: L{int}
@since: 11.0
)r4   r  r   rl  r  st_nlinkr  s     rE   getNumberOfHardLinksFilePath.getNumberOfHardLinks  sK      %%^^KKMB~~{{rI   c                    [         R                  " 5       (       a  [        eU R                  nU(       d  U R	                  5         U R                  nUc   eUR
                  $ )z
Returns the user ID of the file's owner.

@raise NotImplementedError: if the platform is Windows, since the UID
    is always 0 on Windows
@return: the user ID of the file's owner
@rtype: L{int}
@since: 11.0
)r4   r  r   rl  r  st_uidr  s     rE   	getUserIDFilePath.getUserID  K     %%^^KKMB~~yyrI   c                    [         R                  " 5       (       a  [        eU R                  nU(       d  U R	                  5         U R                  nUc   eUR
                  $ )z
Returns the group ID of the file.

@raise NotImplementedError: if the platform is Windows, since the GID
    is always 0 on windows
@return: the group ID of the file
@rtype: L{int}
@since: 11.0
)r4   r  r   rl  r  st_gidr  s     rE   
getGroupIDFilePath.getGroupID  r  rI   c                    U R                   nU(       d  U R                  5         U R                   nUc   e[        [        UR                  5      5      $ )z
Returns the permissions of the file.  Should also work on Windows,
however, those permissions may not be what is expected in Windows.

@return: the permissions for the file
@rtype: L{Permissions}
@since: 11.1
)rl  r  r"  r   st_moder  s     rE   getPermissionsFilePath.getPermissions  s@     ^^KKMB~~72::.//rI   c                n    U R                   (       a  gU R                  S5        U R                   (       a  gg)z
Check if this L{FilePath} exists.

@return: C{True} if the stats of C{path} can be retrieved successfully,
    C{False} in the other cases.
@rtype: L{bool}
TF)rl  r  r   s    rE   r
   FilePath.exists  s'     >>KK~~rI   c                    U R                   nU(       d%  U R                  S5        U R                   nU(       d  g[        UR                  5      $ )z
Check if this L{FilePath} refers to a directory.

@return: C{True} if this L{FilePath} refers to a directory, C{False}
    otherwise.
@rtype: L{bool}
F)rl  r  r   r  r  s     rE   rc   FilePath.isdir  :     ^^KKBrzz""rI   c                    U R                   nU(       d%  U R                  S5        U R                   nU(       d  g[        UR                  5      $ )z
Check if this file path refers to a regular file.

@return: C{True} if this L{FilePath} points to a regular file (not a
    directory, socket, named pipe, etc), C{False} otherwise.
@rtype: L{bool}
F)rl  r  r   r  r  s     rE   rf   FilePath.isfile/  r  rI   c                    U R                   nU(       d%  U R                  S5        U R                   nU(       d  g[        UR                  5      $ )z
Returns whether the underlying path is a block device.

@return: C{True} if it is a block device, C{False} otherwise
@rtype: L{bool}
@since: 11.1
F)rl  r  r   r  r  s     rE   isBlockDeviceFilePath.isBlockDevice?  r  rI   c                    U R                   nU(       d%  U R                  S5        U R                   nU(       d  g[        UR                  5      $ )z
Returns whether the underlying path is a socket.

@return: C{True} if it is a socket, C{False} otherwise
@rtype: L{bool}
@since: 11.1
F)rl  r  r   r  r  s     rE   isSocketFilePath.isSocketO  s:     ^^KKB

##rI   c                ,    [        U R                  5      $ )z
Check if this L{FilePath} points to a symbolic link.

@return: C{True} if this L{FilePath} points to a symbolic link,
    C{False} otherwise.
@rtype: L{bool}
)r   r   r   s    rE   r   FilePath.islink_  s     dii  rI   c                ,    [        U R                  5      $ )z
Check if this L{FilePath} refers to an absolute path.

This always returns C{True}.

@return: C{True}, always.
@rtype: L{bool}
)r   r   r   s    rE   r   FilePath.isabsm  s     TYYrI   c                ,    [        U R                  5      $ )aX  
List the base names of the direct children of this L{FilePath}.

@return: A L{list} of L{bytes}/L{unicode} giving the names of the
    contents of the directory this L{FilePath} refers to. These names
    are relative to this L{FilePath}.
@rtype: L{list}

@raise OSError: Any exception the platform L{os.listdir} implementation
    may raise.
)r   r   r   s    rE   r   FilePath.listdirx  s     tyy!!rI   c                ,    [        U R                  5      $ )z
Split the file path into a pair C{(root, ext)} such that
C{root + ext == path}.

@return: Tuple where the first item is the filename and second item is
    the file extension. See Python docs for L{os.path.splitext}.
@rtype: L{tuple}
)r   r   r   s    rE   r   FilePath.splitext       		""rI   c                $    SU R                   < S3$ )Nz	FilePath())r   r   s    rE   r  FilePath.__repr__  s    499-q))rI   c                     U R                  S5      R                  5         [        U R                  S5        g! [         a     N#f = f)z
Updates the access and last modification times of the file at this
file path to the current time. Also creates the file if it does not
already exist.

@raise Exception: if unable to create or modify the last modification
    time of the file.
r   N)rL   closer   r   r   r   s    rE   touchFilePath.touch  s?    	IIcN  " 	dii  		s   8 
AAc                H   U R                  5       (       a]  U R                  5       (       dH  U R                  5        H  nUR                  5         M     [        R
                  " U R                  5        O [        R                  " U R                  5        U R                  5         g)z
Removes the file or directory that is represented by self.  If
C{self.path} is a directory, recursively remove all its children
before removing the directory. If it's a file or link, just delete it.
N)rc   r   ri   remover   rmdirr   rO   )r   rF   s     rE   r   FilePath.remove  s[     ::<< )HHTYYIIdii rI   c                     [         R                  " U R                  5        g! [         aE  nUR                  [        R
                  :X  a  U(       a  U R                  5       (       d  e  SnAgSnAff = f)z
Create all directories not yet existing in C{path} segments, using
L{os.makedirs}.

@param ignoreExistingDirectory: Don't raise L{OSError} if directory
    already exists.
@type ignoreExistingDirectory: L{bool}

@return: L{None}
N)r   makedirsr   r   r   EEXISTrc   )r   ignoreExistingDirectoryes      rE   r  FilePath.makedirs  sN    	KK		" 	5<<',C

 IU	s    # 
A2;A--A2c                "   [        U[        R                  5      nU R                  U5      nSSKnUS   U:H  =(       a    X1-   =(       d    UR                  X1/5      nUR	                  U5       Vs/ s H  o`R                  U5      PM     sn$ s  snf )aK  
Assuming I am representing a directory, return a list of FilePaths
representing my children that match the given pattern.

@param pattern: A glob pattern to use to match child paths.
@type pattern: L{unicode} or L{bytes}

@return: A L{list} of matching children.
@rtype: L{list} of L{FilePath}, with the mode of C{pattern}'s type
r   N)r   r   r   r  globr   ri  )r   r  r   r  r  r   r   s          rE   globChildrenFilePath.globChildren  su     *'266:++G4r{c!7g&7W388WDV;W+/99T?;?aq!?;;;s   /Bc                ,    [        U R                  5      $ )a
  
Retrieve the final component of the file path's path (everything
after the final path separator).

@return: The final component of the L{FilePath}'s path (Everything
    after the final path separator).
@rtype: the same type as this L{FilePath}'s C{path} attribute
)r   r   r   s    rE   r   FilePath.basename  r  rI   c                ,    [        U R                  5      $ )a8  
Retrieve all of the components of the L{FilePath}'s path except the
last one (everything up to the final path separator).

@return: All of the components of the L{FilePath}'s path except the
    last one (everything up to the final path separator).
@rtype: the same type as this L{FilePath}'s C{path} attribute
)r	   r   r   s    rE   r	   FilePath.dirname  s     tyy!!rI   c                @    U R                  U R                  5       5      $ )z
A file path for the directory containing the file at this file path.

@return: A L{FilePath} representing the path which directly contains
    this L{FilePath}.
@rtype: L{FilePath}
)ri  r	   r   s    rE   rn   FilePath.parent  s     ~~dlln--rI   c                   U R                  U5      nUR                  S5       nUR                  U5        SSS5        [        R                  " 5       (       a:  [        U R                  5      (       a   [        R                  " U R                  5        [        R                  " UR                  U R                  5       R                  5        g! , (       d  f       N= f)a  
Replace the file at this path with a new file that contains the given
bytes, trying to avoid data-loss in the meanwhile.

On UNIX-like platforms, this method does its best to ensure that by the
time this method returns, either the old contents I{or} the new
contents of the file will be present at this path for subsequent
readers regardless of premature device removal, program crash, or power
loss, making the following assumptions:

    - your filesystem is journaled (i.e. your filesystem will not
      I{itself} lose data due to power loss)

    - your filesystem's C{rename()} is atomic

    - your filesystem will not discard new data while preserving new
      metadata (see U{http://mjg59.livejournal.com/108257.html} for
      more detail)

On most versions of Windows there is no atomic C{rename()} (see
U{http://bit.ly/win32-overwrite} for more information), so this method
is slightly less helpful.  There is a small window where the file at
this path may be deleted before the new file is moved to replace it:
however, the new file will be fully written and flushed beforehand so
in the unlikely event that there is a crash at that point, it should be
possible for the user to manually recover the new version of their
data.  In the future, Twisted will support atomic file moves on those
versions of Windows which I{do} support them: see U{Twisted ticket
3004<http://twistedmatrix.com/trac/ticket/3004>}.

This method should be safe for use by multiple concurrent processes,
but note that it is not easy to predict which process's contents will
ultimately end up on disk if they invoke this method at close to the
same time.

@param content: The desired contents of the file at this path.
@type content: L{bytes}

@param ext: An extension to append to the temporary filename used to
    store the bytes while they are being written.  This can be used to
    make sure that temporary files can be identified by their suffix,
    for cleanup in case of crashes.
@type ext: L{bytes}
r   N)temporarySiblingrL   r  r4   r  r
   r   r   unlinkrenamer{  )r   contentr  sibr   s        rE   
setContentFilePath.setContent  s    Z ##C(XXc]aGGG F499$5$5IIdii 
		#((D,,.334	 ]s   C
Cc                x    [        U[        5      (       d  [        $ [        U R                  UR                  5      $ r  )r;  rI  NotImplementedr2   r   rV  s     rE   __cmp__FilePath.__cmp__+  s*    %**!!499ejj))rI   c                D    [         R                  " U R                  5        g)zy
Create the directory the L{FilePath} refers to.

@see: L{makedirs}

@raise OSError: If the directory cannot be created.
N)r   mkdirr   r   s    rE   createDirectoryFilePath.createDirectory0  s     	rI   c                    Xl         g)z
Sets the C{alwaysCreate} variable.

@param val: C{True} or C{False}, indicating whether opening this path
    will be required to create the file or not.
@type val: L{bool}

@return: L{None}
N)rK  )r   r  s     rE   requireCreateFilePath.requireCreate:  s
      rI   c                    [         R                  " U R                  [        5      n[	        [
        [           [         R                  " US5      5      $ )z|
Exclusively create a file, only if this file previously did not exist.

@return: A file-like object opened from this path.
zw+b)r   rL   r   _CREATE_FLAGSr,   r   r   fdopen)r   fdints     rE   r  FilePath.createF  s6     		=1 BuIryy677rI   c                    g r  rB   r   s    rE   r  FilePath.temporarySiblingT  s    rI   c                    g r  rB   )r   	extensions     rE   r  r-  X  s     	rI   c                    Uc  U R                   SS nOUnU R                  U5      nU R                  [        U5      U R	                  U5      R                  5       -   U-   5      nUR                  5         U$ )av  
Construct a path referring to a sibling of this path.

The resulting path will be unpredictable, so that other subprocesses
should neither accidentally attempt to refer to the same path before it
is created, nor they should other processes be able to guess its name
in advance.

@param extension: A suffix to append to the created filename.  (Note
    that if you want an extension with a '.' you must include the '.'
    yourself.)
@type extension: L{bytes} or L{unicode}

@return: a path object with the given extension suffix, C{alwaysCreate}
    set to True.
@rtype: L{FilePath} with a mode equal to the type of C{extension}
r   )r   r  rq   r   ri  r   r%  )r   r/  r  r  r  s        rE   r  r-  ^  sv    *  ))Aa.CC++C0ll(4>>'+B+K+K+MMPSS
 	
rI   i   c                   U R                  5       (       aG  U(       d@  [        R                  " [        R                  " U R                  5      UR                  5        gU R                  5       (       am  UR                  5       (       d  UR                  5         U R                  5        H3  nUR                  UR                  5       5      nUR                  XB5        M5     gU R                  5       (       a|  UR                  S5       oPR                  5        n UR                  U R                  5      nUR!                  U5        [#        U5      U R                  :  a  OMH  SSS5        SSS5        gU R                  5       (       d  [%        [&        R(                  S5      e[+        S5      e! , (       d  f       NQ= f! , (       d  f       g= f)a  
Copies self to destination.

If self doesn't exist, an OSError is raised.

If self is a directory, this method copies its children (but not
itself) recursively to destination - if destination does not exist as a
directory, this method creates it.  If destination is a file, an
IOError will be raised.

If self is a file, this method copies it to destination.  If
destination is a file, this method overwrites it.  If destination is a
directory, an IOError will be raised.

If self is a link (and followLinks is False), self will be copied
over as a new symlink with the same target as returned by os.readlink.
That means that if it is absolute, both the old and new symlink will
link to the same thing.  If it's relative, then perhaps not (and
it's also possible that this relative link will be broken).

File/directory permissions and ownership will NOT be copied over.

If followLinks is True, symlinks are followed so that they're treated
as their targets.  In other words, if self is a link, the link's target
will be copied.  If destination is a link, self will be copied to the
destination's target (the actual destination will be destination's
target).  Symlinks under self (if self is a directory) will be
followed and its target's children be copied recursively.

If followLinks is False, symlinks will be copied over as symlinks.

@param destination: the destination (a FilePath) to which self
    should be copied
@param followLinks: whether symlinks in self should be treated as links
    or as their targets
Nr   zNo such file or directoryz/Only copying of files and directories supported)r   r   r  readlinkr   rc   r
   r"  ri   rF   r   copyTorf   rL   r   
_chunkSizer  lenr   r   r   r   )r   destinationfollowLinksrF   	destChild	writefilereadfilechunks           rE   r3  FilePath.copyTo  s:   N ;;==JJr{{499-{/?/?@
 ::<<%%''++-'--enn.>?	Y4 ) [[]]!!#&)YY[H %MM$//:EOOE*5zDOO3  6A&& %,,(CDD &&WXX% 6A[&&s%   F;A
F*F;*
F8	4F;;
G	c                    [         R                  " U R                  UR                  5      UR                  5        U R	                  5         UR	                  5         g! [
         a  nUR                  [        R                  :X  ah  UR                  5       nU R                  XB5        UR                  X5        U R                  5       nU R                  XR5        UR                  5          SnAge SnAff = f)a  
Move self to destination - basically renaming self to whatever
destination is named.

If destination is an already-existing directory,
moves all children to destination if destination is empty.  If
destination is a non-empty directory, or destination is a file, an
OSError will be raised.

If moving between filesystems, self needs to be copied, and everything
that applies to copyTo applies to moveTo.

@param destination: the destination (a FilePath) to which self
    should be copied
@param followLinks: whether symlinks in self should be treated as links
    or as their targets (only applicable when moving between
    filesystems)
N)r   r  r  r   rO   r   r   EXDEVr  r3  moveTor   )r   r6  r7  r   secsibmysecsibs         rE   r?  FilePath.moveTo  s    *	"IId//0@0@A;CSCST, LLN!-  	yyEKK' %557F0k7  002H2!!'	s   :A 
C3'BC.-C..C3)rl  rK  r   )F)r   r!   rK  r   rs   rz   )r   r;   r   r   rs   FilePath[OtherAnyStr])r   r  rs   rC  )rs   zIterable[FilePath[AnyStr]])r%  objectrs   r   )r   r   rK  r   rs   rC  )rs   zDict[str, object]r   r  )r@  Optional[str]rs   r   )r@  rE  rs   r  )r@  rE  rs   zFilePath[bytes])r@  rE  rs   zFilePath[str])r  r   rs   r   )r   r   rs   rC  )r  r   rs   Optional[FilePath[OtherAnyStr]])r  r   rs   rF  )rs   FilePath[AnyStr])r  r   rs   rC  )r  rG  rs   rz   rt   rv   )T)r  r   rs   rz   ry   )rK   r|   rs   rz   r{   r}   )rs   r"  r   r   )rs   zTuple[AnyStr, AnyStr]r  )r  r   rs   rz   )r  r   rs   zList[FilePath[OtherAnyStr]])z.new)r  r   r  r   rs   rz   )r%  rD  rs   r|   )r  r   rs   rz   )rs   rx   )r/  zOptional[OtherAnyStr]rs   rC  )r6  rC  r7  r   rs   rz   )Lr   r   r   r   r   rl  r  r   r   rq   r   r   rW  rZ  r]  r`  rc  rf  ri  ro  propertyr   ru  rx  r{  r~  r  rF   r  r  r  r   r  r  rL   r  rO   r  rR   rV   rZ   r^   r  r  r  r  r  r  r
   rc   rf   r  r  r   r   r   r   r  r  r   r  r  r   r	   rn   r  r  r"  r%  r  r-   r  r4  r3  r?  r   rB   rI   rE   rI  rI    sJ   B I
L) 									 7</3	 > >	@	?&'@'$!	(, 	(B2-1<.&	""""*04((0 "# # # $ !	 "	#*&<&	#	".25h*

 8   .	  26 . 	 D J GKGY0GY?CGY	GYT GK-"0-"?C-"	-" -"rI   rI  )r   r!   rs   r!   )r  )r   Union[bytes, str]r@  rE  rs   r   r  )r   rI  r@  rE  rs   r  )r   r!   rG  rI  r@  rE  rs   r!   )br   
__future__r   base64r   r   r<  r   r   r   os.pathr   r   r	   r
   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   zope.interfacer.   r/   r0   typing_extensionsr1   twisted.python.compatr2   r3   twisted.python.runtimer4   twisted.python.utilr5   twisted.python.win32r6   r7   r8   r9   r:   O_EXCLO_CREATO_RDWRr(  r;   urandomr   urlsafe_b64encoder   r?   	Exceptionr   r   r   r   r   r  r   r   rw   r   r  r"  rA  rD  r   rI  rB   rI   rE   <module>rZ     s  
 #   	 
 # #
 
 
        & = < % 1 + ,  		BJJ&2X=67 jj  R	 Rj9 	 3g 3*> mS%023W/wv W/t/", /"d)U, )UX?(?, IM=
=,=8E==  Yb"' b"  b"rI   