diff options
author | Damien Plisson <damien.plisson@yahoo.fr> | 2010-02-27 20:03:46 +0300 |
---|---|---|
committer | Damien Plisson <damien.plisson@yahoo.fr> | 2010-02-27 20:03:46 +0300 |
commit | fa6beb43028b26424cf8aa0712f8f1a9ed8360a4 (patch) | |
tree | d679adfa82b10555d9cb8598945a3dce972ebcbb /intern | |
parent | a9e3e0e40f17fca00eeb5b3af9af20b6fcf5ada5 (diff) |
System dependent standard directory retrieval functions update : return const strings (as coded in libc) instead of malloc'ed buffers
and plug them into wip BLI_bfile.c to replace the hardcoded paths
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 4 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCarbon.cpp | 17 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCarbon.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 14 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCarbon.cpp | 4 |
13 files changed, 36 insertions, 39 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 75a055075bc..346fa292520 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -824,14 +824,14 @@ extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection); * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ -extern GHOST_TUns8* GHOST_getSystemDir(); +extern const GHOST_TUns8* GHOST_getSystemDir(); /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ -extern GHOST_TUns8* GHOST_getUserDir(); +extern const GHOST_TUns8* GHOST_getUserDir(); #ifdef __cplusplus diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 5e0c7f41ab8..fd8641f2055 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -380,14 +380,14 @@ public: * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ - virtual GHOST_TUns8* getSystemDir() const = 0; + virtual const GHOST_TUns8* getSystemDir() const = 0; /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ - virtual GHOST_TUns8* getUserDir() const = 0; + virtual const GHOST_TUns8* getUserDir() const = 0; protected: /** diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index fd06d7620ab..51305e82064 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -855,13 +855,13 @@ void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection) system->putClipboard(buffer, selection); } -GHOST_TUns8* GHOST_getSystemDir() +const GHOST_TUns8* GHOST_getSystemDir() { GHOST_ISystem* system = GHOST_ISystem::getSystem(); return system->getSystemDir(); } -GHOST_TUns8* GHOST_getUserDir() +const GHOST_TUns8* GHOST_getUserDir() { GHOST_ISystem* system = GHOST_ISystem::getSystem(); return system->getUserDir(); diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 59f933ea865..d6c6a356323 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -302,14 +302,14 @@ public: * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ - virtual GHOST_TUns8* getSystemDir() const = 0; + virtual const GHOST_TUns8* getSystemDir() const = 0; /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ - virtual GHOST_TUns8* getUserDir() const = 0; + virtual const GHOST_TUns8* getUserDir() const = 0; protected: /** diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index 52b797f56b5..36ea1c7fe85 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -809,7 +809,7 @@ OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event) } err = noErr; } - + return err; } OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event) @@ -1215,22 +1215,19 @@ void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const } } -GHOST_TUns8* GHOST_SystemCarbon::getSystemDir() const +const GHOST_TUns8* GHOST_SystemCarbon::getSystemDir() const { - static GHOST_TUns8 sysPath[64]; - - strcpy((char*)sysPath,"/Library/Application Support/Blender"); - - return sysPath; + return (GHOST_TUns8*)"/Library/Application Support/Blender"; } -GHOST_TUns8* GHOST_SystemCarbon::getUserDir() const +const GHOST_TUns8* GHOST_SystemCarbon::getUserDir() const { - static char usrPath[512] = ""; + static char usrPath[256] = ""; char* env = getenv("HOME"); if (env) { - strcpy(usrPath, env); + strncpy(usrPath, env, 245); + usrPath[245]=0; strcat(usrPath, "/Library/Application Support/Blender"); return (GHOST_TUns8*) usrPath; } diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h index b27d7917377..7f0870674b4 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.h +++ b/intern/ghost/intern/GHOST_SystemCarbon.h @@ -195,14 +195,14 @@ public: * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ - virtual GHOST_TUns8* getSystemDir() const; + virtual const GHOST_TUns8* getSystemDir() const; /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ - virtual GHOST_TUns8* getUserDir() const; + virtual const GHOST_TUns8* getUserDir() const; protected: /** diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 2f1a94fc8eb..b25f8890cf1 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -218,14 +218,14 @@ public: * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ - virtual GHOST_TUns8* getSystemDir() const; + virtual const GHOST_TUns8* getSystemDir() const; /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ - virtual GHOST_TUns8* getUserDir() const; + virtual const GHOST_TUns8* getUserDir() const; /** * Handles a window event. Called by GHOST_WindowCocoa window delegate diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 15ea3730c6e..5289920cccb 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1714,7 +1714,7 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const #pragma mark Base directories retrieval -GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const +const GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const { static GHOST_TUns8 tempPath[512] = ""; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -1742,7 +1742,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const return tempPath; } -GHOST_TUns8* GHOST_SystemCocoa::getUserDir() const +const GHOST_TUns8* GHOST_SystemCocoa::getUserDir() const { static GHOST_TUns8 tempPath[512] = ""; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 0cbd3e99c73..b1c5ee6e6f2 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1095,12 +1095,12 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const } } -GHOST_TUns8* GHOST_SystemWin32::getSystemDir() const +const GHOST_TUns8* GHOST_SystemWin32::getSystemDir() const { return NULL; } -GHOST_TUns8* GHOST_SystemWin32::getUserDir() const +const GHOST_TUns8* GHOST_SystemWin32::getUserDir() const { return NULL; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 1b7b2aad766..75bb858fb49 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -193,14 +193,14 @@ public: * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ - GHOST_TUns8* getSystemDir() const; + virtual const GHOST_TUns8* getSystemDir() const; /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ - GHOST_TUns8* getUserDir() const; + virtual const GHOST_TUns8* getUserDir() const; /** * Creates a drag'n'drop event and pushes it immediately onto the event queue. diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 5eab71eebf5..cbf775045fd 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -1458,19 +1458,19 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const } } -GHOST_TUns8* GHOST_SystemX11::getSystemDir() const +const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const { - + return (GHOST_TUns8*)"/usr/share/blender"; } -GHOST_TUns8* GHOST_SystemX11::getUserDir() const +const GHOST_TUns8* GHOST_SystemX11::getUserDir() const { - char* path; + static char path[256]; char* env = getenv("HOME"); if(env) { - path = (char*) malloc(strlen(env) + 10); // "/.blender/" - strcat(path, env); - strcat(path, "/,blender/"); + strncpy(path, env, 245); + path[245]=0; + strcat(path, "/.blender/"); return (GHOST_TUns8*) path; } else { return NULL; diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index b839b5a057a..1d9959cc931 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -231,14 +231,14 @@ public: * "unpack and run" path, then look for properly installed path, not including versioning. * @return Unsigned char string pointing to system dir (eg /usr/share/blender/). */ - GHOST_TUns8* getSystemDir() const; + const GHOST_TUns8* getSystemDir() const; /** * Determine the base dir in which user configuration is stored, not including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). */ - GHOST_TUns8* getUserDir() const; + const GHOST_TUns8* getUserDir() const; /** * Atom used for ICCCM, WM-spec and Motif. diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp index ab06df8a746..65584e4cc1f 100644 --- a/intern/ghost/intern/GHOST_WindowCarbon.cpp +++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp @@ -136,14 +136,14 @@ GHOST_WindowCarbon::GHOST_WindowCarbon( &m_windowRef); if ( err != noErr) { - fprintf(stderr," error creating window %i \n",err); + fprintf(stderr," error creating window %i \n",(int)err); } else { ::SetWRefCon(m_windowRef,(SInt32)this); setTitle(title); err = InstallWindowEventHandler (m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents,NULL,NULL); if ( err != noErr) { - fprintf(stderr," error creating handler %i \n",err); + fprintf(stderr," error creating handler %i \n",(int)err); } else { // ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL); ::ShowWindow(m_windowRef); |