How to automatically get subsystem name for a file?