diff --git a/src/File.cpp b/src/File.cpp index 5e37166..3e27fb4 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -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()); } @@ -123,7 +123,7 @@ void File::flush() { } } -boolean File::seek(uint32_t pos) { +bool File::seek(uint32_t pos) { if (! _file) { return false; } diff --git a/src/SD.cpp b/src/SD.cpp index 8c9a29e..24fcb2e 100644 --- a/src/SD.cpp +++ b/src/SD.cpp @@ -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), @@ -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? @@ -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. @@ -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 @@ -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(); @@ -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 @@ -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); @@ -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. @@ -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)) { @@ -336,7 +336,7 @@ namespace SDLib { - boolean SDClass::begin(uint8_t csPin) { + bool SDClass::begin(uint8_t csPin) { if (root.isOpen()) { root.close(); } @@ -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(); } @@ -523,7 +523,7 @@ namespace SDLib { */ - //boolean SDClass::close() { + //bool SDClass::close() { // /* // // Closes the file opened by the `open` method. @@ -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. @@ -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` @@ -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. @@ -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. @@ -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); } diff --git a/src/SD.h b/src/SD.h index fa34ccd..c81a7d3 100644 --- a/src/SD.h +++ b/src/SD.h @@ -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); @@ -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(); @@ -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()); } @@ -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;