home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09964.iso / disktool / cabrsckt.exe / FCIUTIL.C < prev    next >
C/C++ Source or Header  |  1996-07-31  |  1KB  |  72 lines

  1. /*
  2.  * util.c
  3.  *
  4.  * Support functions for the demo programs
  5.  */
  6. #include "testfci.h"
  7.  
  8.  
  9. void strip_path(char *filename, char *stripped_name)
  10. {
  11.     char    *p;
  12.  
  13.     p = strrchr(filename, '\\');
  14.  
  15.     if (p == NULL)
  16.         strcpy(stripped_name, filename);
  17.     else
  18.         strcpy(stripped_name, p+1);
  19. }
  20.  
  21.  
  22. int get_percentage(unsigned long a, unsigned long b)
  23. {
  24.     while (a > 10000000)
  25.     {
  26.         a >>= 3;
  27.         b >>= 3;
  28.     }
  29.  
  30.     if (b == 0)
  31.         return 0;
  32.  
  33.     return ((a*100)/b);
  34. }
  35.  
  36.  
  37. char *return_fci_error_string(FCIERROR err)
  38. {
  39.     switch (err)
  40.     {
  41.         case FCIERR_NONE:
  42.             return "No error";
  43.  
  44.         case FCIERR_OPEN_SRC:
  45.             return "Failure opening file to be stored in cabinet";
  46.         
  47.         case FCIERR_READ_SRC:
  48.             return "Failure reading file to be stored in cabinet";
  49.         
  50.         case FCIERR_ALLOC_FAIL:
  51.             return "Insufficient memory in FCI";
  52.  
  53.         case FCIERR_TEMP_FILE:
  54.             return "Could not create a temporary file";
  55.  
  56.         case FCIERR_BAD_COMPR_TYPE:
  57.             return "Unknown compression type";
  58.  
  59.         case FCIERR_CAB_FILE:
  60.             return "Could not create cabinet file";
  61.  
  62.         case FCIERR_USER_ABORT:
  63.             return "Client requested abort";
  64.  
  65.         case FCIERR_MCI_FAIL:
  66.             return "Failure compressing data";
  67.  
  68.         default:
  69.             return "Unknown error";
  70.     }
  71. }
  72.