From 23420a92f0edc1d771b66e2b53d9dea5996f8d1e Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 7 Jun 2003 16:49:50 +0000 Subject: [PATCH] Add generic routine to determine if a string refers to a device or not. --- lib/_cdio_generic.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/_cdio_generic.c b/lib/_cdio_generic.c index 2eccd7a6..a1e12a0b 100644 --- a/lib/_cdio_generic.c +++ b/lib/_cdio_generic.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_generic.c,v 1.8 2003/05/30 10:21:11 rocky Exp $ + $Id: _cdio_generic.c,v 1.9 2003/06/07 16:49:50 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002,2003 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.8 2003/05/30 10:21:11 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.9 2003/06/07 16:49:50 rocky Exp $"; #include #include @@ -139,3 +139,18 @@ cdio_generic_stream_free (void *user_data) free (_obj); } + +/*! + Return true if source_name could be a device containing a CD-ROM. +*/ +bool +cdio_is_device_generic(const char *source_name) +{ + struct stat buf; + if (0 != stat(source_name, &buf)) { + cdio_error ("Can't get file status for %s:\n%s", source_name, + strerror(errno)); + return false; + } + return (S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode)); +}