diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2010-05-23 13:07:19 -0400 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2010-05-23 13:07:19 -0400 |
commit | 8f1b2d6edcb4ab45c8cf80c6e58c5c776d2e550e (patch) | |
tree | 2a3a3e4f8c717ab156615d3f6e054d10a65746f9 /diskio-unix.cc | |
parent | 8b6f476ee5b17e4a0efeb0240a5e7a134d1e1fab (diff) | |
download | sgdisk-8f1b2d6edcb4ab45c8cf80c6e58c5c776d2e550e.tar.gz |
0.6.8 release
Diffstat (limited to 'diskio-unix.cc')
-rw-r--r-- | diskio-unix.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/diskio-unix.cc b/diskio-unix.cc index 7d24301..b20f161 100644 --- a/diskio-unix.cc +++ b/diskio-unix.cc @@ -39,6 +39,7 @@ void DiskIO::MakeRealName(void) { // work. int DiskIO::OpenForRead(void) { int shouldOpen = 1; + struct stat64 st; if (isOpen) { // file is already open if (openForWrite) { @@ -61,8 +62,22 @@ int DiskIO::OpenForRead(void) { isOpen = 0; openForWrite = 0; } else { - isOpen = 1; + isOpen = 0; openForWrite = 0; + if (fstat64(fd, &st) == 0) { + if (S_ISDIR(st.st_mode)) + cerr << "The specified path is a directory!\n"; +#ifndef __FreeBSD__ + else if (S_ISCHR(st.st_mode)) + cerr << "The specified path is a character device!\n"; +#endif + else if (S_ISFIFO(st.st_mode)) + cerr << "The specified path is a FIFO!\n"; + else if (S_ISSOCK(st.st_mode)) + cerr << "The specified path is a socket!\n"; + else + isOpen = 1; + } // if (fstat64()...) } // if/else } // if |