cResult delfile(Poco::Path fullpath) { drunner_assert(fullpath.isFile(), "delfile: asked to delete a directory: "+fullpath.toString()); #ifdef _WIN32 SetFileAttributesA(fullpath.toString().c_str(), GetFileAttributesA(fullpath.toString().c_str()) & ~FILE_ATTRIBUTE_READONLY); if (0 == DeleteFileA(fullpath.toString().c_str())) { if (GetLastError() == ERROR_ACCESS_DENIED) fatal("Couldn't delete - read only"); if (GetLastError() == ERROR_FILE_NOT_FOUND) fatal("File not found - "+std::to_string(GetLastError())); if (GetLastError() == ERROR_SHARING_VIOLATION) fatal("Sharing violation"); fatal("?!" + std::to_string(GetLastError())); } #else try { Poco::File f(fullpath); if (f.exists()) { f.setWriteable(true); f.remove(); } } catch (const Poco::Exception & e) { return cError("Couldn't delete "+fullpath.toString()+" - "+e.what()); } #endif logmsg(kLDEBUG, "Deleted " + fullpath.toString()); return kRSuccess; }