TMReNameFile Code Example

long session_handle;
unsigned char state_buffer[15360];
FileEntry fentry;
short file_handle,result;

/* session_handle set from a call to TMExtendedStartSession */
...

/* get the unique registration number of the device to communicate with using TMFirst,TMNext,TMRom... */
...

fentry.name[0] = 'D';
fentry.name[1] = 'E';
fentry.name[2] = 'M';
fentry.name[3] = 'O';
fentry.extension = 0;

/* rename DEMO.000 to BACK.014 */
file_handle = TMOpenFile(session_handle, state_buffer, &fentry);

if (file_handle >= 0)
{
   /* file opened correctly */
   
   fentry.name[0] = 'B';
   fentry.name[1] = 'A';
   fentry.name[2] = 'C';
   fentry.name[3] = 'K';
   fentry.extension = 14;

   result = TMReNameFile(session_handle, state_buffer, 
                          file_handle, &fentry);

   if (result == 1)
   {
      /* file name changed */
      ...
   }
   else
   {
      /* error renaming the file */
      ...
   }
}  
else 
{
   /* error opening the file */
   ...
}

/* close the opened file with a call to TMCloseFile */
...

/* close the session with a call to TMEndSession */
...