aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.h3
-rw-r--r--nandroid.c14
-rw-r--r--ui.c27
3 files changed, 27 insertions, 17 deletions
diff --git a/common.h b/common.h
index 98842fe..29d100c 100644
--- a/common.h
+++ b/common.h
@@ -36,10 +36,11 @@ void ui_clear_key_queue();
void ui_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void ui_printlogtail(int nb_lines);
-void ui_reset_text_col();
void ui_set_show_text(int value);
void ui_set_nice(int enabled);
#define ui_nice_print(...) ui_set_nice(1); ui_print(__VA_ARGS__); ui_set_nice(0)
+int ui_was_niced();
+int ui_get_text_cols();
// Display some header text followed by a menu of items, which appears
// at the top of the screen (in place of any scrolling ui_print()
diff --git a/nandroid.c b/nandroid.c
index e44c7b6..733f3c2 100644
--- a/nandroid.c
+++ b/nandroid.c
@@ -74,12 +74,13 @@ static void yaffs_callback(const char* filename)
strcpy(tmp, justfile);
if (tmp[strlen(tmp) - 1] == '\n')
tmp[strlen(tmp) - 1] = NULL;
- if (strlen(tmp) < 30)
- ui_nice_print("%s", tmp);
+ tmp[ui_get_text_cols() - 1] = '\0';
yaffs_files_count++;
- if (yaffs_files_total != 0)
+ ui_nice_print("%s\n", tmp);
+ if (!ui_was_niced() && yaffs_files_total != 0)
ui_set_progress((float)yaffs_files_count / (float)yaffs_files_total);
- ui_reset_text_col();
+ if (!ui_was_niced())
+ ui_delete_line();
}
static void compute_directory_stats(const char* directory)
@@ -108,10 +109,7 @@ static int mkyaffs2image_wrapper(const char* backup_path, const char* backup_fil
static int tar_compress_wrapper(const char* backup_path, const char* backup_file_image, int callback) {
char tmp[PATH_MAX];
- if (strcmp(backup_path, "/data") == 0 && is_data_media())
- sprintf(tmp, "cd $(dirname %s) ; touch %s.tar ; tar cv --exclude 'media' $(basename %s) | split -a 1 -b 1000000000 /proc/self/fd/0 %s.tar. ; exit $?", backup_path, backup_file_image, backup_path, backup_file_image);
- else
- sprintf(tmp, "cd $(dirname %s) ; touch %s.tar ; tar cv $(basename %s) | split -a 1 -b 1000000000 /proc/self/fd/0 %s.tar. ; exit $?", backup_path, backup_file_image, backup_path, backup_file_image);
+ sprintf(tmp, "cd $(dirname %s) ; touch %s.tar ; (tar cv %s $(basename %s) | split -a 1 -b 1000000000 /proc/self/fd/0 %s.tar.) 2> /proc/self/fd/1 ; exit $?", backup_path, backup_file_image, strcmp(backup_path, "/data") == 0 && is_data_media() ? "--exclude 'media'" : "", backup_path, backup_file_image);
FILE *fp = __popen(tmp, "r");
if (fp == NULL) {
diff --git a/ui.c b/ui.c
index 97a8152..3ca9598 100644
--- a/ui.c
+++ b/ui.c
@@ -629,9 +629,24 @@ static long delta_milliseconds(struct timeval from, struct timeval to) {
static struct timeval lastupdate = (struct timeval) {0};
static int ui_nice = 0;
+static int ui_niced = 0;
void ui_set_nice(int enabled) {
ui_nice = enabled;
}
+#define NICE_INTERVAL 100
+int ui_was_niced() {
+ return ui_niced;
+}
+int ui_get_text_cols() {
+ return text_cols;
+}
+void ui_delete_line() {
+ pthread_mutex_lock(&gUpdateMutex);
+ text[text_row][0] = '\0';
+ text_row = (text_row - 1 + text_rows) % text_rows;
+ text_col = 0;
+ pthread_mutex_unlock(&gUpdateMutex);
+}
void ui_print(const char *fmt, ...)
{
@@ -646,11 +661,14 @@ void ui_print(const char *fmt, ...)
// if we are running 'ui nice' mode, we do not want to force a screen update
// for this line if not necessary.
+ ui_niced = 0;
if (ui_nice) {
struct timeval curtime;
gettimeofday(&curtime, NULL);
- if (delta_milliseconds(lastupdate, curtime) < 1000)
+ if (delta_milliseconds(lastupdate, curtime) < NICE_INTERVAL) {
+ ui_niced = 1;
return;
+ }
lastupdate = curtime;
}
@@ -695,13 +713,6 @@ void ui_printlogtail(int nb_lines) {
ui_log_stdout=1;
}
-void ui_reset_text_col()
-{
- pthread_mutex_lock(&gUpdateMutex);
- text_col = 0;
- pthread_mutex_unlock(&gUpdateMutex);
-}
-
#define MENU_ITEM_HEADER " - "
#define MENU_ITEM_HEADER_LENGTH strlen(MENU_ITEM_HEADER)