Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!think!ames!rutgers!clyde!burl!codas!killer!wnp From: wnp@killer.UUCP (Wolf Paul) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Determining if a file is a device Message-ID: <1738@killer.UUCP> Date: Mon, 5-Oct-87 11:31:12 EDT Article-I.D.: killer.1738 Posted: Mon Oct 5 11:31:12 1987 Date-Received: Fri, 9-Oct-87 04:31:07 EDT Organization: The Unix(R) Connection, Dallas, Texas Lines: 23 Keywords: stat(2), MS-DOS devices Xref: mnetor comp.sys.ibm.pc:8722 comp.lang.c:4740 In trying to implement a function which emulates the UNIX stat(2) system call I have run into a problem: How can I determine whether a filename passed to a C function is a regular file or the name of a device? I realize that I could hard-code the default device names (i.e. CON, PRN, COM1, LPT1, etc.) into my function, but that would fail as soon as there were a user-installed device driver using a non-standard name. Is there a DOS function which will let me determine this? Can the DOS IOCTL function be used without opening the named file? In a related question, given a file handle (file descriptor), is there any way to determine the name of the file? Specifically, can I determine which device file handle 0 (STDIN) refers to, i.e. CON or possibly COM1? This would be required to implement a tty(1) command, to determine whether access is local (via th CONsole), or remotely, via a COM port. Thanks for any hints - please post or e-mail as you see fit. Wolf Paul ihnp4!killer!wnp