1015 static int IsPCData(TCHAR *p) { |
1016 static int IsPCData(TCHAR *p) { |
1016 const int size = sizeof(CDStart); |
1017 const int size = sizeof(CDStart); |
1017 return (PACKAGER_STRNCMP(CDStart, p, size) == 0); |
1018 return (PACKAGER_STRNCMP(CDStart, p, size) == 0); |
1018 } |
1019 } |
1019 |
1020 |
1020 //---------------------------------------------------------------------------- |
|
1021 |
|
1022 LinuxJavaUserPreferences::LinuxJavaUserPreferences(void) : |
|
1023 JavaUserPreferences() { |
|
1024 } |
|
1025 |
|
1026 LinuxJavaUserPreferences::~LinuxJavaUserPreferences(void) { |
|
1027 } |
|
1028 |
|
1029 TString LinuxJavaUserPreferences::GetUserPrefFileName(TString Appid) { |
|
1030 TString result; |
|
1031 struct passwd *pw = getpwuid(getuid()); |
|
1032 TString homedir = pw->pw_dir; |
|
1033 TString userOverrideFileName = FilePath::IncludeTrailingSeparator(homedir) |
|
1034 + FilePath::IncludeTrailingSeparator(_T(".java/.userPrefs")) |
|
1035 + FilePath::IncludeTrailingSeparator(Appid) |
|
1036 + _T("JVMUserOptions/prefs.xml"); |
|
1037 |
|
1038 if (FilePath::FileExists(userOverrideFileName) == true) { |
|
1039 result = userOverrideFileName; |
|
1040 } |
|
1041 |
|
1042 return result; |
|
1043 } |
|
1044 |
|
1045 OrderedMap<TString, TString> ReadNode(XMLNode* node) { |
|
1046 OrderedMap<TString, TString> result; |
|
1047 XMLNode* keyNode = FindXMLChild(node->_sub, _T("entry")); |
|
1048 |
|
1049 while (keyNode != NULL) { |
|
1050 TString key = FindXMLAttribute(keyNode->_attributes, _T("key")); |
|
1051 TString value = FindXMLAttribute(keyNode->_attributes, _T("value")); |
|
1052 keyNode = keyNode->_next; |
|
1053 |
|
1054 if (key.empty() == false) { |
|
1055 result.Append(key, value); |
|
1056 } |
|
1057 } |
|
1058 |
|
1059 return result; |
|
1060 } |
|
1061 |
|
1062 OrderedMap<TString, TString> GetJvmUserArgs(TString filename) { |
|
1063 OrderedMap<TString, TString> result; |
|
1064 DynamicBuffer<char> buffer(fsize + 1); |
|
1065 if (buffer.GetData() == NULL) { |
|
1066 return result; |
|
1067 } |
|
1068 |
|
1069 if (FilePath::FileExists(filename) == true) { |
|
1070 //scan file for the key |
|
1071 FILE* fp = fopen(PlatformString(filename).toPlatformString(), "r"); |
|
1072 if (fp != NULL) { |
|
1073 fseek(fp, 0, SEEK_END); |
|
1074 long fsize = ftell(fp); |
|
1075 rewind(fp); |
|
1076 fread(buffer.GetData(), fsize, 1, fp); |
|
1077 fclose(fp); |
|
1078 buffer[fsize] = 0; |
|
1079 |
|
1080 XMLNode* node = NULL; |
|
1081 XMLNode* doc = ParseXMLDocument(buffer.GetData()); |
|
1082 |
|
1083 if (doc != NULL) { |
|
1084 node = FindXMLChild(doc, _T("map")); |
|
1085 |
|
1086 if (node != NULL) { |
|
1087 result = ReadNode(node); |
|
1088 } |
|
1089 } |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 return result; |
|
1094 } |
|
1095 |
|
1096 bool LinuxJavaUserPreferences::Load(TString Appid) { |
|
1097 bool result = false; |
|
1098 TString filename = GetUserPrefFileName(Appid); |
|
1099 |
|
1100 if (FilePath::FileExists(filename) == true) { |
|
1101 FMap = GetJvmUserArgs(filename); |
|
1102 result = true; |
|
1103 } |
|
1104 |
|
1105 return result; |
|
1106 } |
|
1107 |
|
1108 namespace { |
1021 namespace { |
1109 template<class funcType> |
1022 template<class funcType> |
1110 class DllFunction { |
1023 class DllFunction { |
1111 const Library& lib; |
1024 const Library& lib; |
1112 funcType funcPtr; |
1025 funcType funcPtr; |