add: printf("tcount: %d count: %d\n", tcount, count);
context: static gboolean UploadFile(char* saveto, char* filename) {	// This function expects that you've already changed the parition and 	// directory to the correct path in the camcorder. dirpath is the Windows	// path to the file to store in.	// directory.  int filesize;  unsigned int x,t;  unsigned int count = 0, tcount = 0, alt_total = 0;  unsigned int udata;  //CFile file;  FILE* file = NULL;  unsigned buffer [BUFSIZE];  unsigned char sfilename[256];    int bufsize;    Log("entering UploadFile");  printf("UploadFile(%s, %s)\n",saveto,filename);  if(strlen(filename)>12) {    Log("Can't upload files with long filenames");    return(FALSE);  }  file = fopen(saveto, "r");  if (file == NULL) {    Log("Trouble opening: ");    Log(saveto);    return FALSE;  }  filesize = GetLength(file);    //  Log("proceeding in UploadFile...");  memset(sfilename,0,255);  strncpy((char *)sfilename,filename,12);  if(ControlMessageWrite(0xb105,(int *)sfilename,strlen((char *)sfilename)+1, TIMEOUT)==FALSE) { // SetFileName    Log("failed at 0xb1");    return FALSE;  }  //Endianess appears to be screwed with this command!!  udata=((filesize&0xffff)<<16)|((filesize>>16));    if(ControlMessageWrite(0x9505,(int *)&udata,4, TIMEOUT)== FALSE) { // Request Write        Log("failed at 0x95");    return FALSE;  }  x=0;  //  EnableControls(FALSE);  while(1) {    //    Log("writing...");    count = fread(buffer, sizeof(char), BUFSIZE, file);    if (count < 1) break;    tcount += count;    set_bitrate(tcount);    if (tcount  - alt_total > 65536) {      set_progress_bar((double)tcount / (double)filesize);      //      fprintf(stderr,"m_progressbar: %f\n",m_progressbar_fraction);      alt_total = tcount;    }    //printf("tcount: %d count: %d\n", tcount, count);    x=Write(buffer,count,TIMEOUT);    //printf("x: %d\n",x);    if(x<1) {      Log("Error writing file to camera");      fclose(file);      //EnableControls(TRUE);      //      m_progressbar_fraction = 0;      set_progress_bar(0.0);      return FALSE;    }    //Log("reading...");    //if(count<BUFSIZE)    //break;    //x += count;    //    printf("x: %d\n", x);    //    file.WriteHuge(buffer,count);    //    if(count<BUFSIZE)    //break;    //DoMessagePump();  }  //CString msg; msg.Format("file was %d bytes in size",x); Log(msg);  // m_progressbar_fraction = 0;  set_progress_bar(0.0);  set_bitrate(0);  fclose(file);  //  Log("Success sending file");    Log("Leaving MemoryToFile");  return TRUE;}