Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of os.path doesn't show custom my documents locations #38

Open
Goldendawn69 opened this issue Jul 19, 2021 · 0 comments
Open

Use of os.path doesn't show custom my documents locations #38

Goldendawn69 opened this issue Jul 19, 2021 · 0 comments
Labels

Comments

@Goldendawn69
Copy link

Hi,

It would appear that os.path.expanduser doesn't find the directories you are looking for when that default directory has been changed. For me, I have moved that using windows Location to H drive.

When you try to set up the TTS Install location, it gives the error:
2021-07-19 12:43:17,041 - ERROR - TTS Dir missing: C:\Users\OEM\Documents\My Games\Tabletop Simulator\Saves

This is also noticed here:
https://stackoverflow.com/questions/6227590/finding-the-users-my-documents-path

So for example I would think you need to find where the My Documents is located first.
This is an example I took from : https://stackoverflow.com/questions/3858851/python-get-windows-special-folders-for-currently-logged-in-user

Should you wish to do it without the win32 extensions, you can use ctypes to call SHGetFolderPath:

>>> import ctypes.wintypes
>>> CSIDL_PERSONAL= 5       # My Documents
>>> SHGFP_TYPE_CURRENT= 0   # Want current, not default value

>>> buf= ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
>>> ctypes.windll.shell32.SHGetFolderPathW(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, buf)
0
>>> buf.value
'H:\\My Documents'

I have run this myself and proved it worked - though not sure how to add this into code to be honest.

I am assuming it is in the filesystem.py that this would need to be identified first. Before the line:

  if platform.system() == 'Windows':
    basepath = os.path.join(os.path.expanduser("~"),"Documents","My Games","Tabletop Simulator")

I made the following changes to my code download, but for some reason I cannot Push the changes for you to view in GIT, and review and decide to merge into your base code :(

At start of Filesystem.py

if platform.system() == 'Windows':
   import ctypes.wintypes
def standard_basepath():
  if platform.system() == 'Windows':
    CSIDL_PERSONAL = 5
    SHGFP_TYPE_CURRENT= 0 
    buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
    ctypes.windll.shell32.SHGetFolderPathW(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, buf)
    basepath = os.path.join(buf.value,"My Games","Tabletop Simulator")
    #basepath = os.path.join(os.path.expanduser("~"),"Documents","My Games","Tabletop Simulator")
@Goldendawn69 Goldendawn69 changed the title Appear to be hardcoding the directories Use of os.path doesn't show custom my documents locations Jul 19, 2021
@cwoac cwoac added the bug label Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants