Changeset 135
- Timestamp:
- 07/22/2009 09:06:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SH_SHM/trunk/source/seed_io/seed_tidy.c
r108 r135 112 112 static void TdFixTbnames( char name[] ); 113 113 int TdQsortCompare( const void *d1, const void *d2 ); 114 static void TdUniqueFilename( char fname[] ); 114 115 115 116 … … 974 975 nametime.min, chan ); 975 976 } /*endif*/ 977 TdUniqueFilename( fname ); 976 978 recnum = 1; 977 979 fd = 1; … … 1010 1012 1011 1013 1014 1015 /*---------------------------------------------------------------------------*/ 1016 1017 1018 static void TdUniqueFilename( char fname[] ) 1019 1020 /* Adds counter to filename until a non existing filename is reached 1021 * 1022 * parameters of routine 1023 * char fname[]; modify; name to be checked/modified 1024 */ 1025 { 1026 /* local variables */ 1027 int cnt; /* counter */ 1028 FILE *fp; /* file pointer */ 1029 char fnamecopy[cBcFileLth+1]; /* copy of filename */ 1030 1031 /* executable code */ 1032 1033 /* if file does not exist, just leave everything unchanged and return */ 1034 fp = fopen( fname, "r" ); 1035 if (fp == NULL) 1036 return; 1037 1038 /* if file is already existing change it using a counter */ 1039 strcpy( fnamecopy, fname ); 1040 cnt = 1; 1041 do { 1042 fclose( fp ); 1043 sprintf( fname, "%s.%d", fnamecopy, cnt ); 1044 cnt++; 1045 fp = fopen( fname, "r" ); 1046 } while (fp != NULL); 1047 1048 } /* end of TdUniqueFilename */ 1012 1049 1013 1050 /*---------------------------------------------------------------------------*/
Note: See TracChangeset
for help on using the changeset viewer.