From 7821968342bc6d098cf2e0c5358ab64ee411599d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jun 2011 18:12:55 +0000 Subject: [PATCH] Added wider file extension support to ExternalFileWriter::generateObjectName --- src/osgDB/ExternalFileWriter.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/osgDB/ExternalFileWriter.cpp b/src/osgDB/ExternalFileWriter.cpp index fab33b103..c269f29ca 100644 --- a/src/osgDB/ExternalFileWriter.cpp +++ b/src/osgDB/ExternalFileWriter.cpp @@ -27,7 +27,7 @@ namespace osgDB /// - "../../a/b/c/d/e" goes 2 /// - "../a/../b/../.." goes 2 /// - "a/b/../c" goes 0 -unsigned int countNbDirsUp(const std::string & path) +static unsigned int countNbDirsUp(const std::string & path) { // Algorithm: // - For each path component, count +1 for "..", 0 for ".", and -1 for anything else @@ -53,7 +53,7 @@ unsigned int countNbDirsUp(const std::string & path) /// Local hash function for a path. /// Does not canonize the given path, but is not confused with mixed separators. -unsigned int pathHash(const std::string & s) +static unsigned int pathHash(const std::string & s) { // This is based on the DJB hash algorithm // Note: SDBM Hash initializes at 0 and is @@ -86,7 +86,7 @@ enum WriteType { }; /// Default prefixes for unnamed objects. -const char * const PREFIX[/*MAX_WRITE_TYPE*/] = { +static const char * const FILE_PREFIX[/*MAX_WRITE_TYPE*/] = { "Object_", "Image_", "HF_", @@ -94,6 +94,14 @@ const char * const PREFIX[/*MAX_WRITE_TYPE*/] = { "Shader_" }; +/// Default prefixes for unnamed objects. +static const char * const FILE_EXTENSION[/*MAX_WRITE_TYPE*/] = { + ".osgb", + ".tga", + ".osgb", + ".osgb", + ".glsl" +}; //.frag //.vert @@ -237,12 +245,10 @@ bool ExternalFileWriter::absoluteObjectPathExists(const std::string & path) void ExternalFileWriter::generateObjectName(std::string & out_relativePath, std::string & out_absolutePath, int type) { static const ObjectIndex MAX_NUMBER = UINT_MAX-1; // -1 to allow doing +1 without an overflow - static const char * const IMAGE_EXT = ".tga"; // Default extension (PNG would be preferable since widely used, but it requires libpng) - static const char * const SHADER_EXT = ".frag"; // Default extension for (ObjectIndex number=_lastGeneratedObjectIndex+1; number