Skip to content

Commit

Permalink
Use bool instead of boolean (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Akihiro Yamazaki <[email protected]>
  • Loading branch information
zakkie and Akihiro Yamazaki authored Mar 18, 2020
1 parent 17c59d1 commit 0a0aaeb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ char *File::name(void) {
}

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

Expand Down Expand Up @@ -123,7 +123,7 @@ void File::flush() {
}
}

boolean File::seek(uint32_t pos) {
bool File::seek(uint32_t pos) {
if (! _file) {
return false;
}
Expand Down
58 changes: 29 additions & 29 deletions src/SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ namespace SDLib {



boolean walkPath(const char *filepath, SdFile& parentDir,
boolean(*callback)(SdFile& parentDir,
const char *filePathComponent,
boolean isLastComponent,
void *object),
void *object = NULL) {
bool walkPath(const char *filepath, SdFile& parentDir,
bool(*callback)(SdFile& parentDir,
const char *filePathComponent,
bool isLastComponent,
void *object),
void *object = NULL) {
/*
When given a file path (and parent directory--normally root),
Expand Down Expand Up @@ -170,9 +170,9 @@ namespace SDLib {

while (true) {

boolean moreComponents = getNextPathComponent(filepath, &offset, buffer);
bool moreComponents = getNextPathComponent(filepath, &offset, buffer);

boolean shouldContinue = callback((*p_parent), buffer, !moreComponents, object);
bool shouldContinue = callback((*p_parent), buffer, !moreComponents, object);

if (!shouldContinue) {
// TODO: Don't repeat this code?
Expand All @@ -188,7 +188,7 @@ namespace SDLib {
break;
}

boolean exists = (*p_child).open(*p_parent, buffer, O_RDONLY);
bool exists = (*p_child).open(*p_parent, buffer, O_RDONLY);

// If it's one we've created then we
// don't need the parent handle anymore.
Expand Down Expand Up @@ -232,8 +232,8 @@ namespace SDLib {
*/

boolean callback_pathExists(SdFile& parentDir, const char *filePathComponent,
boolean /* isLastComponent */, void * /* object */) {
bool callback_pathExists(SdFile& parentDir, const char *filePathComponent,
bool /* isLastComponent */, void * /* object */) {
/*
Callback used to determine if a file/directory exists in parent
Expand All @@ -244,7 +244,7 @@ namespace SDLib {
*/
SdFile child;

boolean exists = child.open(parentDir, filePathComponent, O_RDONLY);
bool exists = child.open(parentDir, filePathComponent, O_RDONLY);

if (exists) {
child.close();
Expand All @@ -255,8 +255,8 @@ namespace SDLib {



boolean callback_makeDirPath(SdFile& parentDir, const char *filePathComponent,
boolean isLastComponent, void *object) {
bool callback_makeDirPath(SdFile& parentDir, const char *filePathComponent,
bool isLastComponent, void *object) {
/*
Callback used to create a directory in the parent directory if
Expand All @@ -265,7 +265,7 @@ namespace SDLib {
Returns true if a directory was created or it already existed.
*/
boolean result = false;
bool result = false;
SdFile child;

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

/*
boolean callback_openPath(SdFile& parentDir, char *filePathComponent,
boolean isLastComponent, void *object) {
bool callback_openPath(SdFile& parentDir, char *filePathComponent,
bool isLastComponent, void *object) {
Callback used to open a file specified by a filepath that may
specify one or more directories above it.
Expand Down Expand Up @@ -310,16 +310,16 @@ namespace SDLib {



boolean callback_remove(SdFile& parentDir, const char *filePathComponent,
boolean isLastComponent, void * /* object */) {
bool callback_remove(SdFile& parentDir, const char *filePathComponent,
bool isLastComponent, void * /* object */) {
if (isLastComponent) {
return SdFile::remove(parentDir, filePathComponent);
}
return true;
}

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



boolean SDClass::begin(uint8_t csPin) {
bool SDClass::begin(uint8_t csPin) {
if (root.isOpen()) {
root.close();
}
Expand All @@ -353,7 +353,7 @@ namespace SDLib {
root.openRoot(volume);
}

boolean SDClass::begin(uint32_t clock, uint8_t csPin) {
bool SDClass::begin(uint32_t clock, uint8_t csPin) {
if (root.isOpen()) {
root.close();
}
Expand Down Expand Up @@ -523,7 +523,7 @@ namespace SDLib {
*/


//boolean SDClass::close() {
//bool SDClass::close() {
// /*
//
// Closes the file opened by the `open` method.
Expand All @@ -533,7 +533,7 @@ namespace SDLib {
//}


boolean SDClass::exists(const char *filepath) {
bool SDClass::exists(const char *filepath) {
/*
Returns true if the supplied file path exists.
Expand All @@ -543,7 +543,7 @@ namespace SDLib {
}


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


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

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

boolean SDClass::remove(const char *filepath) {
bool SDClass::remove(const char *filepath) {
return walkPath(filepath, root, callback_remove);
}

Expand Down
26 changes: 13 additions & 13 deletions src/SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ namespace SDLib {
virtual int available();
virtual void flush();
int read(void *buf, uint16_t nbyte);
boolean seek(uint32_t pos);
bool seek(uint32_t pos);
uint32_t position();
uint32_t size();
void close();
operator bool();
char * name();

boolean isDirectory(void);
bool isDirectory(void);
File openNextFile(uint8_t mode = O_RDONLY);
void rewindDirectory(void);

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

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

// Methods to determine if the requested file path exists.
boolean exists(const char *filepath);
boolean exists(const String &filepath) {
bool exists(const char *filepath);
bool exists(const String &filepath) {
return exists(filepath.c_str());
}

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

// Delete the file.
boolean remove(const char *filepath);
boolean remove(const String &filepath) {
bool remove(const char *filepath);
bool remove(const String &filepath) {
return remove(filepath.c_str());
}

boolean rmdir(const char *filepath);
boolean rmdir(const String &filepath) {
bool rmdir(const char *filepath);
bool rmdir(const String &filepath) {
return rmdir(filepath.c_str());
}

Expand All @@ -116,7 +116,7 @@ namespace SDLib {
int fileOpenMode;

friend class File;
friend boolean callback_openPath(SdFile&, const char *, boolean, void *);
friend bool callback_openPath(SdFile&, const char *, bool, void *);
};

extern SDClass SD;
Expand Down

0 comments on commit 0a0aaeb

Please sign in to comment.