home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 162.lha / ren.c < prev    next >
C/C++ Source or Header  |  1988-04-27  |  2KB  |  70 lines

  1.  
  2. /*****************************************************
  3.   ren.c
  4.  
  5.   This program allows one to rename the directory
  6.   which contains the font data files.
  7.  
  8.   Copyright 1988 By Stephen Vermeulen
  9.  
  10.   This program may be freely redistributed so long as
  11.   the Copyright messages remain intact and the program
  12.   is distributed with the supplied documentation.
  13.  
  14.   syntax:
  15.  
  16.      ren thisfont.font path
  17. ******************************************************/
  18.  
  19. #include <stdio.h>
  20.  
  21. char newname[256], oldname[256];
  22.  
  23. main(argc, argv)
  24. int argc;
  25. char *argv[];
  26. {
  27.   FILE *font;
  28.   long j, pos;
  29.   short i, n;
  30.  
  31.   if (argc != 3)
  32.   {
  33.     printf("ren filename.font newpath\n");
  34.     printf("Copyright 1988 By Stephen Vermeulen\n");
  35.     printf("3635 Utah Dr. N.W.,  Calgary, Alberta, CANADA, T2N 4A6\n");
  36.   }
  37.   else
  38.   {
  39.     font = fopen(argv[1], "r+");
  40.     if (font)
  41.     {
  42.       /********************************************
  43.         now determine how many sizes this font has
  44.       *********************************************/
  45.  
  46.       fread(&n, 2, 1, font);  /** throw away **/
  47.       fread(&n, 2, 1, font);  /** number of sizes **/
  48.       printf("Font %s has %d sizes\n", argv[1], n);
  49.       for (i = 0; i < n; ++i)
  50.       {
  51.         /** for each size we rename it...
  52.          **/
  53.  
  54.         fseek(font, 4L + 260L * i, 0);
  55.         fread(oldname, 256, 1, font);
  56.         printf("name was: %s ", oldname);
  57.         for (j = 255; j > 0; --j)
  58.           if (oldname[j] == '/') break;
  59.         strcpy(newname, argv[2]);
  60.         strcat(newname, oldname + j);
  61.         fseek(font, 4L + 260L * i, 0);
  62.         printf("now is: %s\n", newname);
  63.         fwrite(newname, 256, 1, font);
  64.       }
  65.       fclose(font);
  66.     }
  67.   }
  68. }
  69.  
  70.