Skip to content

Commit e3fae38

Browse files
committed
Declare paths parameters as constant
This way we will avoid some warnings when using paths as constants in #define's `warning: deprecated conversion from string constant to 'char*'`
1 parent a6602ca commit e3fae38

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

libraries/SD/src/SD.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace SDLib {
5858
#define MAX_COMPONENT_LEN 12 // What is max length?
5959
#define PATH_COMPONENT_BUFFER_LEN MAX_COMPONENT_LEN+1
6060

61-
bool getNextPathComponent(char *path, unsigned int *p_offset,
61+
bool getNextPathComponent(const char *path, unsigned int *p_offset,
6262
char *buffer) {
6363
/*
6464
@@ -117,9 +117,9 @@ bool getNextPathComponent(char *path, unsigned int *p_offset,
117117

118118

119119

120-
boolean walkPath(char *filepath, SdFile& parentDir,
120+
boolean walkPath(const char *filepath, SdFile& parentDir,
121121
boolean (*callback)(SdFile& parentDir,
122-
char *filePathComponent,
122+
const char *filePathComponent,
123123
boolean isLastComponent,
124124
void *object),
125125
void *object = NULL) {
@@ -232,7 +232,7 @@ boolean walkPath(char *filepath, SdFile& parentDir,
232232
233233
*/
234234

235-
boolean callback_pathExists(SdFile& parentDir, char *filePathComponent,
235+
boolean callback_pathExists(SdFile& parentDir, const char *filePathComponent,
236236
boolean isLastComponent, void *object) {
237237
/*
238238
@@ -255,7 +255,7 @@ boolean callback_pathExists(SdFile& parentDir, char *filePathComponent,
255255

256256

257257

258-
boolean callback_makeDirPath(SdFile& parentDir, char *filePathComponent,
258+
boolean callback_makeDirPath(SdFile& parentDir, const char *filePathComponent,
259259
boolean isLastComponent, void *object) {
260260
/*
261261
@@ -310,15 +310,15 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent,
310310

311311

312312

313-
boolean callback_remove(SdFile& parentDir, char *filePathComponent,
313+
boolean callback_remove(SdFile& parentDir, const char *filePathComponent,
314314
boolean isLastComponent, void *object) {
315315
if (isLastComponent) {
316316
return SdFile::remove(parentDir, filePathComponent);
317317
}
318318
return true;
319319
}
320320

321-
boolean callback_rmdir(SdFile& parentDir, char *filePathComponent,
321+
boolean callback_rmdir(SdFile& parentDir, const char *filePathComponent,
322322
boolean isLastComponent, void *object) {
323323
if (isLastComponent) {
324324
SdFile f;
@@ -517,7 +517,7 @@ File SDClass::open(char *filepath, uint8_t mode) {
517517
//}
518518

519519

520-
boolean SDClass::exists(char *filepath) {
520+
boolean SDClass::exists(const char *filepath) {
521521
/*
522522
523523
Returns true if the supplied file path exists.
@@ -538,7 +538,7 @@ boolean SDClass::exists(char *filepath) {
538538
//}
539539

540540

541-
boolean SDClass::mkdir(char *filepath) {
541+
boolean SDClass::mkdir(const char *filepath) {
542542
/*
543543
544544
Makes a single directory or a heirarchy of directories.
@@ -549,7 +549,7 @@ boolean SDClass::mkdir(char *filepath) {
549549
return walkPath(filepath, root, callback_makeDirPath);
550550
}
551551

552-
boolean SDClass::rmdir(char *filepath) {
552+
boolean SDClass::rmdir(const char *filepath) {
553553
/*
554554
555555
Remove a single directory or a heirarchy of directories.
@@ -560,7 +560,7 @@ boolean SDClass::rmdir(char *filepath) {
560560
return walkPath(filepath, root, callback_rmdir);
561561
}
562562

563-
boolean SDClass::remove(char *filepath) {
563+
boolean SDClass::remove(const char *filepath) {
564564
return walkPath(filepath, root, callback_remove);
565565
}
566566

libraries/SD/src/SD.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ class SDClass {
7676
File open(const String &filename, uint8_t mode = FILE_READ) { return open( filename.c_str(), mode ); }
7777

7878
// Methods to determine if the requested file path exists.
79-
boolean exists(char *filepath);
79+
boolean exists(const char *filepath);
8080
boolean exists(const String &filepath) { return exists(filepath.c_str()); }
8181

8282
// Create the requested directory heirarchy--if intermediate directories
8383
// do not exist they will be created.
84-
boolean mkdir(char *filepath);
84+
boolean mkdir(const char *filepath);
8585
boolean mkdir(const String &filepath) { return mkdir(filepath.c_str()); }
8686

8787
// Delete the file.
88-
boolean remove(char *filepath);
88+
boolean remove(const char *filepath);
8989
boolean remove(const String &filepath) { return remove(filepath.c_str()); }
9090

91-
boolean rmdir(char *filepath);
91+
boolean rmdir(const char *filepath);
9292
boolean rmdir(const String &filepath) { return rmdir(filepath.c_str()); }
9393

9494
private:
@@ -101,7 +101,7 @@ class SDClass {
101101
int fileOpenMode;
102102

103103
friend class File;
104-
friend boolean callback_openPath(SdFile&, char *, boolean, void *);
104+
friend boolean callback_openPath(SdFile&, const char *, boolean, void *);
105105
};
106106

107107
extern SDClass SD;

0 commit comments

Comments
 (0)