From: Leonardo Florez-Valencia Date: Fri, 22 Jan 2016 04:10:12 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~261 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=35d769c683c10f5c18d17a3e423d89f5b30a5b77;p=cpPlugins.git ... --- diff --git a/lib/cpPlugins/Interface/Interface.cxx b/lib/cpPlugins/Interface/Interface.cxx index 2b5711b..4576f84 100644 --- a/lib/cpPlugins/Interface/Interface.cxx +++ b/lib/cpPlugins/Interface/Interface.cxx @@ -34,6 +34,19 @@ namespace cpPlugins } // ecapseman +// ------------------------------------------------------------------------- +std::string cpPlugins_Interface_CanonicalPath( const std::string& path ) +{ +#ifdef _WIN32 + TCHAR buffer[ 4096 ] = TEXT( "" ); + TCHAR** lppPart = { NULL }; + GetFullPathName( path.c_str( ), 4096, buffer, lppPart ); + return( std::string( buffer ) ); +#else // Linux like + return( std::string( realpath( path.c_str( ), NULL ) ) ); +#endif // _WIN32 +} + // ------------------------------------------------------------------------- cpPlugins::Interface::Interface:: Interface( ) @@ -197,22 +210,8 @@ Load( const std::string& folder, const std::string& name ) PathSeparator sep; if( sep( folder[ folder.size( ) - 1 ] ) ) real_folder = folder.substr( 0, folder.size( ) - 1 ); -#ifdef _WIN32 - DWORD retval=0; - BOOL success; - TCHAR buffer[4096]=TEXT(""); - TCHAR buf[4096]=TEXT(""); - TCHAR** lppPart={NULL}; - // Retrieve the full path name for a file. - // The file does not need to exist. - retval = GetFullPathName(folder.c_str( ), - 4096, - buffer, - lppPart); - real_folder = buffer; -#else // _WIN32 - real_folder = std::string( realpath( real_folder.c_str( ), NULL ) ); -#endif // _WIN32 + real_folder = cpPlugins_Interface_CanonicalPath( real_folder ); + bool ret = true; try { @@ -347,23 +346,7 @@ _SepFName( const std::string& path, std::string& folder, std::string& name ) PathSeparator sep; // Get absolute path - std::string real_path = ""; -#ifdef _WIN32 - DWORD retval=0; - BOOL success; - TCHAR buffer[4096]=TEXT(""); - TCHAR buf[4096]=TEXT(""); - TCHAR** lppPart={NULL}; - // Retrieve the full path name for a file. - // The file does not need to exist. - retval = GetFullPathName(path.c_str( ), - 4096, - buffer, - lppPart); - real_path = buffer; -#else // _WIN32 - real_path = std::string( realpath( path.c_str( ), NULL ) ); -#endif // _WIN32 + std::string real_path = cpPlugins_Interface_CanonicalPath( path ); // Get name name = std::string(