00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "config.h"
00043 #include <stdio.h>
00044 #include "nav_utils.h"
00045
00046
00047
00048 #define SIZE_NAME_COPY 50
00049
00050
00051
00052
00053
00054
00056 U8 str_ram[MAX_FILE_LENGHT];
00057
00058
00065 #ifdef __GNUC__
00066 U8 goto_code_name(U8 *str, Bool b_case_sensitive, Bool b_create)
00067 #else
00068 U8 goto_code_name(U8 code *str, Bool b_case_sensitive, Bool b_create)
00069 #endif
00070 {
00071 str_code_to_str_ram( str, str_ram );
00072 return nav_setcwd( (FS_STRING)str_ram, b_case_sensitive, b_create);
00073 }
00074
00075
00082 #ifdef __GNUC__
00083 void str_code_to_str_ram(U8 string_code[],U8 str_ram[MAX_FILE_LENGHT])
00084 #else
00085 void str_code_to_str_ram(U8 code string_code[],U8 str_ram[MAX_FILE_LENGHT])
00086 #endif
00087 {
00088 U8 i;
00089 for(i=0;i<MAX_FILE_LENGHT;i++)
00090 #ifndef __GNUC__
00091 { str_ram[i]=string_code[i];}
00092 #else
00093 { str_ram[i]=pgm_read_byte_near((unsigned int)string_code+i); }
00094 #endif
00095 }
00096
00097
00100 #ifdef __GNUC__
00101 Bool copy_dir( U8 string_src[], U8 string_dst[], Bool b_print )
00102 #else
00103 Bool copy_dir( U8 code string_src[], U8 code string_dst[], Bool b_print )
00104 #endif
00105 {
00106 Fs_index sav_index;
00107 char s_name[SIZE_NAME_COPY];
00108 U8 u8_folder_level = 0;
00109
00110 if( b_print ) printf("\n\r");
00111
00112 sav_index = nav_getindex();
00113
00114
00115
00116 if( b_print ) printf("Select source directory\n\r");
00117 nav_select( FS_NAV_ID_COPY_SRC_DIR );
00118 if( !goto_code_name( string_src, FALSE, FALSE ) )
00119 goto copy_dir_error;
00120 nav_filelist_reset();
00121
00122 if( b_print ) printf("Select destination directory\n\r");
00123 nav_select( FS_NAV_ID_COPY_DST_DIR );
00124 if( !goto_code_name( string_dst, FALSE, TRUE ) )
00125 goto copy_dir_error;
00126 nav_filelist_reset();
00127
00128
00129
00130 while(1)
00131 {
00132
00133 while(1)
00134 {
00135
00136
00137 nav_select( FS_NAV_ID_COPY_SRC_DIR );
00138 if( nav_filelist_set( 0 , FS_FIND_NEXT ) )
00139 break;
00140
00141
00142 if( 0 == u8_folder_level )
00143 {
00144
00145
00146 goto copy_dir_finish;
00147 }
00148
00149 if( b_print ) printf("Go to parent\n\r");
00150
00151 u8_folder_level--;
00152 if( !nav_dir_gotoparent() )
00153 goto copy_dir_error;
00154
00155 nav_select( FS_NAV_ID_COPY_DST_DIR );
00156 if( !nav_dir_gotoparent() )
00157 goto copy_dir_error;
00158 }
00159
00160 if( nav_file_isdir())
00161 {
00162 if( b_print ) printf("Dir found - create dir: ");
00163
00164
00165 if( !nav_file_name( (FS_STRING)s_name, MAX_FILE_LENGHT, FS_NAME_GET, FALSE ))
00166 goto copy_dir_error;
00167
00168 if( !nav_dir_cd())
00169 goto copy_dir_error;
00170 u8_folder_level++;
00171
00172 nav_select( FS_NAV_ID_COPY_DST_DIR );
00173
00174 if( b_print ) printf((char*)s_name);
00175 if( b_print ) printf("\n\r");
00176 if( !nav_dir_make( (FS_STRING )s_name ))
00177 {
00178 if( FS_ERR_FILE_EXIST != fs_g_status )
00179 goto copy_dir_error;
00180
00181 }
00182
00183 if( !nav_dir_cd())
00184 {
00185 if( FS_ERR_NO_DIR == fs_g_status )
00186 {
00187
00188 }
00189 goto copy_dir_error;
00190 }
00191
00192 }
00193 else
00194 {
00195 if( b_print ) printf("File found - copy file: ");
00196
00197
00198 if( !nav_file_name( (FS_STRING)s_name, MAX_FILE_LENGHT, FS_NAME_GET, FALSE ))
00199 goto copy_dir_error;
00200 if( b_print ) printf((char*)s_name);
00201 if( b_print ) printf("\n\r");
00202 if( !nav_file_copy())
00203 goto copy_dir_error;
00204
00205
00206 nav_select( FS_NAV_ID_COPY_DST_DIR );
00207 while( !nav_file_paste_start( (FS_STRING)s_name ) )
00208 {
00209
00210 if( fs_g_status != FS_ERR_FILE_EXIST )
00211 goto copy_dir_error;
00212
00213 if( b_print ) printf("File exists then deletes this one.\n\r");
00214 if( !nav_file_del( TRUE ) )
00215 goto copy_dir_error;
00216
00217 }
00218
00219 {
00220 U8 status;
00221 do{
00222 status = nav_file_paste_state(FALSE);
00223 }while( COPY_BUSY == status );
00224
00225 if( COPY_FINISH != status )
00226 goto copy_dir_error;
00227 }
00228 }
00229 }
00230
00231 copy_dir_error:
00232
00233 nav_select( FS_NAV_ID_USHELL_CMD );
00234 nav_gotoindex(&sav_index);
00235 if( b_print ) printf("!!!copy fail\n\r");
00236 return FALSE;
00237
00238 copy_dir_finish:
00239
00240 nav_select( FS_NAV_ID_USHELL_CMD );
00241 nav_gotoindex(&sav_index);
00242 if( b_print ) printf("End of copy\n\r");
00243 return TRUE;
00244 }
00245
00246