I want to determine if a file is on the local hard drive or a drive that is installed from the network in OSX. Therefore, I would like to create code similar to the following:
file_name = '/Somewhere/foo.bar' if is_local_file(file_name): do_local_thing() else: do_remote_thing()
I could not find anything that works like is_local_file()
in the above example. Ideally, I would like to use an existing function, if any, but could not, how could I implement it myself? The best I came up with is the following, but this applies to the installed dmgs, as if they are remote, which is not what I want. I also suspect that I can reinvent 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 that generate checksums, one of which uses a multiprocessor that imposes overhead for a start, but which is faster for large files if the network connection is slow.
source share