Author: marvin
Date: Tue Aug 21 23:24:42 2012
New Revision: 1375850
URL: http://svn.apache.org/viewvc?rev=1375850&view=rev
Log:
Have OS_remove() return true on success, false on failure.
Modified:
lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.h
Modified: lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c?rev=1375850&r1=1375849&r2=1375850&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c Tue Aug 21
23:24:42 2012
@@ -79,7 +79,7 @@ OS_dev_null(void) {
return dev_null;
}
-void
+int
OS_remove(const char *name) {
/*
* On Windows it can happen that another process, typically a
@@ -88,6 +88,7 @@ OS_remove(const char *name) {
* fail. As a workaround, files are renamed to a random name
* before deletion.
*/
+ int retval;
static const size_t num_random_chars = 16;
@@ -102,14 +103,15 @@ OS_remove(const char *name) {
temp_name[name_len+num_random_chars] = '\0';
if (rename(name, temp_name) == 0) {
- remove(temp_name);
+ retval = !remove(temp_name);
}
else {
// Error during rename, remove using old name.
- remove(name);
+ retval = !remove(name);
}
free(temp_name);
+ return retval;
}
void
Modified: lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.h
URL:
http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.h?rev=1375850&r1=1375849&r2=1375850&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.h (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.h Tue Aug 21
23:24:42 2012
@@ -26,8 +26,9 @@ extern "C" {
#endif
/* Safely remove a file named [name]. Needed because of Windows quirks.
+ * Returns true on success, false on failure.
*/
-void
+int
chaz_OS_remove(const char *name);
/* Remove an executable file named [name], appending the exe_ext if needed.