Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:361360b2f1c5, committed 2015-01-26
- Comitter:
- ollie8
- Date:
- Mon Jan 26 08:28:04 2015 +0000
- Parent:
- 1:1f1e0c92b3f8
- Commit message:
- Fixed bug where rename would always return true.
Changed in this revision
| FileUtils.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1f1e0c92b3f8 -r 361360b2f1c5 FileUtils.h
--- a/FileUtils.h Mon Dec 30 20:40:50 2013 +0000
+++ b/FileUtils.h Mon Jan 26 08:28:04 2015 +0000
@@ -1,6 +1,8 @@
+#define DEBUG
+#include "logger.h"
/** fcopy: Copies a file
- * Checks to insure destination file was created.
+ * Checks to ensure destination file was created.
* Returns -1 = error; 0 = success
*/
int fcopy (const char *src, const char *dst) {
@@ -16,23 +18,27 @@
int retval = 0;
fpdst = fopen(dst, "r");
if (fpdst == NULL) {
- retval = -1;
+ retval = 0;
} else {
fclose(fpdst);
- retval = 0;
+ retval = 1;
}
return retval;
}
/** frename: renames a file (via copy & delete).
* Moves data instead of adjusting the file name in the
- * file directory. Checks to insure the file was renamed.
+ * file directory. Checks to ensure the file was renamed.
* Returns -1 = error; 0 = success
*/
int frename(const char *oldfname, const char *newfname) {
- int retval = 0;
+ int retval = -1;
+ INFO("Renaming");
if (fcopy(oldfname, newfname)) {
+ INFO("Deleting");
remove(oldfname);
+ retval = 0;
}
+ INFO("Done");
return retval;
}
\ No newline at end of file