#include "config.h"#include "modules/file_system/fat.h"#include "modules/file_system/fs_com.h"#include "modules/file_system/navigation.h"
Go to the source code of this file.
Defines | |
| #define | MAX_FILE_LENGHT 30 |
Functions | |
| U8 | goto_code_name (U8 code *str, Bool b_case_sensitive, Bool b_create) |
| void | str_code_to_str_ram (U8 code string_code[], U8 str_ram[30]) |
| Bool | copy_dir (U8 code string_src[], U8 code string_dst[], Bool b_print) |
Definition in file nav_utils.h.
| #define MAX_FILE_LENGHT 30 |
Definition at line 57 of file nav_utils.h.
set the explorer navigator to the corresponding file or directory name stored in flash.
| *str,: | the file or directory name to found | |
| case_sensitive |
Definition at line 68 of file nav_utils.c.
References nav_setcwd(), str_code_to_str_ram(), and str_ram.
00070 { 00071 str_code_to_str_ram( str, str_ram ); 00072 return nav_setcwd( (FS_STRING)str_ram, b_case_sensitive, b_create); 00073 }
copy an string code to a ram buffer
| U8 | code string_code: the string code pointer | |
| U8 | *str_ram: the ram buffer pointer |
Definition at line 85 of file nav_utils.c.
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 }
This function copys a source directory to an other directory
Definition at line 103 of file nav_utils.c.
References COPY_BUSY, COPY_FINISH, FALSE, FS_ERR_FILE_EXIST, FS_ERR_NO_DIR, FS_FIND_NEXT, fs_g_status, FS_NAME_GET, FS_NAV_ID_COPY_DST_DIR, FS_NAV_ID_COPY_SRC_DIR, FS_NAV_ID_USHELL_CMD, goto_code_name(), nav_dir_cd(), nav_dir_gotoparent(), nav_dir_make(), nav_file_copy(), nav_file_del(), nav_file_isdir(), nav_file_name(), nav_file_paste_start(), nav_file_paste_state(), nav_filelist_reset(), nav_filelist_set(), nav_getindex(), nav_gotoindex(), nav_select(), SIZE_NAME_COPY, and TRUE.
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 // Save the position 00112 sav_index = nav_getindex(); 00113 00114 //** Use three navigators (to explore source, to explore destination, to copy file routine) 00115 // Select source directory 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 // Select destination directory 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 // loop to scan and create ALL folders and files 00130 while(1) 00131 { 00132 // No dir in current dir then go to parent dir on SD and NandFlash disk 00133 while(1) 00134 { 00135 //printf("Search files or dir\n\r"); 00136 // Reselect SD 00137 nav_select( FS_NAV_ID_COPY_SRC_DIR ); 00138 if( nav_filelist_set( 0 , FS_FIND_NEXT ) ) 00139 break; // a next file and directory is found 00140 00141 // No other dir or file in current dir then go to parent dir on SD and NandFlash disk 00142 if( 0 == u8_folder_level ) 00143 { 00144 // end of update folder 00145 //********* END OF COPY ************** 00146 goto copy_dir_finish; 00147 } 00148 00149 if( b_print ) printf("Go to parent\n\r"); 00150 // Remark, nav_dir_gotoparent() routine go to in parent dir and select the children dir in list 00151 u8_folder_level--; 00152 if( !nav_dir_gotoparent() ) 00153 goto copy_dir_error; 00154 // Select NandFlash navigator and go to the same dir of SD 00155 nav_select( FS_NAV_ID_COPY_DST_DIR ); 00156 if( !nav_dir_gotoparent() ) 00157 goto copy_dir_error; 00158 } // end of while (1) 00159 00160 if( nav_file_isdir()) 00161 { 00162 if( b_print ) printf("Dir found - create dir: "); 00163 //** here, a new directory is found and is selected 00164 // Get name of current selection (= dir name on SD) 00165 if( !nav_file_name( (FS_STRING)s_name, MAX_FILE_LENGHT, FS_NAME_GET, FALSE )) 00166 goto copy_dir_error; 00167 // Enter in dir (on SD) 00168 if( !nav_dir_cd()) 00169 goto copy_dir_error; 00170 u8_folder_level++; 00171 // Select NandFlash disk 00172 nav_select( FS_NAV_ID_COPY_DST_DIR ); 00173 // Create folder in NandFlash disk 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 // here, error the name exist 00181 } 00182 // Here the navigator have selected the folder on NandFlash 00183 if( !nav_dir_cd()) 00184 { 00185 if( FS_ERR_NO_DIR == fs_g_status ) 00186 { 00187 // FYC -> Copy impossible, because a file have the same name of folder 00188 } 00189 goto copy_dir_error; 00190 } 00191 // here, the folder is created and the navigatorS is entered in this dir 00192 } 00193 else 00194 { 00195 if( b_print ) printf("File found - copy file: "); 00196 //** here, a new file is found and is selected 00197 // Get name of current selection (= file name on SD) 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 // Paste file in current dir of NandFlash disk 00206 nav_select( FS_NAV_ID_COPY_DST_DIR ); 00207 while( !nav_file_paste_start( (FS_STRING)s_name ) ) 00208 { 00209 // Error 00210 if( fs_g_status != FS_ERR_FILE_EXIST ) 00211 goto copy_dir_error; 00212 // File exists then deletes this one 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 // here, retry PASTE 00217 } 00218 // Copy running 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 } // if dir OR file 00229 } // end of first while(1) 00230 00231 copy_dir_error: 00232 // Restore the position 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 // Restore the position 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 }
1.5.3