Changeset 47898 in vbox
- Timestamp:
- Aug 20, 2013 11:59:55 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/io/nsDirectoryService.cpp
r1 r47898 93 93 #define COMPONENT_REGISTRY_NAME NS_LITERAL_CSTRING("compreg.dat") 94 94 #define COMPONENT_DIRECTORY NS_LITERAL_CSTRING("components") 95 #endif 95 #endif 96 96 97 97 #define XPTI_REGISTRY_NAME NS_LITERAL_CSTRING("xpti.dat") … … 112 112 113 113 //---------------------------------------------------------------------------------------- 114 nsresult 114 nsresult 115 115 nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile) 116 116 //---------------------------------------------------------------------------------------- … … 118 118 NS_ENSURE_ARG_POINTER(aFile); 119 119 *aFile = nsnull; 120 120 121 121 // Set the component registry location: 122 122 if (!mService) 123 123 return NS_ERROR_FAILURE; 124 124 125 nsresult rv; 126 125 nsresult rv; 126 127 127 nsCOMPtr<nsIProperties> dirService; 128 rv = nsDirectoryService::Create(nsnull, 129 NS_GET_IID(nsIProperties), 128 rv = nsDirectoryService::Create(nsnull, 129 NS_GET_IID(nsIProperties), 130 130 getter_AddRefs(dirService)); // needs to be around for life of product 131 131 … … 157 157 if (lastSlash) 158 158 *(lastSlash + 1) = '\0'; 159 159 160 160 localFile->InitWithNativePath(nsDependentCString(buf)); 161 161 *aFile = localFile; … … 183 183 FSSpec appFSSpec; 184 184 ::FSMakeFSSpec(pInfo.processAppSpec->vRefNum, pInfo.processAppSpec->parID, 0, &appFSSpec); 185 185 186 186 nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface((nsIFile*)localFile); 187 if (localFileMac) 187 if (localFileMac) 188 188 { 189 189 localFileMac->InitWithFSSpec(&appFSSpec); … … 221 221 } 222 222 } 223 224 NS_ASSERTION(*aFile, "nsDirectoryService - Could not determine CurrentProcessDir.\n"); 223 224 NS_ASSERTION(*aFile, "nsDirectoryService - Could not determine CurrentProcessDir.\n"); 225 225 if (*aFile) 226 226 return NS_OK; … … 243 243 buf2[0] = '\0'; 244 244 245 /* 245 /* 246 246 * Env.var. VBOX_XPCOM_HOME first. 247 247 */ … … 251 251 if (strlen(psz) < MAXPATHLEN) 252 252 { 253 if (!realpath(psz, buf2)) 253 if (!realpath(psz, buf2)) 254 254 strcpy(buf2, psz); 255 255 strcat(buf2, "/x"); /* for the filename stripping */ … … 278 278 char buf[MAXPATHLEN]; 279 279 int cchLink = readlink("/proc/self/exe", buf, sizeof(buf) - 1); 280 if (cchLink > 0 || cchLink != sizeof(buf) - 1) 280 if (cchLink > 0 || cchLink != sizeof(buf) - 1) 281 281 { 282 282 buf[cchLink] = '\0'; … … 297 297 #ifdef DEBUG 298 298 printf("debug: (1) VBOX_XPCOM_HOME=%s\n", buf2); 299 #endif 299 #endif 300 300 strcpy(szPath, buf2); 301 301 fPathSet = true; … … 313 313 314 314 315 // The MOZ_DEFAULT_VBOX_XPCOM HOME variable can be set at configure time with315 // The MOZ_DEFAULT_VBOX_XPCOM_HOME variable can be set at configure time with 316 316 // a --with-default-mozilla-five-home=foo autoconf flag. 317 // 317 // 318 318 // The idea here is to allow for builds that have a default VBOX_XPCOM_HOME 319 319 // regardless of the environment. This makes it easier to write apps that 320 // embed mozilla without having to worry about setting up the environment 320 // embed mozilla without having to worry about setting up the environment 321 321 // 322 322 // We do this py putenv()ing the default value into the environment. Note that … … 399 399 400 400 #endif 401 401 402 402 NS_RELEASE(localFile); 403 403 … … 449 449 nsIAtom* nsDirectoryService::sMusicDocumentsDirectory = nsnull; 450 450 nsIAtom* nsDirectoryService::sInternetSitesDirectory = nsnull; 451 #elif defined (XP_WIN) 451 #elif defined (XP_WIN) 452 452 nsIAtom* nsDirectoryService::sSystemDirectory = nsnull; 453 453 nsIAtom* nsDirectoryService::sWindowsDirectory = nsnull; … … 558 558 { NS_OSX_MUSIC_DOCUMENTS_DIR, &nsDirectoryService::sMusicDocumentsDirectory }, 559 559 { NS_OSX_INTERNET_SITES_DIR, &nsDirectoryService::sInternetSitesDirectory }, 560 #elif defined (XP_WIN) 560 #elif defined (XP_WIN) 561 561 { NS_OS_SYSTEM_DIR, &nsDirectoryService::sSystemDirectory }, 562 562 { NS_WIN_WINDOWS_DIR, &nsDirectoryService::sWindowsDirectory }, … … 601 601 { NS_BEOS_DESKTOP_DIR, &nsDirectoryService::sDesktopDirectory }, 602 602 #endif 603 }; 603 }; 604 604 605 605 nsresult … … 607 607 { 608 608 nsresult rv; 609 609 610 610 rv = NS_NewISupportsArray(getter_AddRefs(mProviders)); 611 611 if (NS_FAILED(rv)) return rv; 612 612 613 613 NS_RegisterStaticAtoms(directory_atoms, NS_ARRAY_LENGTH(directory_atoms)); 614 614 615 615 // Let the list hold the only reference to the provider. 616 616 nsAppFileLocationProvider *defaultProvider = new nsAppFileLocationProvider; … … 666 666 persistent(PR_TRUE), 667 667 uuid(aUUID) {} 668 668 669 669 const char* property; 670 670 nsISupports* data; … … 707 707 { 708 708 nsCStringKey key(prop); 709 709 710 710 nsCOMPtr<nsISupports> value = dont_AddRef(mHashtable.Get(&key)); 711 711 712 712 if (value) 713 713 { … … 768 768 } 769 769 770 return NS_ERROR_FAILURE; 770 return NS_ERROR_FAILURE; 771 771 } 772 772 … … 777 777 nsCOMPtr<nsIFile> value; 778 778 nsresult rv = Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(value)); 779 if (NS_FAILED(rv)) 779 if (NS_FAILED(rv)) 780 780 return rv; 781 781 782 782 if (value) 783 783 { 784 784 *_retval = PR_TRUE; 785 785 } 786 786 787 787 return rv; 788 788 } … … 823 823 // This is meant to be a place of xpcom or system specific file locations, not 824 824 // application specific locations. If you need the later, register a callback for 825 // your application. 825 // your application. 826 826 827 827 NS_IMETHODIMP … … 837 837 838 838 // check to see if it is one of our defaults 839 840 if (inAtom == nsDirectoryService::sCurrentProcess || 839 840 if (inAtom == nsDirectoryService::sCurrentProcess || 841 841 inAtom == nsDirectoryService::sOS_CurrentProcessDirectory ) 842 842 { … … 849 849 return NS_ERROR_FAILURE; 850 850 851 localFile->AppendNative(COMPONENT_DIRECTORY); 852 localFile->AppendNative(COMPONENT_REGISTRY_NAME); 851 localFile->AppendNative(COMPONENT_DIRECTORY); 852 localFile->AppendNative(COMPONENT_REGISTRY_NAME); 853 853 } 854 854 else if (inAtom == nsDirectoryService::sXPTIRegistry) … … 858 858 return NS_ERROR_FAILURE; 859 859 860 localFile->AppendNative(COMPONENT_DIRECTORY); 861 localFile->AppendNative(XPTI_REGISTRY_NAME); 862 } 863 860 localFile->AppendNative(COMPONENT_DIRECTORY); 861 localFile->AppendNative(XPTI_REGISTRY_NAME); 862 } 863 864 864 // Unless otherwise set, the core pieces of the GRE exist 865 865 // in the current process directory. … … 881 881 rv = GetCurrentProcessDirectory(getter_AddRefs(localFile)); 882 882 if (localFile) 883 localFile->AppendNative(COMPONENT_DIRECTORY); 883 localFile->AppendNative(COMPONENT_DIRECTORY); 884 884 } 885 885 else if (inAtom == nsDirectoryService::sOS_DriveDirectory) … … 893 893 else if (inAtom == nsDirectoryService::sOS_CurrentProcessDirectory) 894 894 { 895 rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, getter_AddRefs(localFile)); 895 rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, getter_AddRefs(localFile)); 896 896 } 897 897 else if (inAtom == nsDirectoryService::sOS_CurrentWorkingDirectory) 898 898 { 899 rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); 900 } 901 899 rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); 900 } 901 902 902 #if defined(XP_MACOSX) 903 903 else if (inAtom == nsDirectoryService::sDirectory) … … 948 948 { 949 949 rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile)); 950 } 950 } 951 951 else if (inAtom == nsDirectoryService::sUserLibDirectory) 952 952 { … … 980 980 ::ICStop(icInstance); 981 981 } 982 982 983 983 if NS_FAILED(rv) 984 { 984 { 985 985 // We got an error getting the DL folder from IC so try finding the user's Desktop folder 986 986 rv = GetOSXFolderType(kUserDomain, kDesktopFolderType, getter_AddRefs(localFile)); 987 987 } 988 988 } 989 989 990 990 // Don't cache the DL directory as the user may change it while we're running. 991 991 // Negligible perf hit as this directory is only requested for downloads … … 1059 1059 else if (inAtom == nsDirectoryService::sSystemDirectory) 1060 1060 { 1061 rv = GetSpecialSystemDirectory(Win_SystemDirectory, getter_AddRefs(localFile)); 1061 rv = GetSpecialSystemDirectory(Win_SystemDirectory, getter_AddRefs(localFile)); 1062 1062 } 1063 1063 else if (inAtom == nsDirectoryService::sWindowsDirectory) 1064 1064 { 1065 rv = GetSpecialSystemDirectory(Win_WindowsDirectory, getter_AddRefs(localFile)); 1065 rv = GetSpecialSystemDirectory(Win_WindowsDirectory, getter_AddRefs(localFile)); 1066 1066 } 1067 1067 else if (inAtom == nsDirectoryService::sHomeDirectory) 1068 1068 { 1069 rv = GetSpecialSystemDirectory(Win_HomeDirectory, getter_AddRefs(localFile)); 1069 rv = GetSpecialSystemDirectory(Win_HomeDirectory, getter_AddRefs(localFile)); 1070 1070 } 1071 1071 else if (inAtom == nsDirectoryService::sDesktop) 1072 1072 { 1073 rv = GetSpecialSystemDirectory(Win_Desktop, getter_AddRefs(localFile)); 1073 rv = GetSpecialSystemDirectory(Win_Desktop, getter_AddRefs(localFile)); 1074 1074 } 1075 1075 else if (inAtom == nsDirectoryService::sPrograms) 1076 1076 { 1077 rv = GetSpecialSystemDirectory(Win_Programs, getter_AddRefs(localFile)); 1077 rv = GetSpecialSystemDirectory(Win_Programs, getter_AddRefs(localFile)); 1078 1078 } 1079 1079 else if (inAtom == nsDirectoryService::sControls) 1080 1080 { 1081 rv = GetSpecialSystemDirectory(Win_Controls, getter_AddRefs(localFile)); 1081 rv = GetSpecialSystemDirectory(Win_Controls, getter_AddRefs(localFile)); 1082 1082 } 1083 1083 else if (inAtom == nsDirectoryService::sPrinters) 1084 1084 { 1085 rv = GetSpecialSystemDirectory(Win_Printers, getter_AddRefs(localFile)); 1085 rv = GetSpecialSystemDirectory(Win_Printers, getter_AddRefs(localFile)); 1086 1086 } 1087 1087 else if (inAtom == nsDirectoryService::sPersonal) 1088 1088 { 1089 rv = GetSpecialSystemDirectory(Win_Personal, getter_AddRefs(localFile)); 1089 rv = GetSpecialSystemDirectory(Win_Personal, getter_AddRefs(localFile)); 1090 1090 } 1091 1091 else if (inAtom == nsDirectoryService::sFavorites) 1092 1092 { 1093 rv = GetSpecialSystemDirectory(Win_Favorites, getter_AddRefs(localFile)); 1093 rv = GetSpecialSystemDirectory(Win_Favorites, getter_AddRefs(localFile)); 1094 1094 } 1095 1095 else if (inAtom == nsDirectoryService::sStartup) … … 1099 1099 else if (inAtom == nsDirectoryService::sRecent) 1100 1100 { 1101 rv = GetSpecialSystemDirectory(Win_Recent, getter_AddRefs(localFile)); 1101 rv = GetSpecialSystemDirectory(Win_Recent, getter_AddRefs(localFile)); 1102 1102 } 1103 1103 else if (inAtom == nsDirectoryService::sSendto) 1104 1104 { 1105 rv = GetSpecialSystemDirectory(Win_Sendto, getter_AddRefs(localFile)); 1105 rv = GetSpecialSystemDirectory(Win_Sendto, getter_AddRefs(localFile)); 1106 1106 } 1107 1107 else if (inAtom == nsDirectoryService::sBitbucket) 1108 1108 { 1109 rv = GetSpecialSystemDirectory(Win_Bitbucket, getter_AddRefs(localFile)); 1109 rv = GetSpecialSystemDirectory(Win_Bitbucket, getter_AddRefs(localFile)); 1110 1110 } 1111 1111 else if (inAtom == nsDirectoryService::sStartmenu) 1112 1112 { 1113 rv = GetSpecialSystemDirectory(Win_Startmenu, getter_AddRefs(localFile)); 1113 rv = GetSpecialSystemDirectory(Win_Startmenu, getter_AddRefs(localFile)); 1114 1114 } 1115 1115 else if (inAtom == nsDirectoryService::sDesktopdirectory) 1116 1116 { 1117 rv = GetSpecialSystemDirectory(Win_Desktopdirectory, getter_AddRefs(localFile)); 1117 rv = GetSpecialSystemDirectory(Win_Desktopdirectory, getter_AddRefs(localFile)); 1118 1118 } 1119 1119 else if (inAtom == nsDirectoryService::sDrives) … … 1123 1123 else if (inAtom == nsDirectoryService::sNetwork) 1124 1124 { 1125 rv = GetSpecialSystemDirectory(Win_Network, getter_AddRefs(localFile)); 1125 rv = GetSpecialSystemDirectory(Win_Network, getter_AddRefs(localFile)); 1126 1126 } 1127 1127 else if (inAtom == nsDirectoryService::sNethood) 1128 1128 { 1129 rv = GetSpecialSystemDirectory(Win_Nethood, getter_AddRefs(localFile)); 1129 rv = GetSpecialSystemDirectory(Win_Nethood, getter_AddRefs(localFile)); 1130 1130 } 1131 1131 else if (inAtom == nsDirectoryService::sFonts) … … 1135 1135 else if (inAtom == nsDirectoryService::sTemplates) 1136 1136 { 1137 rv = GetSpecialSystemDirectory(Win_Templates, getter_AddRefs(localFile)); 1137 rv = GetSpecialSystemDirectory(Win_Templates, getter_AddRefs(localFile)); 1138 1138 } 1139 1139 else if (inAtom == nsDirectoryService::sCommon_Startmenu) 1140 1140 { 1141 rv = GetSpecialSystemDirectory(Win_Common_Startmenu, getter_AddRefs(localFile)); 1141 rv = GetSpecialSystemDirectory(Win_Common_Startmenu, getter_AddRefs(localFile)); 1142 1142 } 1143 1143 else if (inAtom == nsDirectoryService::sCommon_Programs) 1144 1144 { 1145 rv = GetSpecialSystemDirectory(Win_Common_Programs, getter_AddRefs(localFile)); 1145 rv = GetSpecialSystemDirectory(Win_Common_Programs, getter_AddRefs(localFile)); 1146 1146 } 1147 1147 else if (inAtom == nsDirectoryService::sCommon_Startup) 1148 1148 { 1149 rv = GetSpecialSystemDirectory(Win_Common_Startup, getter_AddRefs(localFile)); 1149 rv = GetSpecialSystemDirectory(Win_Common_Startup, getter_AddRefs(localFile)); 1150 1150 } 1151 1151 else if (inAtom == nsDirectoryService::sCommon_Desktopdirectory) 1152 1152 { 1153 rv = GetSpecialSystemDirectory(Win_Common_Desktopdirectory, getter_AddRefs(localFile)); 1153 rv = GetSpecialSystemDirectory(Win_Common_Desktopdirectory, getter_AddRefs(localFile)); 1154 1154 } 1155 1155 else if (inAtom == nsDirectoryService::sAppdata) 1156 1156 { 1157 rv = GetSpecialSystemDirectory(Win_Appdata, getter_AddRefs(localFile)); 1157 rv = GetSpecialSystemDirectory(Win_Appdata, getter_AddRefs(localFile)); 1158 1158 } 1159 1159 else if (inAtom == nsDirectoryService::sPrinthood) 1160 1160 { 1161 rv = GetSpecialSystemDirectory(Win_Printhood, getter_AddRefs(localFile)); 1161 rv = GetSpecialSystemDirectory(Win_Printhood, getter_AddRefs(localFile)); 1162 1162 } 1163 1163 else if (inAtom == nsDirectoryService::sWinCookiesDirectory) 1164 1164 { 1165 rv = GetSpecialSystemDirectory(Win_Cookies, getter_AddRefs(localFile)); 1165 rv = GetSpecialSystemDirectory(Win_Cookies, getter_AddRefs(localFile)); 1166 1166 } 1167 1167 #elif defined (XP_UNIX) … … 1169 1169 else if (inAtom == nsDirectoryService::sLocalDirectory) 1170 1170 { 1171 rv = GetSpecialSystemDirectory(Unix_LocalDirectory, getter_AddRefs(localFile)); 1171 rv = GetSpecialSystemDirectory(Unix_LocalDirectory, getter_AddRefs(localFile)); 1172 1172 } 1173 1173 else if (inAtom == nsDirectoryService::sLibDirectory) … … 1177 1177 else if (inAtom == nsDirectoryService::sHomeDirectory) 1178 1178 { 1179 rv = GetSpecialSystemDirectory(Unix_HomeDirectory, getter_AddRefs(localFile)); 1179 rv = GetSpecialSystemDirectory(Unix_HomeDirectory, getter_AddRefs(localFile)); 1180 1180 } 1181 1181 #elif defined (XP_OS2) 1182 1182 else if (inAtom == nsDirectoryService::sSystemDirectory) 1183 1183 { 1184 rv = GetSpecialSystemDirectory(OS2_SystemDirectory, getter_AddRefs(localFile)); 1184 rv = GetSpecialSystemDirectory(OS2_SystemDirectory, getter_AddRefs(localFile)); 1185 1185 } 1186 1186 else if (inAtom == nsDirectoryService::sOS2Directory) 1187 1187 { 1188 rv = GetSpecialSystemDirectory(OS2_OS2Directory, getter_AddRefs(localFile)); 1188 rv = GetSpecialSystemDirectory(OS2_OS2Directory, getter_AddRefs(localFile)); 1189 1189 } 1190 1190 else if (inAtom == nsDirectoryService::sHomeDirectory) 1191 1191 { 1192 rv = GetSpecialSystemDirectory(OS2_HomeDirectory, getter_AddRefs(localFile)); 1192 rv = GetSpecialSystemDirectory(OS2_HomeDirectory, getter_AddRefs(localFile)); 1193 1193 } 1194 1194 else if (inAtom == nsDirectoryService::sDesktopDirectory) 1195 1195 { 1196 rv = GetSpecialSystemDirectory(OS2_DesktopDirectory, getter_AddRefs(localFile)); 1196 rv = GetSpecialSystemDirectory(OS2_DesktopDirectory, getter_AddRefs(localFile)); 1197 1197 } 1198 1198 #elif defined (XP_BEOS) 1199 1199 else if (inAtom == nsDirectoryService::sSettingsDirectory) 1200 1200 { 1201 rv = GetSpecialSystemDirectory(BeOS_SettingsDirectory, getter_AddRefs(localFile)); 1201 rv = GetSpecialSystemDirectory(BeOS_SettingsDirectory, getter_AddRefs(localFile)); 1202 1202 } 1203 1203 else if (inAtom == nsDirectoryService::sHomeDirectory) … … 1207 1207 else if (inAtom == nsDirectoryService::sDesktopDirectory) 1208 1208 { 1209 rv = GetSpecialSystemDirectory(BeOS_DesktopDirectory, getter_AddRefs(localFile)); 1209 rv = GetSpecialSystemDirectory(BeOS_DesktopDirectory, getter_AddRefs(localFile)); 1210 1210 } 1211 1211 else if (inAtom == nsDirectoryService::sSystemDirectory) 1212 1212 { 1213 rv = GetSpecialSystemDirectory(BeOS_SystemDirectory, getter_AddRefs(localFile)); 1213 rv = GetSpecialSystemDirectory(BeOS_SystemDirectory, getter_AddRefs(localFile)); 1214 1214 } 1215 1215 #endif … … 1231 1231 NS_ENSURE_ARG_POINTER(_retval); 1232 1232 *_retval = nsnull; 1233 1233 1234 1234 return NS_ERROR_FAILURE; 1235 1235 }
Note:
See TracChangeset
for help on using the changeset viewer.