-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 75205d6..500426b 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -897,192 +897,195 @@ int KStandardDirs::findAllExe( QStringList& list, const QString& appname, | |||
897 | QStringList tokens; | 897 | QStringList tokens; |
898 | 898 | ||
899 | if( p.isNull() ) { | 899 | if( p.isNull() ) { |
900 | p = getenv( "PATH" ); | 900 | p = getenv( "PATH" ); |
901 | } | 901 | } |
902 | 902 | ||
903 | list.clear(); | 903 | list.clear(); |
904 | tokenize( tokens, p, ":\b" ); | 904 | tokenize( tokens, p, ":\b" ); |
905 | 905 | ||
906 | for ( unsigned i = 0; i < tokens.count(); i++ ) { | 906 | for ( unsigned i = 0; i < tokens.count(); i++ ) { |
907 | p = tokens[ i ]; | 907 | p = tokens[ i ]; |
908 | p += "/"; | 908 | p += "/"; |
909 | p += appname; | 909 | p += appname; |
910 | 910 | ||
911 | info.setFile( p ); | 911 | info.setFile( p ); |
912 | 912 | ||
913 | if( info.exists() && (ignore || info.isExecutable()) | 913 | if( info.exists() && (ignore || info.isExecutable()) |
914 | && info.isFile() ) { | 914 | && info.isFile() ) { |
915 | list.append( p ); | 915 | list.append( p ); |
916 | } | 916 | } |
917 | 917 | ||
918 | } | 918 | } |
919 | 919 | ||
920 | return list.count(); | 920 | return list.count(); |
921 | } | 921 | } |
922 | */ | 922 | */ |
923 | 923 | ||
924 | static int tokenize( QStringList& tokens, const QString& str, | 924 | static int tokenize( QStringList& tokens, const QString& str, |
925 | const QString& delim ) | 925 | const QString& delim ) |
926 | { | 926 | { |
927 | int len = str.length(); | 927 | int len = str.length(); |
928 | QString token = ""; | 928 | QString token = ""; |
929 | 929 | ||
930 | for( int index = 0; index < len; index++) | 930 | for( int index = 0; index < len; index++) |
931 | { | 931 | { |
932 | if ( delim.find( str[ index ] ) >= 0 ) | 932 | if ( delim.find( str[ index ] ) >= 0 ) |
933 | { | 933 | { |
934 | tokens.append( token ); | 934 | tokens.append( token ); |
935 | token = ""; | 935 | token = ""; |
936 | } | 936 | } |
937 | else | 937 | else |
938 | { | 938 | { |
939 | token += str[ index ]; | 939 | token += str[ index ]; |
940 | } | 940 | } |
941 | } | 941 | } |
942 | if ( token.length() > 0 ) | 942 | if ( token.length() > 0 ) |
943 | { | 943 | { |
944 | tokens.append( token ); | 944 | tokens.append( token ); |
945 | } | 945 | } |
946 | 946 | ||
947 | return tokens.count(); | 947 | return tokens.count(); |
948 | } | 948 | } |
949 | 949 | ||
950 | QString KStandardDirs::kde_default(const char *type) { | 950 | QString KStandardDirs::kde_default(const char *type) { |
951 | if (!strcmp(type, "data")) | 951 | if (!strcmp(type, "data")) |
952 | return "apps/"; | 952 | return "apps/"; |
953 | if (!strcmp(type, "html")) | 953 | if (!strcmp(type, "html")) |
954 | return "share/doc/HTML/"; | 954 | return "share/doc/HTML/"; |
955 | if (!strcmp(type, "icon")) | 955 | if (!strcmp(type, "icon")) |
956 | return "share/icons/"; | 956 | return "share/icons/"; |
957 | if (!strcmp(type, "config")) | 957 | if (!strcmp(type, "config")) |
958 | return "config/"; | 958 | return "config/"; |
959 | if (!strcmp(type, "pixmap")) | 959 | if (!strcmp(type, "pixmap")) |
960 | return "share/pixmaps/"; | 960 | return "share/pixmaps/"; |
961 | if (!strcmp(type, "apps")) | 961 | if (!strcmp(type, "apps")) |
962 | return "share/applnk/"; | 962 | return "share/applnk/"; |
963 | if (!strcmp(type, "sound")) | 963 | if (!strcmp(type, "sound")) |
964 | return "share/sounds/"; | 964 | return "share/sounds/"; |
965 | if (!strcmp(type, "locale")) | 965 | if (!strcmp(type, "locale")) |
966 | return "share/locale/"; | 966 | return "share/locale/"; |
967 | if (!strcmp(type, "services")) | 967 | if (!strcmp(type, "services")) |
968 | return "share/services/"; | 968 | return "share/services/"; |
969 | if (!strcmp(type, "servicetypes")) | 969 | if (!strcmp(type, "servicetypes")) |
970 | return "share/servicetypes/"; | 970 | return "share/servicetypes/"; |
971 | if (!strcmp(type, "mime")) | 971 | if (!strcmp(type, "mime")) |
972 | return "share/mimelnk/"; | 972 | return "share/mimelnk/"; |
973 | if (!strcmp(type, "cgi")) | 973 | if (!strcmp(type, "cgi")) |
974 | return "cgi-bin/"; | 974 | return "cgi-bin/"; |
975 | if (!strcmp(type, "wallpaper")) | 975 | if (!strcmp(type, "wallpaper")) |
976 | return "share/wallpapers/"; | 976 | return "share/wallpapers/"; |
977 | if (!strcmp(type, "templates")) | 977 | if (!strcmp(type, "templates")) |
978 | return "share/templates/"; | 978 | return "share/templates/"; |
979 | if (!strcmp(type, "exe")) | 979 | if (!strcmp(type, "exe")) |
980 | return "bin/"; | 980 | return "bin/"; |
981 | if (!strcmp(type, "lib")) | 981 | if (!strcmp(type, "lib")) |
982 | return "lib/"; | 982 | return "lib/"; |
983 | if (!strcmp(type, "module")) | 983 | if (!strcmp(type, "module")) |
984 | return "lib/kde3/"; | 984 | return "lib/kde3/"; |
985 | if (!strcmp(type, "qtplugins")) | 985 | if (!strcmp(type, "qtplugins")) |
986 | return "lib/kde3/plugins"; | 986 | return "lib/kde3/plugins"; |
987 | if (!strcmp(type, "xdgdata-apps")) | 987 | if (!strcmp(type, "xdgdata-apps")) |
988 | return "applications/"; | 988 | return "applications/"; |
989 | if (!strcmp(type, "xdgdata-dirs")) | 989 | if (!strcmp(type, "xdgdata-dirs")) |
990 | return "desktop-directories/"; | 990 | return "desktop-directories/"; |
991 | if (!strcmp(type, "xdgconf-menu")) | 991 | if (!strcmp(type, "xdgconf-menu")) |
992 | return "menus/"; | 992 | return "menus/"; |
993 | if (!strcmp(type, "tmp")) | ||
994 | return "tmp/"; | ||
995 | |||
993 | qFatal("unknown resource type %s", type); | 996 | qFatal("unknown resource type %s", type); |
994 | return QString::null; | 997 | return QString::null; |
995 | } | 998 | } |
996 | 999 | ||
997 | QString KStandardDirs::saveLocation(const char *type, | 1000 | QString KStandardDirs::saveLocation(const char *type, |
998 | const QString& suffix, | 1001 | const QString& suffix, |
999 | bool create) const | 1002 | bool create) const |
1000 | { | 1003 | { |
1001 | //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); | 1004 | //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); |
1002 | //return ""; | 1005 | //return ""; |
1003 | checkConfig(); | 1006 | checkConfig(); |
1004 | 1007 | ||
1005 | QString *pPath = savelocations.find(type); | 1008 | QString *pPath = savelocations.find(type); |
1006 | if (!pPath) | 1009 | if (!pPath) |
1007 | { | 1010 | { |
1008 | QStringList *dirs = relatives.find(type); | 1011 | QStringList *dirs = relatives.find(type); |
1009 | if (!dirs && ( | 1012 | if (!dirs && ( |
1010 | (strcmp(type, "socket") == 0) || | 1013 | (strcmp(type, "socket") == 0) || |
1011 | (strcmp(type, "tmp") == 0) || | 1014 | (strcmp(type, "tmp") == 0) || |
1012 | (strcmp(type, "cache") == 0) )) | 1015 | (strcmp(type, "cache") == 0) )) |
1013 | { | 1016 | { |
1014 | (void) resourceDirs(type); // Generate socket|tmp|cache resource. | 1017 | (void) resourceDirs(type); // Generate socket|tmp|cache resource. |
1015 | dirs = relatives.find(type); // Search again. | 1018 | dirs = relatives.find(type); // Search again. |
1016 | } | 1019 | } |
1017 | if (dirs) | 1020 | if (dirs) |
1018 | { | 1021 | { |
1019 | // Check for existance of typed directory + suffix | 1022 | // Check for existance of typed directory + suffix |
1020 | if (strncmp(type, "xdgdata-", 8) == 0) | 1023 | if (strncmp(type, "xdgdata-", 8) == 0) |
1021 | pPath = new QString(realPath(localxdgdatadir() + dirs->last())); | 1024 | pPath = new QString(realPath(localxdgdatadir() + dirs->last())); |
1022 | else if (strncmp(type, "xdgconf-", 8) == 0) | 1025 | else if (strncmp(type, "xdgconf-", 8) == 0) |
1023 | pPath = new QString(realPath(localxdgconfdir() + dirs->last())); | 1026 | pPath = new QString(realPath(localxdgconfdir() + dirs->last())); |
1024 | else | 1027 | else |
1025 | pPath = new QString(realPath(localkdedir() + dirs->last())); | 1028 | pPath = new QString(realPath(localkdedir() + dirs->last())); |
1026 | } | 1029 | } |
1027 | else { | 1030 | else { |
1028 | dirs = absolutes.find(type); | 1031 | dirs = absolutes.find(type); |
1029 | if (!dirs) | 1032 | if (!dirs) |
1030 | qFatal("KStandardDirs: The resource type %s is not registered", type); | 1033 | qFatal("KStandardDirs: The resource type %s is not registered", type); |
1031 | pPath = new QString(realPath(dirs->last())); | 1034 | pPath = new QString(realPath(dirs->last())); |
1032 | } | 1035 | } |
1033 | 1036 | ||
1034 | savelocations.insert(type, pPath); | 1037 | savelocations.insert(type, pPath); |
1035 | } | 1038 | } |
1036 | 1039 | ||
1037 | QString fullPath = *pPath + suffix; | 1040 | QString fullPath = *pPath + suffix; |
1038 | //US struct stat st; | 1041 | //US struct stat st; |
1039 | //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) | 1042 | //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) |
1040 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); | 1043 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); |
1041 | if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) | 1044 | if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) |
1042 | 1045 | ||
1043 | 1046 | ||
1044 | { | 1047 | { |
1045 | if(!create) { | 1048 | if(!create) { |
1046 | #ifndef NDEBUG | 1049 | #ifndef NDEBUG |
1047 | qDebug("save location %s doesn't exist", fullPath.latin1()); | 1050 | qDebug("save location %s doesn't exist", fullPath.latin1()); |
1048 | #endif | 1051 | #endif |
1049 | return fullPath; | 1052 | return fullPath; |
1050 | } | 1053 | } |
1051 | if(!makeDir(fullPath, 0700)) { | 1054 | if(!makeDir(fullPath, 0700)) { |
1052 | qWarning("failed to create %s", fullPath.latin1()); | 1055 | qWarning("failed to create %s", fullPath.latin1()); |
1053 | return fullPath; | 1056 | return fullPath; |
1054 | } | 1057 | } |
1055 | dircache.remove(type); | 1058 | dircache.remove(type); |
1056 | } | 1059 | } |
1057 | return fullPath; | 1060 | return fullPath; |
1058 | } | 1061 | } |
1059 | 1062 | ||
1060 | QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) | 1063 | QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) |
1061 | { | 1064 | { |
1062 | QString fullPath = absPath; | 1065 | QString fullPath = absPath; |
1063 | int i = absPath.findRev('/'); | 1066 | int i = absPath.findRev('/'); |
1064 | if (i != -1) | 1067 | if (i != -1) |
1065 | { | 1068 | { |
1066 | fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize | 1069 | fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize |
1067 | } | 1070 | } |
1068 | 1071 | ||
1069 | QStringList candidates = resourceDirs(type); | 1072 | QStringList candidates = resourceDirs(type); |
1070 | 1073 | ||
1071 | for (QStringList::ConstIterator it = candidates.begin(); | 1074 | for (QStringList::ConstIterator it = candidates.begin(); |
1072 | it != candidates.end(); it++) | 1075 | it != candidates.end(); it++) |
1073 | if (fullPath.startsWith(*it)) | 1076 | if (fullPath.startsWith(*it)) |
1074 | { | 1077 | { |
1075 | return fullPath.mid((*it).length()); | 1078 | return fullPath.mid((*it).length()); |
1076 | } | 1079 | } |
1077 | 1080 | ||
1078 | return absPath; | 1081 | return absPath; |
1079 | } | 1082 | } |
1080 | 1083 | ||
1081 | 1084 | ||
1082 | bool KStandardDirs::makeDir(const QString& dir2, int mode) | 1085 | bool KStandardDirs::makeDir(const QString& dir2, int mode) |
1083 | { | 1086 | { |
1084 | QString dir = QDir::convertSeparators( dir2 ); | 1087 | QString dir = QDir::convertSeparators( dir2 ); |
1085 | #if 0 | 1088 | #if 0 |
1086 | //LR | 1089 | //LR |
1087 | 1090 | ||
1088 | // we want an absolute path | 1091 | // we want an absolute path |