plumbum icon indicating copy to clipboard operation
plumbum copied to clipboard

IsExistingFile only works for regular files

Open charlie-ht opened this issue 7 years ago • 3 comments

I often write scripts that take as arguments sockets, block devices, etc and would like the same thing ExistingFile does for "regular files". I'm wondering if you think ExistingFile should be modified to also check for is_socket, is_fifo, is_char_device, and is_block_device as well?

charlie-ht avatar Aug 12 '17 13:08 charlie-ht

Splitting the predicates into IsRegularFile, IsSocketFile, etc would also seem OK to me, but "is_file" is too broad a name for an API on UNIX IMO.

charlie-ht avatar Aug 12 '17 16:08 charlie-ht

How does path lib do it? I'll be able to look at this in a few days, I just got back from a small vacation (and have a conference next week).

henryiii avatar Aug 14 '17 21:08 henryiii

I think the following steps would be needed:

  • Add is_symlink(), .is_fifo(), .is_block_device(), .is_char_device(), .is_reserved() from pathlib.
  • Add several predicates, like IsSocketFile
  • Allow composition, SocketFile & RegularFile, etc
  • ExistingFile would be a shortcut to SocketFile & ...

Would that work?

henryiii avatar Aug 28 '17 21:08 henryiii