
    Uj=                        U d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 ddl
mZ erddlmZ d	Zd
ed<    G d de          Zd'dZd(dZd'dZdddddddddddd Zd!ed"<   d'd#Zd)d%Z e            Zd'd&ZdgZdS )*zWindows.    )annotationsN)Path)TYPE_CHECKINGFinal   )PlatformDirsABC)Callablei @  z
Final[int]_KF_FLAG_DONT_VERIFYc                     e Zd ZdZed%d            Zddd&d
Zed%d            Zed%d            Zed%d            Z	ed%d            Z
ed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d            Zed%d             Zed%d!            Zed%d"            Zed%d#            Zed%d$            Z dS )'Windowsa  `MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.

    Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `appauthor
    <platformdirs.api.PlatformDirsABC.appauthor>`, `version <platformdirs.api.PlatformDirsABC.version>`, `roaming
    <platformdirs.api.PlatformDirsABC.roaming>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
    <platformdirs.api.PlatformDirsABC.ensure_exists>`.

    returnstrc                    | j         rdnd}t          j                            t	          |                    }|                     |          S )z:returns: data directory tied to the user, e.g. ``%USERPROFILE%\AppData\Local\$appauthor\$appname`` (not roaming) or ``%USERPROFILE%\AppData\Roaming\$appauthor\$appname`` (roaming)CSIDL_APPDATACSIDL_LOCAL_APPDATA)roamingospathnormpathget_win_folder_append_parts)selfconstr   s      X/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/platformdirs/windows.pyuser_data_dirzWindows.user_data_dir   sF     $(<J5Jwu 5 566!!$'''    Nopinion_valuer   r   
str | Nonec               z   g }| j         r| j        dur#| j        p| j         }|                    |           |                    | j                    || j        r|                    |           | j        r|                    | j                   t          j        j        |g|R  }|                     |           |S )NF)	appname	appauthorappendopinionversionr   r   join_optionally_create_directory)r   r   r   paramsauthors        r   r   zWindows._append_parts$   s    < 	,~U**74<f%%%MM$,'''(T\(m,,,| ,dl+++w|D*6***))$///r   c                    t           j                            t          d                    }|                     |          S )zU:returns: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``CSIDL_COMMON_APPDATAr   r   r   r   r   r   r   s     r   site_data_dirzWindows.site_data_dir3   s6     w/E F FGG!!$'''r   c                    | j         S )zD:returns: config directory tied to the user, same as `user_data_dir`r   r   s    r   user_config_dirzWindows.user_config_dir9        !!r   c                    | j         S )zC:returns: config directory shared by users, same as `site_data_dir`r.   r1   s    r   site_config_dirzWindows.site_config_dir>   r3   r   c                    t           j                            t          d                    }|                     |d          S )z:returns: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g. ``%USERPROFILE%\AppData\Local\$appauthor\$appname\Cache\$version``r   Cacher   r,   r-   s     r   user_cache_dirzWindows.user_cache_dirC   s;     w/D E EFF!!$g!>>>r   c                    t           j                            t          d                    }|                     |d          S )ze:returns: cache directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname\Cache\$version``r+   r8   r   r,   r-   s     r   site_cache_dirzWindows.site_cache_dirI   s;     w/E F FGG!!$g!>>>r   c                    | j         S )zC:returns: state directory tied to the user, same as `user_data_dir`r0   r1   s    r   user_state_dirzWindows.user_state_dirO   r3   r   c                    | j         S )zB:returns: state directory shared by users, same as `site_data_dir`r5   r1   s    r   site_state_dirzWindows.site_state_dirT   r3   r   c                    | j         }| j        r5t          j                            |d          }|                     |           |S )zh:returns: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in itLogs)r   r$   r   r   r&   r'   r-   s     r   user_log_dirzWindows.user_log_dirY   D     !< 	47<<f--D--d333r   c                    | j         }| j        r5t          j                            |d          }|                     |           |S )zg:returns: log directory shared by users, same as `site_data_dir` if not opinionated else ``Logs`` in itrA   )r.   r$   r   r   r&   r'   r-   s     r   site_log_dirzWindows.site_log_dirb   rC   r   c                Z    t           j                            t          d                    S )zO:returns: documents directory tied to the user e.g. ``%USERPROFILE%\Documents``CSIDL_PERSONALr   r   r   r   r1   s    r   user_documents_dirzWindows.user_documents_dirk   #     w/? @ @AAAr   c                Z    t           j                            t          d                    S )zO:returns: downloads directory tied to the user e.g. ``%USERPROFILE%\Downloads``CSIDL_DOWNLOADSrH   r1   s    r   user_downloads_dirzWindows.user_downloads_dirp   s#     w/@ A ABBBr   c                Z    t           j                            t          d                    S )zM:returns: pictures directory tied to the user e.g. ``%USERPROFILE%\Pictures``CSIDL_MYPICTURESrH   r1   s    r   user_pictures_dirzWindows.user_pictures_diru   s#     w/A B BCCCr   c                Z    t           j                            t          d                    S )zI:returns: videos directory tied to the user e.g. ``%USERPROFILE%\Videos``CSIDL_MYVIDEOrH   r1   s    r   user_videos_dirzWindows.user_videos_dirz   "     w ? ?@@@r   c                Z    t           j                            t          d                    S )zG:returns: music directory tied to the user e.g. ``%USERPROFILE%\Music``CSIDL_MYMUSICrH   r1   s    r   user_music_dirzWindows.user_music_dir   rT   r   c                Z    t           j                            t          d                    S )zL:returns: desktop directory tied to the user, e.g. ``%USERPROFILE%\Desktop``CSIDL_DESKTOPDIRECTORYrH   r1   s    r   user_desktop_dirzWindows.user_desktop_dir   s#     w/G H HIIIr   c                z    t           j                            t           j                            d                    S )zN:returns: projects directory tied to the user, e.g. ``%USERPROFILE%\Projects``z
~/Projects)r   r   r   
expanduserr1   s    r   user_projects_dirzWindows.user_projects_dir   s*     w 2 2< @ @AAAr   c           
         t           j                            t           j                            dt          t          d                                          j        dz                                S )z9:returns: public share directory e.g. ``C:\Users\Public``PUBLIC~Public)	r   r   r   environgetr   r   r\   parentr1   s    r   user_publicshare_dirzWindows.user_publicshare_dir   sM     w
xT#YY=Q=Q=S=S=Z]e=e9f9f g ghhhr   c           	         t           j                            t          t	          t          d                    dz  dz  dz                      S )z]:returns: templates directory tied to the user e.g. ``%APPDATA%\Microsoft\Windows\Templates``r   	Microsoftr   	Templatesr   r   r   r   r   r   r1   s    r   user_templates_dirzWindows.user_templates_dir   sC     wD)H)H$I$IK$WZc$cfq$q r rsssr   c           	         t           j                            t          t	          t          d                    dz  dz  dz                      S )zZ:returns: fonts directory tied to the user e.g. ``%LOCALAPPDATA%\Microsoft\Windows\Fonts``r   rg   r   Fontsri   r1   s    r   user_fonts_dirzWindows.user_fonts_dir   sE     wD8M)N)N$O$OR]$]`i$ils$s t tuuur   c                    | j         S )zL:returns: preference directory tied to the user, same as ``user_config_dir``)r2   r1   s    r   user_preference_dirzWindows.user_preference_dir   s     ##r   c                    t           j                            t           j                            t	          d          d                    S )zJ:returns: bin directory tied to the user, e.g. ``%LOCALAPPDATA%\Programs``r   Programsr   r   r   r&   r   r1   s    r   user_bin_dirzWindows.user_bin_dir   s4     w^<Q-R-RT^ _ _```r   c                    t           j                            t           j                            t	          d          d                    S )zC:returns: bin directory shared by users, e.g. ``C:\ProgramDatain``r+   binrr   r1   s    r   site_bin_dirzWindows.site_bin_dir   s4     w^<R-S-SUZ [ [\\\r   c                Z    t           j                            t          d                    S )zO:returns: applications directory tied to the user, e.g. ``Start Menu\Programs``CSIDL_PROGRAMSrH   r1   s    r   user_applications_dirzWindows.user_applications_dir   rJ   r   c                Z    t           j                            t          d                    S )zo:returns: applications directory shared by users, e.g. ``C:\ProgramData\Microsoft\Windows\Start Menu\Programs``CSIDL_COMMON_PROGRAMSrH   r1   s    r   site_applications_dirzWindows.site_applications_dir   s#     w/F G GHHHr   c                    t           j                            t           j                            t	          d          d                    }|                     |          S )zk:returns: runtime directory tied to the user, e.g. ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname``r   Temp)r   r   r   r&   r   r   r-   s     r   user_runtime_dirzWindows.user_runtime_dir   sG     w^<Q-R-RTZ [ [\\!!$'''r   c                    | j         S )zG:returns: runtime directory shared by users, same as `user_runtime_dir`)r   r1   s    r   site_runtime_dirzWindows.site_runtime_dir   s     $$r   )r   r   )r   r   r   r   r   r   )!__name__
__module____qualname____doc__propertyr   r   r.   r2   r6   r9   r;   r=   r?   rB   rE   rI   rM   rP   rS   rW   rZ   r]   re   rj   rm   ro   rs   rv   ry   r|   r   r    r   r   r   r      s         ( ( ( X( GK       ( ( ( X(
 " " " X" " " " X" ? ? ? X?
 ? ? ? X?
 " " " X" " " " X"    X    X B B B XB C C C XC D D D XD A A A XA A A A XA J J J XJ B B B XB i i i Xi t t t Xt v v v Xv $ $ $ X$ a a a Xa ] ] ] X] B B B XB I I I XI ( ( ( X(
 % % % X% % %r   r   
csidl_namer   r   c                    t          |           }||S dddd                    |           }|d|  }t          |          t          j                            |          }|d| }t          |          |S )z&Get folder from environment variables.NAPPDATAALLUSERSPROFILELOCALAPPDATA)r   r+   r   Unknown CSIDL name: zUnset environment variable: )(get_win_folder_if_csidl_name_not_env_varrc   
ValueErrorr   rb   )r   resultenv_var_namemsgs       r   get_win_folder_from_env_varsr      s    5jAAF # 1-  
c*oo	 
 1Z11ooZ^^L))F~;\;;ooMr   r   c                   | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d	          S | d
k    rMt           j                            t           j                            t           j        d                   d          S | dk    rPt           j                            t           j                            t           j        d                   dddd          S | dk    r|t           j                            t           j                            t           j                            dt           j                            dd                              dddd          S dS )zMGet a folder for a CSIDL name that does not exist as an environment variable.rG   USERPROFILE	DocumentsrL   	DownloadsrO   PicturesrR   VideosrV   Musicrx   r   rg   r   z
Start Menurq   r{   PROGRAMDATAr   zC:\ProgramDataN)r   r   r&   r   rb   rc   )r   s    r   r   r      s   %%%w||BG,,RZ-FGGUUU&&&w||BG,,RZ-FGGUUU'''w||BG,,RZ-FGGTTT_$$w||BG,,RZ-FGGRRR_$$w||BG,,RZ-FGGQQQ%%%w||GRZ	233
 
 	
 ,,,w||GRZ^^M2:>>J[]n;o;oppqq
 
 	
 4r   c                L   ddh}ddddddd	d
ddd
                     |           }|d|  }t          |          t          j        dk    rt          ddl}| |v r|j        n|j        }|                    |d          }|	                    ||          \  }}t          |          S )zGet folder from the registry.

    This is a fallback technique at best. I'm not sure if using the registry for these guarantees us the correct answer
    for all CSIDL_* names.

    r+   r{   AppDatazCommon AppDatazLocal AppDataPersonal&{374DE290-123F-4565-9164-39C4925E467B}zMy PictureszMy VideozMy Musicrq   zCommon Programs)
r   r+   r   rG   rL   rO   rR   rV   rx   r{   Nr   win32r   z@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)rc   r   sysplatformNotImplementedErrorwinregHKEY_LOCAL_MACHINEHKEY_CURRENT_USEROpenKeyQueryValueExr   )	r   machine_namesshell_folder_namer   r   hkeykey	directory_s	            r   get_win_folder_from_registryr      s     	M
 # 0.$C)##$!2  
c*oo   1Z11oo
|w!!MMM )3m(C(C6$$IaD
..b
c
cC&&s,=>>LIqy>>r   z&{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}z&{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}z&{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}z&{FDD39AD0-238F-46AF-ADB4-6C85480369C7}z&{33E28130-4E1E-4676-835A-98395C3BC3BB}z&{18989B1D-99B5-455B-841C-AB7C74E4DDFC}z&{4BD8D571-6D19-48D3-BE97-422220080E43}r   z&{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}z&{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}z&{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8})r   r+   r   rG   rO   rR   rV   rL   rY   rx   r{   zdict[str, str]_KNOWN_FOLDER_GUIDSc                @   t           j        dk    rt          ddlm}m}m}m}m}m	}m
  G fdd|          } |d          }||j        _        j         ||          g|j        _        d|j        _        j        g|j        _         |d          }	||	j        _         ||          j        j         |j                  g|	j        _         |d	          }
j        |
j        _        j        j        j        g|
j        _        t,                              |           }|d
|  }t1          |           |            }|                    | ||                                                     }|	                     ||          t2          d ||                     |j        }|                    |           |d|  }t1          |          t7          d |D                       r) |d          }|
                    ||d          r|j        }|S )zGet folder via :func:`SHGetKnownFolderPath`.

    See https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath.

    r   r   )HRESULTPOINTER	StructureWinDLLbyrefcreate_unicode_bufferwintypesc                  Z    e Zd Zd j        fd j        fd j        fd j        dz  fgZdS )(get_win_folder_via_ctypes.<locals>._GUIDData1Data2Data3Data4   N)r   r   r   DWORDWORDBYTE_fields_)r   s   r   _GUIDr   ;  sC        hn%hm$hm$hma'(	
r   r   ole32Nshell32kernel32r   z'SHGetKnownFolderPath returned NULL for c              3  <   K   | ]}t          |          d k    V  dS )   N)ord).0cs     r   	<genexpr>z,get_win_folder_via_ctypes.<locals>.<genexpr>b  s,      
(
(A3q66C<
(
(
(
(
(
(r   i   )r   r   r   ctypesr   r   r   r   r   r   r   CLSIDFromStringrestype	LPCOLESTRargtypesCoTaskMemFreeLPVOIDSHGetKnownFolderPathr   HANDLELPWSTRGetShortPathNameWr   rc   r   r
   valueany)r   r   r   r   r   r   r   r   r   r   r   folder_guidr   guidpath_ptrr   bufr   s                    @r   get_win_folder_via_ctypesr   1  st    |w!!bbbbbbbbbbbbbbbbbb
 
 
 
 
 
 
	 
 
 
 F7OOE$+E!&.&8''%..%IE""&E$,O#4E fYG+2G (-4WU^^X^X_^e^efnfu^v^v,wG )vj!!H)1H&+3?HOX^*\H'%))*55K1Z11oo577D	+uuT{{333  H  t.BD%%PX//ZZZ^F	!!!~D
DDoo

(
(
(
(
((( ##D))%%fc488 	YFMr   Callable[[str], str]c                     	 ddl } t          S # t          $ r Y nw xY w	 ddl}t          S # t          $ r
 t
          cY S w xY w)zjSelect the best method to resolve Windows folder paths: ctypes, then registry, then environment variables.r   N)r   r   ImportErrorr   r   r   )r   r   s     r   _pick_get_win_folderr   j  sy    ) )(    , ,+  , , ,++++,s    
) ==c                    d|                      d           }t          j                            |d                                          x}r|S t          |           S )zGet a Windows folder path, checking for ``WIN_PD_OVERRIDE_*`` environment variable overrides first.

    For example, ``CSIDL_LOCAL_APPDATA`` can be overridden by setting ``WIN_PD_OVERRIDE_LOCAL_APPDATA``.

    WIN_PD_OVERRIDE_CSIDL_ )removeprefixr   rb   rc   strip_resolve_win_folder)r   env_varoverrides      r   r   r   }  s\     E!8!8!B!BDDG:>>'2..44666x z***r   )r   r   r   r   )r   r   r   r   )r   r   )r   
__future__r   r   r   pathlibr   typingr   r   apir   collections.abcr	   r
   __annotations__r   r   r   r   r   r   r   r   r   __all__r   r   r   <module>r      s    " " " " " " 				 



       ' ' ' ' ' ' ' '             )(((((( $.  - - - -l% l% l% l% l%o l% l% l%^   *" " " "J# # # #N >DC>@==?F>E' '     6 6 6 6r, , , ,  +*,, 	+ 	+ 	+ 	+ r   