home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / compre.zip / isvalid.c < prev    next >
C/C++ Source or Header  |  1991-02-12  |  1KB  |  60 lines

  1. /* ISVALID.C
  2.  *
  3.  * Autor:    Kai Uwe Rommel
  4.  * Datum:    Thu 15-Nov-1990
  5.  *
  6.  * Compiler: MS C ab 6.00
  7.  * System:   OS/2 ab 1.2
  8.  */
  9.  
  10. #define LABEL    "isvalid.c"
  11. #define VERSION  "1.0"
  12.  
  13.  
  14. #define INCL_NOPM
  15. #define INCL_DOSERRORS
  16. #include <os2.h>
  17. #include <stdlib.h>
  18.  
  19.  
  20. int IsFileNameValid(char *name)
  21. {
  22.   HFILE hf;
  23.   USHORT usAction;
  24.  
  25.   switch( DosOpen(name, &hf, &usAction, 0L, 0, FILE_OPEN,
  26.                   OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0L) )
  27.   {
  28.   case ERROR_INVALID_NAME:
  29.   case ERROR_FILENAME_EXCED_RANGE:
  30.     return FALSE;
  31.   case NO_ERROR:
  32.     DosClose(hf);
  33.   default:
  34.     return TRUE;
  35.   }
  36. }
  37.  
  38.  
  39. int IsFileSystemDumb(char *dir)
  40. {                         
  41.   char drive[5], path[256], name[256];
  42.   
  43.   _splitpath(dir, drive, path, NULL, NULL);
  44.   _makepath(name, drive, path, ".DUMB.TEST.NAME", NULL);
  45.   
  46.   return !IsFileNameValid(name);
  47. }
  48.  
  49.  
  50. void UnixFileName(char *name)
  51. {
  52.   for ( ; *name; name++ )
  53.     if ( *name == '\\' )
  54.       *name = '/';
  55. }
  56.  
  57.  
  58.  
  59. /* Ende ISVALID.C */
  60.