From 880dcd8645f21eb9638c74bfc0ffceb01c5a50ba Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 20 Sep 2014 17:17:18 +0200 Subject: [PATCH] Fixed incorrect messages about temp files not being deleted. --- examples/OpenGL/main.cpp | 2 +- library/PolyVoxCore/include/PolyVoxCore/FilePager.h | 11 +++++++++-- tests/TestSurfaceExtractor.cpp | 4 ++-- tests/testvolume.cpp | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 1c51f511..9a36fac8 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -50,7 +50,7 @@ const int32_t g_uVolumeSideLength = 128; int main(int argc, char *argv[]) { - FilePager* pager = new FilePager("./"); + FilePager* pager = new FilePager("."); LargeVolume volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)), pager); //Make our volume contain a sphere in the center. diff --git a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h index 8e3e36ed..6f466204 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h @@ -46,10 +46,17 @@ namespace PolyVox { public: /// Constructor - FilePager(const std::string& strFolderName) + FilePager(const std::string& strFolderName = ".") :Pager() ,m_strFolderName(strFolderName) { + // Add the trailing slash, assuming the user dind't already do it. + if ((m_strFolderName.back() != '/') && (m_strFolderName.back() != '\\')) + { + m_strFolderName.append("/"); + } + + // Build a unique prefix to avoid multiple pagers using the same filenames. srand(static_cast(time(0))); int iRandomValue = rand(); @@ -63,7 +70,7 @@ namespace PolyVox { for(std::vector::iterator iter = m_vecCreatedFiles.begin(); iter < m_vecCreatedFiles.end(); iter++) { - POLYVOX_LOG_WARNING_IF(!std::remove(iter->c_str()), "Failed to delete '" << *iter << "' when destroying FilePager"); + POLYVOX_LOG_WARNING_IF(std::remove(iter->c_str()) != 0, "Failed to delete '" << *iter << "' when destroying FilePager"); } m_vecCreatedFiles.clear(); diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index fc7f92ba..599281bb 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -102,7 +102,7 @@ VolumeType* createAndFillVolume(void) { const int32_t uVolumeSideLength = 64; - FilePager* pager = new FilePager("./"); + FilePager* pager = new FilePager("."); //Create empty volume VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)), pager); @@ -139,7 +139,7 @@ float randomFloat(float a, float b) template VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minValue, float maxValue) { - FilePager* pager = new FilePager("./"); + FilePager* pager = new FilePager("."); //Create empty volume VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)), pager); diff --git a/tests/testvolume.cpp b/tests/testvolume.cpp index 4007c6ed..a8f8202b 100644 --- a/tests/testvolume.cpp +++ b/tests/testvolume.cpp @@ -269,7 +269,7 @@ TestVolume::TestVolume() { Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size - m_pFilePager = new FilePager("./"); + m_pFilePager = new FilePager("."); //Create the volumes m_pRawVolume = new RawVolume(region);