home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / File Access Examples 1.0 / ActionRoutines.c next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  1.1 KB  |  45 lines  |  [TEXT/KAHL]

  1. /* ActionRoutines.c
  2.  *
  3.  * This file contains a routine called by the volume scanning routine
  4.  * which simply writes each folder name to the file with the global
  5.  * reference number myFileRef and writes a period (.) to the file
  6.  * for each file found. (The number of periods that follow a folder
  7.  * name won't necessarily be the number of files in that folder. That
  8.  * number also includes files in the parent folder between the current
  9.  * folder and the next folder found.)
  10.  *
  11.  */
  12.  
  13. #include "FileRoutines.h"        /* uses these routines to write to file */
  14.  
  15. extern short myFileRef;            /* the global file reference number */
  16.  
  17.  
  18. void FolderAction( Str31 folderName, short level )
  19. {
  20.     short x;
  21.     
  22.     /* write a carriage return to the file */
  23.     
  24.         WriteByte( myFileRef, kSequential, '\r' );
  25.     
  26.     /* write the folder name to the file indenting based on */
  27.     /* the level number sent. */
  28.     
  29.         /* 4 spaces for each level */
  30.         
  31.         for( x=1; x<=level; x++ )
  32.             WriteLong( myFileRef, kSequential, '    ' );
  33.         
  34.         WriteBlock( myFileRef, kSequential,
  35.                         folderName[0], &folderName[1] );
  36. }
  37.  
  38.  
  39. void FileAction( void )
  40. {
  41.     /* Write a period to the file */
  42.     
  43.     WriteByte( myFileRef, kSequential, '.' );
  44. }
  45.