I want to determine whether or not a file is located on a local hard drive or a drive mounted from the network in OSX. So I'd be looking to produce code a bit like the following:
file_name = '/Somewhere/foo.bar'
if is_local_file(file_name):
do_local_thing()
else:
do_remote_thing()
I've not been able to find anything that works like is_local_file()
in the example above. Ideally I'd like to use an existing function if there is one but failing that how could I implement it myself? The best I've come up with is the following but this treats mounted dmgs as though they're remote which isn't what I want. Also I suspect I might be reinventing the wheel!
def is_local_file(path):
path = path.split('/')[1:]
for index in range(1,len(path)+1):
if os.path.ismount('/' + '/'.join(path[:index])):
return False
return True
I have two functions which generate checksums, one of which uses multiprocess which incurs an overhead to start off with but which is faster for large files if the network connection is slow.