Skip to content

Commit 0a0aaeb

Browse files
zakkieAkihiro Yamazaki
and
Akihiro Yamazaki
authored
Use bool instead of boolean (#76)
Co-authored-by: Akihiro Yamazaki <[email protected]>
1 parent 17c59d1 commit 0a0aaeb

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

src/File.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ char *File::name(void) {
4949
}
5050

5151
// a directory is a special type of file
52-
boolean File::isDirectory(void) {
52+
bool File::isDirectory(void) {
5353
return (_file && _file->isDir());
5454
}
5555

@@ -123,7 +123,7 @@ void File::flush() {
123123
}
124124
}
125125

126-
boolean File::seek(uint32_t pos) {
126+
bool File::seek(uint32_t pos) {
127127
if (! _file) {
128128
return false;
129129
}

src/SD.cpp

+29-29
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ namespace SDLib {
117117

118118

119119

120-
boolean walkPath(const char *filepath, SdFile& parentDir,
121-
boolean(*callback)(SdFile& parentDir,
122-
const char *filePathComponent,
123-
boolean isLastComponent,
124-
void *object),
125-
void *object = NULL) {
120+
bool walkPath(const char *filepath, SdFile& parentDir,
121+
bool(*callback)(SdFile& parentDir,
122+
const char *filePathComponent,
123+
bool isLastComponent,
124+
void *object),
125+
void *object = NULL) {
126126
/*
127127
128128
When given a file path (and parent directory--normally root),
@@ -170,9 +170,9 @@ namespace SDLib {
170170

171171
while (true) {
172172

173-
boolean moreComponents = getNextPathComponent(filepath, &offset, buffer);
173+
bool moreComponents = getNextPathComponent(filepath, &offset, buffer);
174174

175-
boolean shouldContinue = callback((*p_parent), buffer, !moreComponents, object);
175+
bool shouldContinue = callback((*p_parent), buffer, !moreComponents, object);
176176

177177
if (!shouldContinue) {
178178
// TODO: Don't repeat this code?
@@ -188,7 +188,7 @@ namespace SDLib {
188188
break;
189189
}
190190

191-
boolean exists = (*p_child).open(*p_parent, buffer, O_RDONLY);
191+
bool exists = (*p_child).open(*p_parent, buffer, O_RDONLY);
192192

193193
// If it's one we've created then we
194194
// don't need the parent handle anymore.
@@ -232,8 +232,8 @@ namespace SDLib {
232232
233233
*/
234234

235-
boolean callback_pathExists(SdFile& parentDir, const char *filePathComponent,
236-
boolean /* isLastComponent */, void * /* object */) {
235+
bool callback_pathExists(SdFile& parentDir, const char *filePathComponent,
236+
bool /* isLastComponent */, void * /* object */) {
237237
/*
238238
239239
Callback used to determine if a file/directory exists in parent
@@ -244,7 +244,7 @@ namespace SDLib {
244244
*/
245245
SdFile child;
246246

247-
boolean exists = child.open(parentDir, filePathComponent, O_RDONLY);
247+
bool exists = child.open(parentDir, filePathComponent, O_RDONLY);
248248

249249
if (exists) {
250250
child.close();
@@ -255,8 +255,8 @@ namespace SDLib {
255255

256256

257257

258-
boolean callback_makeDirPath(SdFile& parentDir, const char *filePathComponent,
259-
boolean isLastComponent, void *object) {
258+
bool callback_makeDirPath(SdFile& parentDir, const char *filePathComponent,
259+
bool isLastComponent, void *object) {
260260
/*
261261
262262
Callback used to create a directory in the parent directory if
@@ -265,7 +265,7 @@ namespace SDLib {
265265
Returns true if a directory was created or it already existed.
266266
267267
*/
268-
boolean result = false;
268+
bool result = false;
269269
SdFile child;
270270

271271
result = callback_pathExists(parentDir, filePathComponent, isLastComponent, object);
@@ -279,8 +279,8 @@ namespace SDLib {
279279

280280
/*
281281
282-
boolean callback_openPath(SdFile& parentDir, char *filePathComponent,
283-
boolean isLastComponent, void *object) {
282+
bool callback_openPath(SdFile& parentDir, char *filePathComponent,
283+
bool isLastComponent, void *object) {
284284
285285
Callback used to open a file specified by a filepath that may
286286
specify one or more directories above it.
@@ -310,16 +310,16 @@ namespace SDLib {
310310

311311

312312

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

321-
boolean callback_rmdir(SdFile& parentDir, const char *filePathComponent,
322-
boolean isLastComponent, void * /* object */) {
321+
bool callback_rmdir(SdFile& parentDir, const char *filePathComponent,
322+
bool isLastComponent, void * /* object */) {
323323
if (isLastComponent) {
324324
SdFile f;
325325
if (!f.open(parentDir, filePathComponent, O_READ)) {
@@ -336,7 +336,7 @@ namespace SDLib {
336336

337337

338338

339-
boolean SDClass::begin(uint8_t csPin) {
339+
bool SDClass::begin(uint8_t csPin) {
340340
if (root.isOpen()) {
341341
root.close();
342342
}
@@ -353,7 +353,7 @@ namespace SDLib {
353353
root.openRoot(volume);
354354
}
355355

356-
boolean SDClass::begin(uint32_t clock, uint8_t csPin) {
356+
bool SDClass::begin(uint32_t clock, uint8_t csPin) {
357357
if (root.isOpen()) {
358358
root.close();
359359
}
@@ -523,7 +523,7 @@ namespace SDLib {
523523
*/
524524

525525

526-
//boolean SDClass::close() {
526+
//bool SDClass::close() {
527527
// /*
528528
//
529529
// Closes the file opened by the `open` method.
@@ -533,7 +533,7 @@ namespace SDLib {
533533
//}
534534

535535

536-
boolean SDClass::exists(const char *filepath) {
536+
bool SDClass::exists(const char *filepath) {
537537
/*
538538
539539
Returns true if the supplied file path exists.
@@ -543,7 +543,7 @@ namespace SDLib {
543543
}
544544

545545

546-
//boolean SDClass::exists(char *filepath, SdFile& parentDir) {
546+
//bool SDClass::exists(char *filepath, SdFile& parentDir) {
547547
// /*
548548
//
549549
// Returns true if the supplied file path rooted at `parentDir`
@@ -554,7 +554,7 @@ namespace SDLib {
554554
//}
555555

556556

557-
boolean SDClass::mkdir(const char *filepath) {
557+
bool SDClass::mkdir(const char *filepath) {
558558
/*
559559
560560
Makes a single directory or a hierarchy of directories.
@@ -565,7 +565,7 @@ namespace SDLib {
565565
return walkPath(filepath, root, callback_makeDirPath);
566566
}
567567

568-
boolean SDClass::rmdir(const char *filepath) {
568+
bool SDClass::rmdir(const char *filepath) {
569569
/*
570570
571571
Remove a single directory or a hierarchy of directories.
@@ -576,7 +576,7 @@ namespace SDLib {
576576
return walkPath(filepath, root, callback_rmdir);
577577
}
578578

579-
boolean SDClass::remove(const char *filepath) {
579+
bool SDClass::remove(const char *filepath) {
580580
return walkPath(filepath, root, callback_remove);
581581
}
582582

src/SD.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ namespace SDLib {
4141
virtual int available();
4242
virtual void flush();
4343
int read(void *buf, uint16_t nbyte);
44-
boolean seek(uint32_t pos);
44+
bool seek(uint32_t pos);
4545
uint32_t position();
4646
uint32_t size();
4747
void close();
4848
operator bool();
4949
char * name();
5050

51-
boolean isDirectory(void);
51+
bool isDirectory(void);
5252
File openNextFile(uint8_t mode = O_RDONLY);
5353
void rewindDirectory(void);
5454

@@ -68,8 +68,8 @@ namespace SDLib {
6868
public:
6969
// This needs to be called to set up the connection to the SD card
7070
// before other methods are used.
71-
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
72-
boolean begin(uint32_t clock, uint8_t csPin);
71+
bool begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
72+
bool begin(uint32_t clock, uint8_t csPin);
7373

7474
//call this when a card is removed. It will allow you to insert and initialise a new card.
7575
void end();
@@ -83,26 +83,26 @@ namespace SDLib {
8383
}
8484

8585
// Methods to determine if the requested file path exists.
86-
boolean exists(const char *filepath);
87-
boolean exists(const String &filepath) {
86+
bool exists(const char *filepath);
87+
bool exists(const String &filepath) {
8888
return exists(filepath.c_str());
8989
}
9090

9191
// Create the requested directory heirarchy--if intermediate directories
9292
// do not exist they will be created.
93-
boolean mkdir(const char *filepath);
94-
boolean mkdir(const String &filepath) {
93+
bool mkdir(const char *filepath);
94+
bool mkdir(const String &filepath) {
9595
return mkdir(filepath.c_str());
9696
}
9797

9898
// Delete the file.
99-
boolean remove(const char *filepath);
100-
boolean remove(const String &filepath) {
99+
bool remove(const char *filepath);
100+
bool remove(const String &filepath) {
101101
return remove(filepath.c_str());
102102
}
103103

104-
boolean rmdir(const char *filepath);
105-
boolean rmdir(const String &filepath) {
104+
bool rmdir(const char *filepath);
105+
bool rmdir(const String &filepath) {
106106
return rmdir(filepath.c_str());
107107
}
108108

@@ -116,7 +116,7 @@ namespace SDLib {
116116
int fileOpenMode;
117117

118118
friend class File;
119-
friend boolean callback_openPath(SdFile&, const char *, boolean, void *);
119+
friend bool callback_openPath(SdFile&, const char *, bool, void *);
120120
};
121121

122122
extern SDClass SD;

0 commit comments

Comments
 (0)