Commits

Anonymous committed 485b9b2

Fixed buger under Dingoo native where copying file from root of disk failed. Reduced copy file buffer (from 1Mb) to 256Kb.

Comments (0)

Files changed (1)

 
 #endif /* DINGOO_NATIVE */
 
+//#define DEBUG_COPY
 //#define DEBUG_CHDIR
 #ifdef DEBUG_CHDIR
 int my_chdir(char *the_path)
 bool CopyFile(char *dest, char *src) {
   FILE *fp_in, *fp_out;
 #define FILE_COPY_BUFF_SIZE (1024*1024) /* adjust for performance/memory-usage NOTE progress bar may not be updated as expected */
+#define FILE_COPY_BUFF_SIZE (256*1024) /* adjust for performance/memory-usage NOTE progress bar may not be updated as expected */
   char buf[FILE_COPY_BUFF_SIZE];
   struct stat st;
   int progress_block, processed_size=0, processed_block=0;
   char tmpstr[PATHNAME_MAX];
   int numbytes=0;
 
+#ifdef DEBUG_COPY
+	printf("CopyFile(): dest >%s< src >%s<\n", dest, src );
+#endif /* DEBUG_COPY */
+
   fp_in = fopen(src, "r");
   if (!fp_in) {
     snprintf(tmpstr, sizeof(tmpstr), "can't open %s", src);
 
   DrawDialogBox(-1, -1, 200, 80, "Copying");
   BaseName(tmpstr, src, sizeof(tmpstr));
+#ifdef DEBUG_COPY
+	printf("CopyFile(): basename tmpstr >%s< \n", tmpstr);
+#endif /* DEBUG_COPY */
+
   r.x = 70; r.y = 95+option.font_height;
   r.w = 180; r.h = 60-option.font_height;
   DrawText(r, tmpstr);
       PopupMessage(150, 100, "Error", tmpstr);
       return false;
     }
+#ifdef DEBUG_COPY
+	printf("CopyFile(): read numbytes >%d< \n", numbytes);
+#endif /* DEBUG_COPY */
     fwrite(buf, 1, numbytes, fp_out); /* FIXME check number of bytes written and error check that too */
     if (ferror(fp_out) != 0) {
       snprintf(tmpstr, sizeof(tmpstr), "write %s failed", dest);
     PopupMessage(120, 80, "Error", "path too long");
     return false;
   }
-  snprintf(destpath, sizeof(destpath), "%s" DIRSEP "%s", destdir, entry); /* FIXME replace with JoinPath() */
+  JoinPath(destpath, destdir, entry);
+  
   if (stat(destpath, &st) == 0) {
     snprintf(tmpstr, sizeof(tmpstr), "%s already exists", destpath);
     PopupMessage(150, 100, "Error", tmpstr);
     PopupMessage(120, 80, "Error", "path too long");
     return false;
   }
-  snprintf(srcpath, sizeof(srcpath), "%s" DIRSEP "%s", srcdir, entry); /* FIXME replace with JoinPath() */
+  JoinPath(srcpath, srcdir, entry);
+#ifdef DEBUG_COPY
+	printf("CopyDirEntry(): srcpath >%s<\n", srcpath);
+#endif /* DEBUG_COPY */
 
   stat(srcpath, &st);
+#ifdef DEBUG_COPY
+	printf("CopyDirEntry(): st.st_mode >%d< >0x%x<\n", (int) st.st_mode, (int) st.st_mode);
+	printf("CopyDirEntry(): st.st_size >%d< \n", (int) st.st_size);
+#endif /* DEBUG_COPY */
   if (S_ISDIR(st.st_mode)) {
     if (mkdir(destpath, S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH | S_IWUSR | S_IWGRP ) == -1) {
       snprintf(tmpstr, sizeof(tmpstr), "can't create dir %s", destpath);