00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00023 #ifndef __vtkKWFileBrowserUtilities_h
00024 #define __vtkKWFileBrowserUtilities_h
00025
00026 #include <vtksys/SystemTools.hxx>
00027 #include <vtksys/stl/string>
00028
00029 #ifdef _WIN32
00030 #define KWFileBrowser_PATH_SEPARATOR "\\"
00031 #else
00032 #define KWFileBrowser_PATH_SEPARATOR "/"
00033 #endif
00034
00035 #define KWFileBrowser_UNIX_ROOT_DIRECTORY "/"
00036 #define KWFileBrowser_ESCAPE_CHARS "{}[]$\"\\"
00037 #define VTK_KW_FAVORITE_TOPLEVEL "KWFileBrowserFavorites"
00038
00039 static char* KWFileBrowser_GetUnixPath(const char* path)
00040 {
00041 if(path && *path)
00042 {
00043 vtksys_stl::string sBuffer = path;
00044 vtksys::SystemTools::ConvertToUnixSlashes(sBuffer);
00045 static char buffer[512];
00046 strcpy(buffer, sBuffer.c_str());
00047 return buffer;
00048 }
00049 return NULL;
00050 };
00051
00052 static int KWFileBrowser_HasTrailingSlash(const char *dir)
00053 {
00054 size_t dir_len = strlen(dir);
00055 int has_slash =
00056 (dir_len && (dir[dir_len - 1] == '/' || dir[dir_len - 1] == '\\'));
00057
00058 return has_slash;
00059 };
00060
00061 static bool KWFileBrowser_ComparePath(const char *dir1, const char* dir2)
00062 {
00063 if(!dir1 || !dir2)
00064 {
00065 return false;
00066 }
00067 vtksys_stl::string path1 = dir1;
00068 vtksys_stl::string path2 = dir2;
00069 int dirslash1 = KWFileBrowser_HasTrailingSlash(dir1);
00070 int dirslash2 = KWFileBrowser_HasTrailingSlash(dir2);
00071 if(!dirslash1 && dirslash2)
00072 {
00073 path1 += "/";
00074 }
00075 else if(dirslash1 && !dirslash2)
00076 {
00077 path2 += "/";
00078 }
00079 vtksys::SystemTools::ConvertToUnixSlashes(path1);
00080 vtksys::SystemTools::ConvertToUnixSlashes(path2);
00081 return vtksys::SystemTools::ComparePath(path1.c_str(), path2.c_str());
00082 };
00083
00084 #endif