5252
5353#include " SD.h"
5454
55+ namespace SDLib {
56+
5557// Used by `getNextPathComponent`
5658#define MAX_COMPONENT_LEN 12 // What is max length?
5759#define PATH_COMPONENT_BUFFER_LEN MAX_COMPONENT_LEN+1
5860
59- bool getNextPathComponent (char *path, unsigned int *p_offset,
61+ bool getNextPathComponent (const char *path, unsigned int *p_offset,
6062 char *buffer) {
6163 /*
6264
@@ -115,9 +117,9 @@ bool getNextPathComponent(char *path, unsigned int *p_offset,
115117
116118
117119
118- boolean walkPath (char *filepath, SdFile& parentDir,
120+ boolean walkPath (const char *filepath, SdFile& parentDir,
119121 boolean (*callback)(SdFile& parentDir,
120- char *filePathComponent,
122+ const char *filePathComponent,
121123 boolean isLastComponent,
122124 void *object),
123125 void *object = NULL) {
@@ -230,7 +232,7 @@ boolean walkPath(char *filepath, SdFile& parentDir,
230232
231233 */
232234
233- boolean callback_pathExists (SdFile& parentDir, char *filePathComponent,
235+ boolean callback_pathExists (SdFile& parentDir, const char *filePathComponent,
234236 boolean isLastComponent, void *object) {
235237 /*
236238
@@ -253,7 +255,7 @@ boolean callback_pathExists(SdFile& parentDir, char *filePathComponent,
253255
254256
255257
256- boolean callback_makeDirPath (SdFile& parentDir, char *filePathComponent,
258+ boolean callback_makeDirPath (SdFile& parentDir, const char *filePathComponent,
257259 boolean isLastComponent, void *object) {
258260 /*
259261
@@ -308,15 +310,15 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent,
308310
309311
310312
311- boolean callback_remove (SdFile& parentDir, char *filePathComponent,
313+ boolean callback_remove (SdFile& parentDir, const char *filePathComponent,
312314 boolean isLastComponent, void *object) {
313315 if (isLastComponent) {
314316 return SdFile::remove (parentDir, filePathComponent);
315317 }
316318 return true ;
317319}
318320
319- boolean callback_rmdir (SdFile& parentDir, char *filePathComponent,
321+ boolean callback_rmdir (SdFile& parentDir, const char *filePathComponent,
320322 boolean isLastComponent, void *object) {
321323 if (isLastComponent) {
322324 SdFile f;
@@ -515,7 +517,7 @@ File SDClass::open(char *filepath, uint8_t mode) {
515517// }
516518
517519
518- boolean SDClass::exists (char *filepath) {
520+ boolean SDClass::exists (const char *filepath) {
519521 /*
520522
521523 Returns true if the supplied file path exists.
@@ -536,7 +538,7 @@ boolean SDClass::exists(char *filepath) {
536538// }
537539
538540
539- boolean SDClass::mkdir (char *filepath) {
541+ boolean SDClass::mkdir (const char *filepath) {
540542 /*
541543
542544 Makes a single directory or a heirarchy of directories.
@@ -547,7 +549,7 @@ boolean SDClass::mkdir(char *filepath) {
547549 return walkPath (filepath, root, callback_makeDirPath);
548550}
549551
550- boolean SDClass::rmdir (char *filepath) {
552+ boolean SDClass::rmdir (const char *filepath) {
551553 /*
552554
553555 Remove a single directory or a heirarchy of directories.
@@ -558,7 +560,7 @@ boolean SDClass::rmdir(char *filepath) {
558560 return walkPath (filepath, root, callback_rmdir);
559561}
560562
561- boolean SDClass::remove (char *filepath) {
563+ boolean SDClass::remove (const char *filepath) {
562564 return walkPath (filepath, root, callback_remove);
563565}
564566
@@ -614,3 +616,5 @@ void File::rewindDirectory(void) {
614616}
615617
616618SDClass SD;
619+
620+ };
0 commit comments