]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/filetypes.cpp
Implement buffer operations
[xonotic/netradiant.git] / radiant / filetypes.cpp
index 87cb205c15b4afd6fc7519b3458b08d380f717d7..9da5537f3131c5273a4221e13f97334ace01c04c 100644 (file)
 #include "os/path.h"
 #include <vector>
 #include <map>
+#include <util/buffer.h>
 
 class RadiantFileTypeRegistry : public IFileTypeRegistry
 {
 struct filetype_copy_t
 {
        filetype_copy_t( const char* moduleName, const filetype_t other )
-               : m_moduleName( moduleName ), m_name( other.name ), m_pattern( other.pattern ), m_can_load( other.can_load ), m_can_import( other.can_import ), m_can_save( other.can_save ){
+               : m_can_load( other.can_load ), m_can_import( other.can_import ), m_can_save( other.can_save ), m_moduleName( moduleName ), m_name( other.name ), m_pattern( other.pattern ) {
        }
        const char* getModuleName() const {
                return m_moduleName.c_str();
@@ -87,15 +88,15 @@ IFileTypeRegistry* GetFileTypeRegistry(){
 const char* findModuleName( IFileTypeRegistry* registry, const char* moduleType, const char* extension ){
        class SearchFileTypeList : public IFileTypeList
        {
-       char m_pattern[128];
+       u::BufferVal<128> m_pattern;
        const char* m_moduleName;
 public:
        SearchFileTypeList( const char* ext )
                : m_moduleName( "" ){
-               m_pattern[0] = '*';
-               m_pattern[1] = '.';
-               strncpy( m_pattern + 2, ext, 125 );
-               m_pattern[127] = '\0';
+               m_pattern.mut()[0] = '*';
+               m_pattern.mut()[1] = '.';
+               m_pattern.copy(ext, 2);
+               m_pattern.terminate();
        }
        void addType( const char* moduleName, filetype_t type ){
                if ( extension_equal( m_pattern, type.pattern ) ) {