A UNIX emulation shell to access the underlying SDCard FileSystem through a terminal interface

Dependents:   Waldo_Embed_V2

Information

SDShell does not change the com baudrate. Access is made using the baud as initialized by the Serial object when passed into the SDShell object

Example

#include "mbed.h"
#include "SDFileSystem.h"
#include "SDShell.h"

Serial com(USBTX, USBRX);
SDFileSystem sd(p11, p12, p13, p14, "sd");
SDShell emulate;

int main()
{
    emulate.init();
    emulate.shell(com, sd, "/sd");
}
Committer:
sam_grove
Date:
Tue May 14 12:49:18 2013 +0000
Revision:
9:5e1764ff5dfa
Parent:
8:30aa615d4508
Child:
10:f269775edfdf
Added "du" for disk usage. Also cleaned buffers before use

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 1:514f321aa528 1
sam_grove 1:514f321aa528 2 //http://mbed.org/users/shimniok/code/SDCardShell/file/792bddcf799d/main.cpp
sam_grove 0:618e98bf18ce 3
sam_grove 0:618e98bf18ce 4 #include "SDShell.h"
sam_grove 0:618e98bf18ce 5
sam_grove 0:618e98bf18ce 6 SDShell::SDShell()
sam_grove 0:618e98bf18ce 7 {
sam_grove 1:514f321aa528 8 _debug = 0;
sam_grove 9:5e1764ff5dfa 9 memset(_cwd, 0, SHELL_BUF_SIZE);
sam_grove 1:514f321aa528 10
sam_grove 0:618e98bf18ce 11 return;
sam_grove 0:618e98bf18ce 12 }
sam_grove 0:618e98bf18ce 13
sam_grove 0:618e98bf18ce 14 void SDShell::init(void)
sam_grove 0:618e98bf18ce 15 {
sam_grove 1:514f321aa528 16 // add known commands to a linked list
sam_grove 2:b3107e463974 17 _cmds.attachMsg("ls" , this, &SDShell::ls);
sam_grove 2:b3107e463974 18 _cmds.attachMsg("cd" , this, &SDShell::cd);
sam_grove 2:b3107e463974 19 _cmds.attachMsg("pwd" , this, &SDShell::pwd);
sam_grove 2:b3107e463974 20 _cmds.attachMsg("head" , this, &SDShell::head);
sam_grove 2:b3107e463974 21 _cmds.attachMsg("cat" , this, &SDShell::cat);
sam_grove 5:3417ba8cb1e4 22 _cmds.attachMsg("bcat" , this, &SDShell::bcat);
sam_grove 2:b3107e463974 23 _cmds.attachMsg("mkdir", this, &SDShell::create);
sam_grove 2:b3107e463974 24 _cmds.attachMsg("touch", this, &SDShell::touch);
sam_grove 2:b3107e463974 25 _cmds.attachMsg("rm" , this, &SDShell::rm);
sam_grove 2:b3107e463974 26 _cmds.attachMsg("exit" , this, &SDShell::exit);
sam_grove 2:b3107e463974 27 _cmds.attachMsg("debug", this, &SDShell::debug);
sam_grove 9:5e1764ff5dfa 28 _cmds.attachMsg("du" , this, &SDShell::du);
sam_grove 2:b3107e463974 29
sam_grove 0:618e98bf18ce 30 return;
sam_grove 0:618e98bf18ce 31 }
sam_grove 0:618e98bf18ce 32
sam_grove 2:b3107e463974 33 void SDShell::shell(Serial &com, SDFileSystem &storage, char const *cwd)
sam_grove 0:618e98bf18ce 34 {
sam_grove 1:514f321aa528 35 uint32_t done = 0;
sam_grove 1:514f321aa528 36
sam_grove 1:514f321aa528 37 // get local copies of the initialized objects
sam_grove 0:618e98bf18ce 38 _com = &com;
sam_grove 1:514f321aa528 39 _storage = &storage;
sam_grove 1:514f321aa528 40
sam_grove 1:514f321aa528 41 // put the current working directory to the root of the card - should be pulled in I think
sam_grove 2:b3107e463974 42 strcpy(_cwd, cwd);
sam_grove 1:514f321aa528 43
sam_grove 1:514f321aa528 44 while(0 == done)
sam_grove 0:618e98bf18ce 45 {
sam_grove 9:5e1764ff5dfa 46 memset(_cmd , 0, SHELL_BUF_SIZE);
sam_grove 9:5e1764ff5dfa 47 memset(_cmdline, 0, SHELL_BUF_SIZE);
sam_grove 9:5e1764ff5dfa 48 memset(_newpath, 0, SHELL_BUF_SIZE);
sam_grove 1:514f321aa528 49 // gather input from the Serial object
sam_grove 1:514f321aa528 50 shellInput();
sam_grove 1:514f321aa528 51 // break up the command line arguemnt
sam_grove 2:b3107e463974 52 _arg = split(_cmd, _cmdline, 64, ' ');
sam_grove 1:514f321aa528 53 // look at the arg and get paths and files separated if present
sam_grove 2:b3107e463974 54 resolveDirectory(_newpath, _arg);
sam_grove 2:b3107e463974 55 // print parsed members if we're debugging
sam_grove 1:514f321aa528 56 if(_debug)
sam_grove 1:514f321aa528 57 {
sam_grove 2:b3107e463974 58 LOG("cmdline:<%s> cmd:<%s> arg:<%s> newpath:<%s>\n", _cmdline, _cmd, _arg, _newpath);
sam_grove 1:514f321aa528 59 }
sam_grove 2:b3107e463974 60 // now service known messages
sam_grove 2:b3107e463974 61 char* result = _cmds.serviceMessage(_cmd);
sam_grove 2:b3107e463974 62 // look at the result > 0 means we found somehting
sam_grove 2:b3107e463974 63 if(result == (char *)EXIT)
sam_grove 1:514f321aa528 64 {
sam_grove 2:b3107e463974 65 done = 1; // force an exit
sam_grove 1:514f321aa528 66 }
sam_grove 2:b3107e463974 67 else if (result == (char *)UNKNOWN) // didnt know what that was
sam_grove 1:514f321aa528 68 {
sam_grove 2:b3107e463974 69 uint32_t cnt = 1;
sam_grove 2:b3107e463974 70 LOG("Unknown Message from Terminal: Options are\n");
jekain314 4:6ff0a3d92778 71 do{
sam_grove 2:b3107e463974 72 result = _cmds.messageLookup(cnt++);
sam_grove 2:b3107e463974 73 _com->printf(" %s\n", result);
sam_grove 2:b3107e463974 74 } while(result != NULL);
sam_grove 0:618e98bf18ce 75 }
sam_grove 0:618e98bf18ce 76 else
sam_grove 0:618e98bf18ce 77 {
sam_grove 2:b3107e463974 78 // that should have done something
sam_grove 0:618e98bf18ce 79 }
sam_grove 0:618e98bf18ce 80 }
sam_grove 1:514f321aa528 81 }
sam_grove 0:618e98bf18ce 82
sam_grove 1:514f321aa528 83 void SDShell::shellInput(void)
sam_grove 0:618e98bf18ce 84 {
sam_grove 1:514f321aa528 85 int i=0;
sam_grove 1:514f321aa528 86 char c;
sam_grove 1:514f321aa528 87 uint32_t done = 0;
sam_grove 1:514f321aa528 88 // clear the last command
sam_grove 2:b3107e463974 89 // memset(_cmdline, 0, SHELL_BUF_SIZE);
sam_grove 1:514f321aa528 90 _com->printf("# ", _cwd);
sam_grove 1:514f321aa528 91 do
sam_grove 0:618e98bf18ce 92 {
sam_grove 2:b3107e463974 93 _cmdline[i] = 0; // clearing the next loc before using it is faster than memset
sam_grove 2:b3107e463974 94 c = _com->getc(); // get a char
jekain314 8:30aa615d4508 95 if ((c == '\r') || (c == '\n')) // process on "enter"
sam_grove 1:514f321aa528 96 {
sam_grove 1:514f321aa528 97 done = 1;
sam_grove 1:514f321aa528 98 }
sam_grove 2:b3107e463974 99 else if (i < SHELL_BUF_MASK) // once full the user can only press enter
sam_grove 0:618e98bf18ce 100 {
sam_grove 2:b3107e463974 101 if (c == 0x7f) // backspace
sam_grove 2:b3107e463974 102 {
sam_grove 2:b3107e463974 103 if (i > 0) // if we're at the beginning, do nothing
sam_grove 2:b3107e463974 104 {
sam_grove 1:514f321aa528 105 i--;
sam_grove 1:514f321aa528 106 _com->printf("\b \b");
sam_grove 1:514f321aa528 107 }
sam_grove 1:514f321aa528 108 }
sam_grove 2:b3107e463974 109 else // valid keystrokes get stored and echo'd
sam_grove 1:514f321aa528 110 {
sam_grove 1:514f321aa528 111 _com->putc(c);
sam_grove 2:b3107e463974 112 _cmdline[i++] = c;
sam_grove 1:514f321aa528 113 }
sam_grove 0:618e98bf18ce 114 }
sam_grove 2:b3107e463974 115 } while(0 == done);
sam_grove 1:514f321aa528 116
sam_grove 1:514f321aa528 117 _com->printf("\n");
sam_grove 0:618e98bf18ce 118 }
sam_grove 0:618e98bf18ce 119
sam_grove 1:514f321aa528 120 char *SDShell::split(char *dst, char *src, int max, char delim)
sam_grove 0:618e98bf18ce 121 {
sam_grove 1:514f321aa528 122 int i = 0;
sam_grove 1:514f321aa528 123 char *v;
sam_grove 1:514f321aa528 124
sam_grove 1:514f321aa528 125 // make sure pointers are valid (could validate RAM but that should be the caller responsibility)
sam_grove 2:b3107e463974 126 if ((dst == 0) || (src == 0))
sam_grove 1:514f321aa528 127 {
sam_grove 1:514f321aa528 128 return 0;
sam_grove 1:514f321aa528 129 }
sam_grove 2:b3107e463974 130 // break up the string until delim is found
sam_grove 1:514f321aa528 131 while((*src != 0) && (*src != delim) && (i < max))
sam_grove 0:618e98bf18ce 132 {
sam_grove 1:514f321aa528 133 *(dst++) = *(src++);
sam_grove 1:514f321aa528 134 i++;
sam_grove 1:514f321aa528 135 }
sam_grove 2:b3107e463974 136 // return what comes after the delimiter - dst has before the delimiter
sam_grove 2:b3107e463974 137 *dst = 0;
sam_grove 2:b3107e463974 138 v = (*src == '\0') ? dst : (src+1);
sam_grove 1:514f321aa528 139
sam_grove 1:514f321aa528 140 return v;
sam_grove 1:514f321aa528 141 }
sam_grove 1:514f321aa528 142
sam_grove 1:514f321aa528 143 void SDShell::resolveDirectory(char *newpath, char *path)
sam_grove 1:514f321aa528 144 {
sam_grove 1:514f321aa528 145 char basename[64], dirname[64];
sam_grove 1:514f321aa528 146
sam_grove 1:514f321aa528 147 // absolute path
sam_grove 1:514f321aa528 148 if (path[0] == '/')
sam_grove 1:514f321aa528 149 {
sam_grove 1:514f321aa528 150 strcpy(newpath, path);
sam_grove 1:514f321aa528 151 }
sam_grove 1:514f321aa528 152 // relative path
sam_grove 1:514f321aa528 153 else
sam_grove 1:514f321aa528 154 {
sam_grove 1:514f321aa528 155 strcpy(newpath, _cwd);
sam_grove 1:514f321aa528 156 // make sure something was passed
sam_grove 1:514f321aa528 157 if(path[0] != 0)
sam_grove 0:618e98bf18ce 158 {
sam_grove 1:514f321aa528 159 // add the backslash if the user didnt
sam_grove 1:514f321aa528 160 if(newpath[strlen(newpath)-1] != '/')
sam_grove 1:514f321aa528 161 {
sam_grove 1:514f321aa528 162 strcat(newpath, "/");
sam_grove 1:514f321aa528 163 }
sam_grove 1:514f321aa528 164 strcat(newpath, path);
sam_grove 0:618e98bf18ce 165 }
sam_grove 1:514f321aa528 166 // Resolve .. references
sam_grove 1:514f321aa528 167 splitName(newpath, dirname, basename);
sam_grove 1:514f321aa528 168 if (0 == strcmp(basename, ".."))
sam_grove 1:514f321aa528 169 {
sam_grove 1:514f321aa528 170 splitName(dirname, newpath, basename);
sam_grove 1:514f321aa528 171 }
sam_grove 0:618e98bf18ce 172 }
sam_grove 0:618e98bf18ce 173
sam_grove 1:514f321aa528 174 return;
sam_grove 0:618e98bf18ce 175 }
sam_grove 0:618e98bf18ce 176
sam_grove 1:514f321aa528 177 void SDShell::splitName(char *path, char *dirname, char *basename)
sam_grove 1:514f321aa528 178 {
sam_grove 1:514f321aa528 179 int sep = 0;
sam_grove 2:b3107e463974 180 // print the original path
sam_grove 1:514f321aa528 181 if (_debug)
sam_grove 1:514f321aa528 182 {
sam_grove 1:514f321aa528 183 LOG("%d\n", strlen(path));
sam_grove 1:514f321aa528 184 }
sam_grove 2:b3107e463974 185 // find the directory backslash location in the path
sam_grove 1:514f321aa528 186 for (int i=strlen(path)-1; i >= 0; i--)
sam_grove 1:514f321aa528 187 {
sam_grove 2:b3107e463974 188 if (_debug) // print what we found
sam_grove 1:514f321aa528 189 {
sam_grove 1:514f321aa528 190 LOG("- %c\n", path[i]);
sam_grove 1:514f321aa528 191 }
sam_grove 1:514f321aa528 192 sep = i;
sam_grove 1:514f321aa528 193 if (path[i] == '/')
sam_grove 1:514f321aa528 194 {
sam_grove 1:514f321aa528 195 break;
sam_grove 1:514f321aa528 196 }
sam_grove 1:514f321aa528 197 }
sam_grove 2:b3107e463974 198 // extract the directory
sam_grove 2:b3107e463974 199 for (int i=0; i < sep; i++)
sam_grove 1:514f321aa528 200 {
sam_grove 2:b3107e463974 201 if (_debug) // print what we found
sam_grove 1:514f321aa528 202 {
sam_grove 2:b3107e463974 203 LOG("> %c\n", path[i]);
sam_grove 1:514f321aa528 204 }
sam_grove 2:b3107e463974 205 dirname[i] = path[i];
sam_grove 2:b3107e463974 206 dirname[i+1] = 0;
sam_grove 1:514f321aa528 207 }
sam_grove 2:b3107e463974 208 // and then split the file from directory
sam_grove 2:b3107e463974 209 for (int i=sep+1; i < strlen(path); i++)
sam_grove 1:514f321aa528 210 {
sam_grove 2:b3107e463974 211 if (_debug) // print what we found
sam_grove 1:514f321aa528 212 {
sam_grove 2:b3107e463974 213 LOG("* %c\n", path[i]);
sam_grove 1:514f321aa528 214 }
sam_grove 2:b3107e463974 215 basename[i-(sep+1)] = path[i];
sam_grove 2:b3107e463974 216 basename[i-sep] = 0;
sam_grove 1:514f321aa528 217 }
sam_grove 2:b3107e463974 218 if (_debug) // print the the split
sam_grove 1:514f321aa528 219 {
sam_grove 1:514f321aa528 220 LOG("d:<%s> b:<%s>\n", dirname, basename);
sam_grove 1:514f321aa528 221 }
sam_grove 1:514f321aa528 222 }
sam_grove 0:618e98bf18ce 223
sam_grove 2:b3107e463974 224 char *SDShell::ls(char *cmd)
sam_grove 1:514f321aa528 225 {
sam_grove 2:b3107e463974 226 if (_debug)
sam_grove 2:b3107e463974 227 {
sam_grove 2:b3107e463974 228 LOG("%s\n", _cwd);
sam_grove 2:b3107e463974 229 }
sam_grove 2:b3107e463974 230
sam_grove 2:b3107e463974 231 DIR *d = opendir(_newpath);
sam_grove 2:b3107e463974 232 if (NULL != d)
sam_grove 2:b3107e463974 233 {
sam_grove 2:b3107e463974 234 struct dirent *p;
sam_grove 2:b3107e463974 235 while ((p = readdir(d)) != NULL)
sam_grove 2:b3107e463974 236 {
sam_grove 2:b3107e463974 237 _com->printf(" %s\n", p->d_name);
sam_grove 2:b3107e463974 238 }
sam_grove 2:b3107e463974 239 closedir(d);
sam_grove 2:b3107e463974 240 }
sam_grove 2:b3107e463974 241 else
sam_grove 2:b3107e463974 242 {
sam_grove 2:b3107e463974 243 _com->printf("%s: No such directory\n", _newpath);
sam_grove 2:b3107e463974 244 }
sam_grove 2:b3107e463974 245
sam_grove 2:b3107e463974 246 return (char *)OK;
sam_grove 1:514f321aa528 247 }
sam_grove 1:514f321aa528 248
sam_grove 2:b3107e463974 249 char *SDShell::cd(char *cmd)
sam_grove 1:514f321aa528 250 {
sam_grove 2:b3107e463974 251 strcpy(_cwd, _newpath);
sam_grove 2:b3107e463974 252
sam_grove 2:b3107e463974 253 return (char *)OK;
sam_grove 2:b3107e463974 254 }
sam_grove 0:618e98bf18ce 255
sam_grove 2:b3107e463974 256 char *SDShell::pwd(char *path)
sam_grove 2:b3107e463974 257 {
sam_grove 2:b3107e463974 258 _com->printf("%s\n", _cwd);
sam_grove 2:b3107e463974 259
sam_grove 2:b3107e463974 260 return (char *)OK;
sam_grove 1:514f321aa528 261 }
sam_grove 1:514f321aa528 262
sam_grove 2:b3107e463974 263 char *SDShell::head(char *cmd)
sam_grove 1:514f321aa528 264 {
sam_grove 2:b3107e463974 265 FILE *fp = fopen(_newpath, "r");
sam_grove 2:b3107e463974 266 if (fp != NULL)
sam_grove 2:b3107e463974 267 {
sam_grove 2:b3107e463974 268 uint32_t line = 0;
sam_grove 2:b3107e463974 269 while ((0 == feof(fp)) && ((line++) < 10))
sam_grove 2:b3107e463974 270 {
sam_grove 2:b3107e463974 271 fgets(_buf, 512, fp);
sam_grove 2:b3107e463974 272 _com->printf("%s", _buf);
sam_grove 2:b3107e463974 273 }
sam_grove 2:b3107e463974 274 fclose(fp);
sam_grove 2:b3107e463974 275 }
sam_grove 2:b3107e463974 276 else
sam_grove 2:b3107e463974 277 {
sam_grove 2:b3107e463974 278 _com->printf("%s: No such file\n", _newpath);
sam_grove 2:b3107e463974 279 }
sam_grove 2:b3107e463974 280
sam_grove 2:b3107e463974 281 return (char *)OK;
sam_grove 1:514f321aa528 282 }
sam_grove 1:514f321aa528 283
sam_grove 2:b3107e463974 284 char *SDShell::cat(char *cmd)
sam_grove 1:514f321aa528 285 {
sam_grove 9:5e1764ff5dfa 286 memset(_buf, 0, 512);
sam_grove 2:b3107e463974 287 FILE *fp= fopen(_newpath, "r");
sam_grove 2:b3107e463974 288 if (fp != NULL)
sam_grove 2:b3107e463974 289 {
sam_grove 2:b3107e463974 290 while (!feof(fp))
sam_grove 2:b3107e463974 291 {
sam_grove 2:b3107e463974 292 fread(_buf, 1, 512, fp);
sam_grove 2:b3107e463974 293 _com->printf("%s", _buf);
sam_grove 1:514f321aa528 294 }
sam_grove 1:514f321aa528 295 fclose(fp);
sam_grove 1:514f321aa528 296 }
sam_grove 2:b3107e463974 297 else
sam_grove 2:b3107e463974 298 {
sam_grove 2:b3107e463974 299 _com->printf("%s: No such file\n", _newpath);
sam_grove 2:b3107e463974 300 }
sam_grove 2:b3107e463974 301
sam_grove 2:b3107e463974 302 return (char *)OK;
sam_grove 1:514f321aa528 303 }
sam_grove 0:618e98bf18ce 304
sam_grove 5:3417ba8cb1e4 305 char *SDShell::bcat(char *cmd)
jekain314 4:6ff0a3d92778 306 {
jekain314 8:30aa615d4508 307 uint8_t buf[4] = {NULL};
jekain314 4:6ff0a3d92778 308 FILE *fp= fopen(_newpath, "rb");
jekain314 4:6ff0a3d92778 309 if (fp != NULL)
jekain314 4:6ff0a3d92778 310 {
jekain314 4:6ff0a3d92778 311 while (!feof(fp))
jekain314 4:6ff0a3d92778 312 {
jekain314 8:30aa615d4508 313 fread(buf, 1, 1, fp);
jekain314 8:30aa615d4508 314 _com->putc(buf[0]);
jekain314 4:6ff0a3d92778 315 }
jekain314 4:6ff0a3d92778 316 fclose(fp);
jekain314 4:6ff0a3d92778 317 }
jekain314 4:6ff0a3d92778 318 else
jekain314 4:6ff0a3d92778 319 {
jekain314 4:6ff0a3d92778 320 _com->printf("%s: No such file\n", _newpath);
jekain314 4:6ff0a3d92778 321 }
jekain314 4:6ff0a3d92778 322 return (char *)OK;
jekain314 4:6ff0a3d92778 323 }
jekain314 4:6ff0a3d92778 324
sam_grove 2:b3107e463974 325 char *SDShell::touch(char *cmd)
sam_grove 1:514f321aa528 326 {
sam_grove 2:b3107e463974 327 FILE *fp = fopen(_newpath, "w");
sam_grove 2:b3107e463974 328 if (fp != NULL)
sam_grove 2:b3107e463974 329 {
sam_grove 2:b3107e463974 330 _com->printf("%s: File created\n", _newpath);
sam_grove 2:b3107e463974 331 fclose(fp);
sam_grove 2:b3107e463974 332 }
sam_grove 2:b3107e463974 333 else
sam_grove 2:b3107e463974 334 {
sam_grove 2:b3107e463974 335 _com->printf("%s: No such file\n", _newpath);
sam_grove 2:b3107e463974 336 }
sam_grove 2:b3107e463974 337
sam_grove 2:b3107e463974 338 return (char *)OK;
sam_grove 2:b3107e463974 339 }
sam_grove 0:618e98bf18ce 340
sam_grove 2:b3107e463974 341 char *SDShell::create(char *cmd)
sam_grove 2:b3107e463974 342 {
sam_grove 2:b3107e463974 343 mkdir(_newpath, 1023);
sam_grove 2:b3107e463974 344
sam_grove 2:b3107e463974 345 return (char *)OK;
sam_grove 1:514f321aa528 346 }
sam_grove 1:514f321aa528 347
sam_grove 2:b3107e463974 348 char *SDShell::rm(char *cmd)
sam_grove 1:514f321aa528 349 {
sam_grove 2:b3107e463974 350 remove(_newpath);
sam_grove 2:b3107e463974 351
sam_grove 2:b3107e463974 352 return (char *)OK;
sam_grove 1:514f321aa528 353 }
sam_grove 1:514f321aa528 354
sam_grove 2:b3107e463974 355 char *SDShell::exit(char *cmd)
sam_grove 2:b3107e463974 356 {
sam_grove 2:b3107e463974 357 return (char *)EXIT;
sam_grove 2:b3107e463974 358 }
sam_grove 2:b3107e463974 359
sam_grove 2:b3107e463974 360 char *SDShell::debug(char *cmd)
sam_grove 2:b3107e463974 361 {
sam_grove 2:b3107e463974 362 _debug = !_debug;
sam_grove 2:b3107e463974 363
sam_grove 2:b3107e463974 364 return (char *)OK;
sam_grove 2:b3107e463974 365 }
sam_grove 2:b3107e463974 366
sam_grove 9:5e1764ff5dfa 367 char *SDShell::du(char *cmd)
sam_grove 5:3417ba8cb1e4 368 {
sam_grove 9:5e1764ff5dfa 369 uint32_t file_size = 0;
sam_grove 9:5e1764ff5dfa 370 memset(_buf, 0, 512);
sam_grove 9:5e1764ff5dfa 371
sam_grove 9:5e1764ff5dfa 372 FILE *fp= fopen(_newpath, "rb");
sam_grove 9:5e1764ff5dfa 373 if (fp != NULL)
sam_grove 9:5e1764ff5dfa 374 {
sam_grove 9:5e1764ff5dfa 375 while (!feof(fp))
sam_grove 9:5e1764ff5dfa 376 {
sam_grove 9:5e1764ff5dfa 377 uint32_t tmp = fread(_buf, 1, 512, fp);
sam_grove 9:5e1764ff5dfa 378 file_size += tmp;
sam_grove 9:5e1764ff5dfa 379 }
sam_grove 9:5e1764ff5dfa 380 fclose(fp);
sam_grove 9:5e1764ff5dfa 381 _com->printf(" %d (bytes) %s\n", file_size, _newpath);
sam_grove 9:5e1764ff5dfa 382 }
sam_grove 9:5e1764ff5dfa 383 else
sam_grove 9:5e1764ff5dfa 384 {
sam_grove 9:5e1764ff5dfa 385 _com->printf("%s: No such file\n", _newpath);
sam_grove 9:5e1764ff5dfa 386 }
sam_grove 9:5e1764ff5dfa 387 return (char *)OK;
sam_grove 5:3417ba8cb1e4 388 }
sam_grove 2:b3107e463974 389
sam_grove 2:b3107e463974 390
sam_grove 2:b3107e463974 391