? build ? splitedit_disk_full.patch Index: apps/plugin.c =================================================================== RCS file: /cvsroot/rockbox/apps/plugin.c,v retrieving revision 1.123 diff -u -b -r1.123 plugin.c --- apps/plugin.c 2 Sep 2005 05:39:09 -0000 1.123 +++ apps/plugin.c 6 Sep 2005 16:02:52 -0000 @@ -338,6 +338,7 @@ read_bmp_file, #endif show_logo, + fat_size, /* new stuff at the end, sort into place next time the API gets incompatible */ Index: apps/plugin.h =================================================================== RCS file: /cvsroot/rockbox/apps/plugin.h,v retrieving revision 1.133 diff -u -b -r1.133 plugin.h --- apps/plugin.h 2 Sep 2005 05:39:09 -0000 1.133 +++ apps/plugin.h 6 Sep 2005 16:02:52 -0000 @@ -89,7 +89,7 @@ #endif /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 50 +#define PLUGIN_API_VERSION 51 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any @@ -423,10 +423,10 @@ char *bitmap, int maxsize); #endif int (*show_logo)(void); + void (*fat_size)(IF_MV2(int vol,) unsigned long* size, unsigned long* free); /* new stuff at the end, sort into place next time the API gets incompatible */ - }; int plugin_load(const char* plugin, void* parameter); Index: apps/plugins/splitedit.c =================================================================== RCS file: /cvsroot/rockbox/apps/plugins/splitedit.c,v retrieving revision 1.14 diff -u -b -r1.14 splitedit.c --- apps/plugins/splitedit.c 29 Aug 2005 21:15:20 -0000 1.14 +++ apps/plugins/splitedit.c 6 Sep 2005 16:02:54 -0000 @@ -33,6 +33,7 @@ #define SPLITEDIT_SPEED100 (BUTTON_ON | BUTTON_PLAY) #define SPLITEDIT_SPEED150 (BUTTON_ON | BUTTON_RIGHT) #define SPLITEDIT_MENU_RUN BUTTON_PLAY +#define SPLITEDIT_ABORT_COPY BUTTON_OFF #elif CONFIG_KEYPAD == ONDIO_PAD #define SPLITEDIT_QUIT BUTTON_OFF @@ -42,6 +43,7 @@ #define SPLITEDIT_LOOP_MODE (BUTTON_MENU | BUTTON_UP) #define SPLITEDIT_SCALE (BUTTON_MENU | BUTTON_RIGHT) #define SPLITEDIT_MENU_RUN BUTTON_RIGHT +#define SPLITEDIT_ABORT_COPY BUTTON_OFF #elif CONFIG_KEYPAD == IRIVER_H100_PAD #define SPLITEDIT_QUIT BUTTON_OFF @@ -53,6 +55,7 @@ #define SPLITEDIT_SPEED100 (BUTTON_REC | BUTTON_DOWN) #define SPLITEDIT_SPEED150 (BUTTON_REC | BUTTON_RIGHT) #define SPLITEDIT_MENU_RUN BUTTON_RIGHT +#define SPLITEDIT_ABORT_COPY BUTTON_OFF #endif @@ -571,18 +574,32 @@ unsigned int i = 0; ssize_t bytes_read = 1; /* ensure the for loop is executed */ unsigned int buffer_size; + int btn = BUTTON_NONE; buffer = rb->plugin_get_buffer(&buffer_size); - for (i = 0; i < bytes && bytes_read > 0; i += bytes_read) + for (i = 0; + (i < bytes) && (bytes_read > 0) && (btn != SPLITEDIT_ABORT_COPY); + i += bytes_read) { ssize_t bytes_written; - unsigned int bytes_to_read = - bytes - i > buffer_size ? buffer_size : bytes - i; + unsigned int bytes_to_read; + + btn = rb->button_get(false); + + bytes_to_read = bytes - i > buffer_size ? buffer_size : bytes - i; bytes_read = rb->read(src, buffer, bytes_to_read); bytes_written = rb->write(dest, buffer, bytes_read); rb->scrollbar(0, prg_y, LCD_WIDTH, prg_h, bytes, 0, i, HORIZONTAL); rb->lcd_update_rect(0, prg_y, LCD_WIDTH, prg_h); + + } + + if (btn == SPLITEDIT_ABORT_COPY) + { + rb->splash(0, true, "Copy aborted by user"); + rb->button_get(true); + rb->button_get(true); } } @@ -598,6 +615,7 @@ int file1, file2, src_file; unsigned int end = 0; int retval = 0; + unsigned long disksize = 0, diskfree = 0; /* Verify that file 1 doesn't exit yet */ if (file_name1 != NULL) @@ -634,6 +652,8 @@ rb->yield(); end = rb->audio_get_file_pos(); + rb->fat_size(IF_MV2(0, ) &disksize, &diskfree); + /* open the source file */ src_file = rb->open(mp3->path, O_RDONLY); if (src_file >= 0) @@ -654,6 +674,8 @@ /* write the file 1 */ if (file_name1 != NULL) { + if (diskfree > end / 1024) + { file1 = rb->open (file_name1, O_WRONLY | O_CREAT); if (file1 >= 0) { @@ -677,6 +699,15 @@ retval = -1; } } + else + { + char *fn = rb->strrchr(file_name1, '/'); + fn++; + rb->splash(0, true, "insufficiant space for %s", fn); + rb->button_get(true); + rb->button_get(true); + } + } /* if file1 hasn't been written we're not at the split point yet */ else { @@ -691,11 +722,13 @@ if (file_name2 != NULL) { + end = mp3->filesize - end; + if (diskfree > end / 1024) + { /* write file 2 */ file2 = rb->open (file_name2, O_WRONLY | O_CREAT); if (file2 >= 0) { - end = mp3->filesize - end; copy_file(file2, src_file, end, y * 5 + 1, y -1); close_stat = rb->close(file2); @@ -716,6 +749,15 @@ retval = -2; } } + else + { + char *fn = rb->strrchr(file_name2, '/'); + fn++; + rb->splash(0, true, "insufficiant space for %s", fn); + rb->button_get(true); + rb->button_get(true); + } + } close_stat = rb->close(src_file); if (close_stat != 0)