Fixed incorrect messages about temp files not being deleted.

This commit is contained in:
David Williams 2014-09-20 17:17:18 +02:00
parent 4779f91787
commit 880dcd8645
4 changed files with 13 additions and 6 deletions

View File

@ -50,7 +50,7 @@ const int32_t g_uVolumeSideLength = 128;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FilePager<MaterialDensityPair88>* pager = new FilePager<MaterialDensityPair88>("./"); FilePager<MaterialDensityPair88>* pager = new FilePager<MaterialDensityPair88>(".");
LargeVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)), pager); LargeVolume<MaterialDensityPair88> 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. //Make our volume contain a sphere in the center.

View File

@ -46,10 +46,17 @@ namespace PolyVox
{ {
public: public:
/// Constructor /// Constructor
FilePager(const std::string& strFolderName) FilePager(const std::string& strFolderName = ".")
:Pager<VoxelType>() :Pager<VoxelType>()
,m_strFolderName(strFolderName) ,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<unsigned int>(time(0))); srand(static_cast<unsigned int>(time(0)));
int iRandomValue = rand(); int iRandomValue = rand();
@ -63,7 +70,7 @@ namespace PolyVox
{ {
for(std::vector<std::string>::iterator iter = m_vecCreatedFiles.begin(); iter < m_vecCreatedFiles.end(); iter++) for(std::vector<std::string>::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(); m_vecCreatedFiles.clear();

View File

@ -102,7 +102,7 @@ VolumeType* createAndFillVolume(void)
{ {
const int32_t uVolumeSideLength = 64; const int32_t uVolumeSideLength = 64;
FilePager<VolumeType::VoxelType>* pager = new FilePager<VolumeType::VoxelType>("./"); FilePager<VolumeType::VoxelType>* pager = new FilePager<VolumeType::VoxelType>(".");
//Create empty volume //Create empty volume
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)), pager); 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 <typename VolumeType> template <typename VolumeType>
VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minValue, float maxValue) VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minValue, float maxValue)
{ {
FilePager<float>* pager = new FilePager<float>("./"); FilePager<float>* pager = new FilePager<float>(".");
//Create empty volume //Create empty volume
VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)), pager); VolumeType* volData = new VolumeType(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(iVolumeSideLength - 1, iVolumeSideLength - 1, iVolumeSideLength - 1)), pager);

View File

@ -269,7 +269,7 @@ TestVolume::TestVolume()
{ {
Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size
m_pFilePager = new FilePager<int32_t>("./"); m_pFilePager = new FilePager<int32_t>(".");
//Create the volumes //Create the volumes
m_pRawVolume = new RawVolume<int32_t>(region); m_pRawVolume = new RawVolume<int32_t>(region);