comparison sd.c @ 59:488085e0c7e1

Don't print extra newlines when cat'ing a file.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 08 Apr 2013 23:10:47 +0930
parents f0563086040d
children fc21fb5b171b
comparison
equal deleted inserted replaced
58:0e7d687a2322 59:488085e0c7e1
238 fno.fattrib & AM_ARC ? "A" : ""); 238 fno.fattrib & AM_ARC ? "A" : "");
239 } 239 }
240 } else if (!strcmp(argv[0], "cat")) { 240 } else if (!strcmp(argv[0], "cat")) {
241 FRESULT fserr; 241 FRESULT fserr;
242 FIL f; 242 FIL f;
243 char buf[128], *tmp; 243 char buf[128];
244 244
245 if (argc != 2) { 245 if (argc != 2) {
246 printf("No file given\n"); 246 printf("No file given\n");
247 return; 247 return;
248 } 248 }
250 if ((fserr = f_open(&f, argv[1], FA_READ)) != FR_OK) { 250 if ((fserr = f_open(&f, argv[1], FA_READ)) != FR_OK) {
251 printf("Failed to open file: %d\n", fserr); 251 printf("Failed to open file: %d\n", fserr);
252 return; 252 return;
253 } 253 }
254 254
255 while ((tmp = f_gets(buf, sizeof(buf), &f)) != NULL) { 255 while (f_gets(buf, sizeof(buf), &f) != NULL)
256 puts(tmp); 256 fputs(buf, stdout);
257 }
258 257
259 f_close(&f); 258 f_close(&f);
260 259
261 } else if (!strcmp(argv[0], "wr")) { 260 } else if (!strcmp(argv[0], "wr")) {
262 FRESULT fserr; 261 FRESULT fserr;