home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm7.zip / isdir.cpp < prev    next >
C/C++ Source or Header  |  1999-06-13  |  2KB  |  68 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1998, 1999  Paul Elliott
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     Paul Elliott
  20.     PMB # 181
  21.     11900 Metric Blvd Ste. J
  22.     Austin Tx 78758-3117
  23.     pelliott@io.com
  24. *    HISTORY
  25. *     APR 1999 Paul Elliott               Use open class library to determine if file is directory
  26. *     APR 1999 Paul Elliott               DISABLED causes exception at startup.
  27. */
  28. #include "isdir.hpp"
  29. #include "iexcbase.hpp"
  30.  
  31. // the code below should work but it does not.
  32. // it causes an exception at start time.
  33. // message box reads.
  34. // UIL0274: Number of bitmap planes is not 1.
  35. // message box has retry and cancel buttons.
  36. // if anyone can tell the reason for this exceptions
  37. // please contact Paul Elliottt pelliottt@io.com
  38. // new code if it worked used new Open class library
  39. #if ( __IBMCPP__  >= 400 )                             // begin new code
  40. #include <ifilesys.hpp>
  41.  
  42. // returns true if indicated file is determined to be a directory.
  43. Boolean IsDir(const IString& str)
  44. {
  45.    try {
  46.       IFileSystemEntity file_system_ent(str);
  47.       return file_system_ent.isA( IDirectory::kKind );
  48.    }
  49.    catch(IException& exc)
  50.    {
  51.       return false;
  52.    };
  53. }
  54. #else
  55.                                   // end new code
  56.                                   // comment out old code
  57. #include <sys\types.h>
  58. #include <sys\stat.h>
  59.  
  60. // returns true if indicated file is determined to be a directory.
  61. Boolean IsDir(const IString& str)
  62. {
  63.      struct stat our_stat;
  64.      if ( stat( str, &our_stat) ) return false;
  65.  
  66.      return ( ( our_stat.st_mode & S_IFDIR) ? true : false );
  67. };
  68. #endif                            // comment out old code