I'm creating an application that stores blob files into the hard drive, but this script must run in both Linux and Windows, the issue is that I want to give it an absolute path from the filesystem root and not one relative to the project files. This is because I'm using git and don't want to deal with excluding all these files from syncing.
So I would like to have something like this:
path = '/var/lib/blob_files/'
file = open(path+'myfile.blob', 'w')
and get a file in Unix at:
/var/lib/blob_files/myfile.blob
and in Windows at:
C:\var\lib\blob_files\myfile.blob
It could also be relative to the user home folder (/home/user in Unix and C:\Users\User in Windows) but I guess the problem is very similar.
How can I achieve this? Is there any library or function that can help me transparently to convert this path without having to ask in what platform is the script running all the time?
Of my two options, absolute from root or relative from home folder, which one do you recommend to use?
C:\var\lib`, so creatingC:\var\lib\blob_files` will be weird, but creating the Windows equivalent of~/.blob_filesis perfectly reasonable.