- Timestamp:
- Oct 26, 2010 12:27:50 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/fs.h
r30365 r33464 563 563 RT_C_DECLS_END 564 564 565 #endif /* ___iprt_fs_h */566 565 #endif /* !___iprt_fs_h */ 566 -
trunk/include/iprt/isofs.h
r33449 r33464 27 27 #define ___iprt_isofs_h 28 28 29 #include <iprt/file.h> 30 #include <iprt/mem.h> 29 #include <iprt/types.h> 31 30 #include <iprt/list.h> 32 #include <iprt/string.h>33 31 34 32 RT_C_DECLS_BEGIN … … 221 219 RT_C_DECLS_END 222 220 223 #endif /* ___iprt_isofs_h */224 221 #endif 222 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSharedFolders.cpp
r31111 r33464 57 57 Log(("VBoxTray: Connecting share %u (%s) ...\n", i+1, pszName)); 58 58 59 char *pszShareName = NULL; 60 if ( RTStrAPrintf(&pszShareName, "\\\\vboxsrv\\%s", pszName) > 0 61 && pszShareName) 59 char *pszShareName; 60 if (RTStrAPrintf(&pszShareName, "\\\\vboxsrv\\%s", pszName) >= 0) 62 61 { 63 char c Drive = 'D'; /* Start probing whether drive D: is free to use. */62 char chDrive = 'D'; /* Start probing whether drive D: is free to use. */ 64 63 do 65 64 { 66 65 char szCurDrive[3]; 67 RTStrPrintf(szCurDrive, sizeof(szCurDrive), "%c:", c Drive++);66 RTStrPrintf(szCurDrive, sizeof(szCurDrive), "%c:", chDrive++); 68 67 69 68 NETRESOURCE resource; … … 102 101 } 103 102 } 104 } while (cDrive <= 'Z');105 106 if (c Drive > 'Z')103 } while (chDrive <= 'Z'); 104 105 if (chDrive > 'Z') 107 106 { 108 107 LogRel(("VBoxTray: No free driver letter found to assign shared folder \"%s\", aborting.\n", pszName)); … … 113 112 } 114 113 else 115 rc = VERR_NO_ MEMORY;114 rc = VERR_NO_STR_MEMORY; 116 115 RTStrFree(pszName); 117 116 } … … 156 155 Log(("VBoxTray: Disconnecting share %u (%s) ...\n", i+1, pszName)); 157 156 158 char *pszShareName = NULL; 159 if ( RTStrAPrintf(&pszShareName, "\\\\vboxsrv\\%s", pszName) > 0 160 && pszShareName) 157 char *pszShareName; 158 if (RTStrAPrintf(&pszShareName, "\\\\vboxsrv\\%s", pszName) >= 0) 161 159 { 162 160 DWORD dwErr = WNetCancelConnection2(pszShareName, 0, FALSE /* Force disconnect */); … … 164 162 { 165 163 LogRel(("VBoxTray: Share \"%s\" was disconnected\n", pszShareName)); 164 RTStrFree(pszShareName); 165 RTStrFree(pszName); 166 166 break; 167 167 } 168 else 168 169 LogRel(("VBoxTray: Disconnecting \"%s\" failed, dwErr = %ld\n", pszShareName, dwErr)); 170 171 switch (dwErr) 169 172 { 170 LogRel(("VBoxTray: Disconnecting \"%s\" failed, dwErr = %ld\n", pszShareName, dwErr)); 171 172 switch (dwErr) 173 { 174 case ERROR_NOT_CONNECTED: 175 break; 176 177 default: 178 LogRel(("VBoxTray: Error while disconnecting shared folder \"%s\", error = %ld\n", 179 pszShareName, dwErr)); 180 break; 181 } 173 case ERROR_NOT_CONNECTED: 174 break; 175 176 default: 177 LogRel(("VBoxTray: Error while disconnecting shared folder \"%s\", error = %ld\n", 178 pszShareName, dwErr)); 179 break; 182 180 } 183 181 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
r32705 r33464 280 280 { 281 281 #endif 282 if (RTStrAPrintf(ppszPrefix, "sf_")) 283 rc = VINF_SUCCESS; 284 else 285 rc = VERR_NO_MEMORY; 282 rc = RTStrDupEx(ppszPrefix, "sf_"); 286 283 #ifdef VBOX_WITH_GUEST_PROPS 287 284 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
r33448 r33464 940 940 if (uNumEnvVars) 941 941 { 942 pData->papszEnv = (char **)RTMemAlloc(uNumEnvVars * sizeof(char*));942 pData->papszEnv = (char **)RTMemAlloc(uNumEnvVars * sizeof(char*)); 943 943 AssertPtr(pData->papszEnv); 944 944 pData->uNumEnvVars = uNumEnvVars; 945 945 946 const char *p cCur = pszEnv;946 const char *pszCur = pszEnv; 947 947 uint32_t i = 0; 948 948 uint32_t cbLen = 0; … … 955 955 break; 956 956 } 957 int cbStr = RTStrAPrintf(&pData->papszEnv[i++], "%s", p cCur);957 int cbStr = RTStrAPrintf(&pData->papszEnv[i++], "%s", pszCur); 958 958 if (cbStr < 0) 959 959 { 960 rc = VERR_NO_ MEMORY;960 rc = VERR_NO_STR_MEMORY; 961 961 break; 962 962 } 963 cbLen+= cbStr + 1; /* Skip terminating '\0' */964 pcCur+= cbStr + 1; /* Skip terminating '\0' */963 pszCur += cbStr + 1; /* Skip terminating '\0' */ 964 cbLen += cbStr + 1; /* Skip terminating '\0' */ 965 965 } 966 966 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceCpuHotPlug.cpp
r30013 r33464 154 154 { 155 155 PCSYSFSCPUPATHCOMP pPathComponent = &pAcpiCpuPathLvl->aComponentsPossible[iCompCurr]; 156 157 /* Open the directory */ 156 158 PRTDIR pDirCurr = NULL; 157 char *pszPathTmp = NULL; 158 bool fFound = false; 159 160 rc = RTStrAPrintf(&pszPathTmp, "%s/%s*", pszPath, pPathComponent->pcszName); 159 char *pszPathTmp = RTPathJoinA(pszPath, pPathComponent->pcszName); 160 if (pszPathTmp) 161 { 162 rc = RTDirOpenFiltered(&pDirCurr, pszPathTmp, RTDIRFILTER_WINNT); 163 RTStrFree(pszPathTmp); 164 } 165 else 166 rc = VERR_NO_STR_MEMORY; 161 167 if (RT_FAILURE(rc)) 162 168 break; 163 169 164 /* Open the directory */165 rc = RTDirOpenFiltered(&pDirCurr, pszPathTmp, RTDIRFILTER_WINNT);166 if (RT_FAILURE(rc))167 {168 RTStrFree(pszPathTmp);169 break;170 }171 172 170 /* Search if the current directory contains one of the possible parts. */ 171 size_t cchName = strlen(pPathComponent->pcszName); 173 172 RTDIRENTRY DirFolderContent; 173 bool fFound = false; 174 174 while (RT_SUCCESS(RTDirRead(pDirCurr, &DirFolderContent, NULL))) /* Assumption that szName has always enough space */ 175 175 { 176 if (!strncmp(DirFolderContent.szName, pPathComponent->pcszName, strlen(pPathComponent->pcszName))) 176 if ( DirFolderContent.cbName >= cchName 177 && !strncmp(DirFolderContent.szName, pPathComponent->pcszName, cchName)) 177 178 { 178 char *pszPathLvl = NULL;179 180 179 /* Found, use the complete name to dig deeper. */ 181 180 fFound = true; 182 181 pAcpiCpuPathLvl->uId = iCompCurr; 183 rc = RTStrAPrintf(&pszPathLvl, "%s/%s", pszPath, DirFolderContent.szName); 184 185 if (RT_SUCCESS(rc)) 182 char *pszPathLvl = RTPathJoinA(pszPath, DirFolderContent.szName); 183 if (pszPathLvl) 186 184 { 187 185 RTStrFree(pszPath); 188 186 pszPath = pszPathLvl; 189 187 } 188 else 189 rc = VERR_NO_STR_MEMORY; 190 190 break; 191 191 } … … 235 235 /* Init everything. */ 236 236 Assert(pAcpiCpuPathLvl->uId != ACPI_CPU_PATH_NOT_PROBED); 237 rc = RTStrAPrintf(&pszPath, 238 "%s/%s*", SYSFS_ACPI_CPU_PATH, 239 pAcpiCpuPathLvl->aComponentsPossible[pAcpiCpuPathLvl->uId].pcszName); 240 if (RT_FAILURE(rc)) 241 return rc; 237 pszPath = RTPathJoinA(SYSFS_ACPI_CPU_PATH, pAcpiCpuPathLvl->aComponentsPossible[pAcpiCpuPathLvl->uId].pcszName); 238 if (!pszPath) 239 return VERR_NO_STR_MEMORY; 242 240 243 241 pAcpiCpuPathLvl->pszPath = RTStrDup(SYSFS_ACPI_CPU_PATH); 244 242 if (!pAcpiCpuPathLvl->pszPath) 245 return VERR_NO_MEMORY; 243 { 244 RTStrFree(pszPath); 245 return VERR_NO_STR_MEMORY; 246 } 246 247 247 248 /* Open the directory */ … … 259 260 if (RT_SUCCESS(rc)) 260 261 { 261 char *pszPathCurr;262 263 262 /* Create the new path. */ 264 rc = RTStrAPrintf(&pszPathCurr, "%s/%s", pAcpiCpuPathLvl->pszPath, DirFolderContent.szName); 265 if (RT_FAILURE(rc)) 263 char *pszPathCurr = RTPathJoinA(pAcpiCpuPathLvl->pszPath, DirFolderContent.szName); 264 if (!pszPathCurr) 265 { 266 rc = VERR_NO_STR_MEMORY; 266 267 break; 268 } 267 269 268 270 /* If this is the last level check for the given core and package id. */ … … 306 308 Assert(pAcpiCpuPathLvl->uId != ACPI_CPU_PATH_NOT_PROBED); 307 309 308 rc = RTStrAPrintf(&pszPathDir, "%s/%s*", pszPathCurr, pPathComponent->pcszName); 309 if (RT_FAILURE(rc)) 310 pszPathDir = RTPathJoinA(pszPathCurr, pPathComponent->pcszName); 311 if (!pszPathDir) 312 { 313 rc = VERR_NO_STR_MEMORY; 310 314 break; 315 } 311 316 312 317 VBoxServiceVerbose(3, "New path %s\n", pszPathDir); -
trunk/src/VBox/Devices/Network/lwip/vbox/sys_arch.c
r28800 r33464 383 383 { 384 384 int rc; 385 char *pszThread = NULL;386 385 #if SYS_LIGHTWEIGHT_PROT 387 386 SYS_ARCH_DECL_PROTECT(old_level); … … 400 399 g_aTLS[id].thread = thread; 401 400 g_aTLS[id].arg = arg; 402 RTStrAPrintf(&pszThread, "lwIP%u", id); 403 rc = RTThreadCreate(&tid, sys_thread_adapter, &g_aTLS[id], 0, 404 RTTHREADTYPE_IO, 0, pszThread); 401 rc = RTThreadCreateF(&tid, sys_thread_adapter, &g_aTLS[id], 0, 402 RTTHREADTYPE_IO, 0, "lwIP%u", id); 405 403 if (RT_FAILURE(rc)) 406 404 { -
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r28800 r33464 970 970 rc = RTStrAPrintf(&pszPassthroughDevice, "/dev/%s%u", 971 971 DeviceCCB.cgdl.periph_name, DeviceCCB.cgdl.unit_number); 972 if ( RT_SUCCESS(rc))972 if (rc >= 0) 973 973 { 974 974 RTFILE PassthroughDevice; … … 1013 1013 } 1014 1014 } 1015 else 1016 rc = VERR_NO_STR_MEMORY; 1015 1017 } 1016 1018 else -
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r33355 r33464 2075 2075 2076 2076 /* To get all entries with VBoxHDD as prefix. */ 2077 char *pszPluginFilter; 2078 rc = RTStrAPrintf(&pszPluginFilter, "%s/%s*", szPath, VBOX_HDDFORMAT_PLUGIN_PREFIX); 2079 if (RT_FAILURE(rc)) 2080 { 2081 rc = VERR_NO_MEMORY; 2082 return rc; 2083 } 2077 char *pszPluginFilter = RTPathJoinA(szPath, VBOX_HDDFORMAT_PLUGIN_PREFIX "*"); 2078 if (!pszPluginFilter) 2079 return VERR_NO_STR_MEMORY; 2084 2080 2085 2081 PRTDIRENTRYEX pPluginDirEntry = NULL; … … 2127 2123 2128 2124 /* Prepend the path to the libraries. */ 2129 rc = RTStrAPrintf(&pszPluginPath, "%s/%s",szPath, pPluginDirEntry->szName);2130 if ( RT_FAILURE(rc))2131 { 2132 rc = VERR_NO_ MEMORY;2125 pszPluginPath = RTPathJoinA(szPath, pPluginDirEntry->szName); 2126 if (!pszPluginPath) 2127 { 2128 rc = VERR_NO_STR_MEMORY; 2133 2129 break; 2134 2130 } … … 2195 2191 2196 2192 /* To get all entries with VBoxHDD as prefix. */ 2197 char *pszPluginFilter; 2198 rc = RTStrAPrintf(&pszPluginFilter, "%s/%s*", szPath, VD_CACHEFORMAT_PLUGIN_PREFIX); 2199 if (RT_FAILURE(rc)) 2200 { 2201 rc = VERR_NO_MEMORY; 2193 char *pszPluginFilter = RTPathJoinA(szPath, VD_CACHEFORMAT_PLUGIN_PREFIX "*"); 2194 if (!pszPluginFilter) 2195 { 2196 rc = VERR_NO_STR_MEMORY; 2202 2197 return rc; 2203 2198 } … … 2247 2242 2248 2243 /* Prepend the path to the libraries. */ 2249 rc = RTStrAPrintf(&pszPluginPath, "%s/%s",szPath, pPluginDirEntry->szName);2250 if ( RT_FAILURE(rc))2251 { 2252 rc = VERR_NO_ MEMORY;2244 pszPluginPath = RTPathJoinA(szPath, pPluginDirEntry->szName); 2245 if (!pszPluginPath) 2246 { 2247 rc = VERR_NO_STR_MEMORY; 2253 2248 break; 2254 2249 } -
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r33191 r33464 1700 1700 char *pszValueQuoted; 1701 1701 1702 int rc =RTStrAPrintf(&pszValueQuoted, "\"%s\"", pszValue);1703 if ( RT_FAILURE(rc))1704 return rc;1705 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc, pszKey,1706 pszValueQuoted);1702 RTStrAPrintf(&pszValueQuoted, "\"%s\"", pszValue); 1703 if (!pszValueQuoted) 1704 return VERR_NO_STR_MEMORY; 1705 int rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc, pszKey, 1706 pszValueQuoted); 1707 1707 RTStrFree(pszValueQuoted); 1708 1708 return rc; … … 1870 1870 if (pszVal) 1871 1871 { 1872 rc =RTStrAPrintf(&pszValQuoted, "\"%s\"", pszVal);1873 if ( RT_FAILURE(rc))1874 return rc;1872 RTStrAPrintf(&pszValQuoted, "\"%s\"", pszVal); 1873 if (!pszValQuoted) 1874 return VERR_NO_STR_MEMORY; 1875 1875 } 1876 1876 else … … 1888 1888 char *pszUuid; 1889 1889 1890 int rc =RTStrAPrintf(&pszUuid, "\"%RTuuid\"", pUuid);1891 if ( RT_FAILURE(rc))1892 return rc;1893 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey,1894 pszUuid);1890 RTStrAPrintf(&pszUuid, "\"%RTuuid\"", pUuid); 1891 if (!pszUuid) 1892 return VERR_NO_STR_MEMORY; 1893 int rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey, 1894 pszUuid); 1895 1895 RTStrFree(pszUuid); 1896 1896 return rc; … … 1902 1902 char *pszValue; 1903 1903 1904 int rc =RTStrAPrintf(&pszValue, "\"%d\"", uValue);1905 if ( RT_FAILURE(rc))1906 return rc;1907 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey,1908 pszValue);1904 RTStrAPrintf(&pszValue, "\"%d\"", uValue); 1905 if (!pszValue) 1906 return VERR_NO_STR_MEMORY; 1907 int rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey, 1908 pszValue); 1909 1909 RTStrFree(pszValue); 1910 1910 return rc; … … 3447 3447 else 3448 3448 { 3449 size_t cbDirname;3450 3449 char *pszDirname = RTStrDup(pImage->pszFilename); 3451 3450 if (!pszDirname) … … 3455 3454 } 3456 3455 RTPathStripFilename(pszDirname); 3457 cbDirname = strlen(pszDirname); 3458 rc = RTStrAPrintf(&pszFullname, "%s%c%s", pszDirname, 3459 RTPATH_SLASH, pExtent->pszBasename); 3456 pszFullname = RTPathJoinA(pszDirname, pExtent->pszBasename); 3460 3457 RTStrFree(pszDirname); 3461 if (RT_FAILURE(rc)) 3458 if (!pszFullname) 3459 { 3460 rc = VERR_NO_STR_MEMORY; 3462 3461 goto out; 3462 } 3463 3463 } 3464 3464 pExtent->pszFullname = pszFullname; … … 3720 3720 3721 3721 /* Set up full name for partition extent. */ 3722 size_t cbDirname;3723 3722 char *pszDirname = RTStrDup(pImage->pszFilename); 3724 3723 if (!pszDirname) 3725 return VERR_NO_ MEMORY;3724 return VERR_NO_STR_MEMORY; 3726 3725 RTPathStripFilename(pszDirname); 3727 cbDirname = strlen(pszDirname); 3728 char *pszFullname; 3729 rc = RTStrAPrintf(&pszFullname, "%s%c%s", pszDirname, 3730 RTPATH_SLASH, pExtent->pszBasename); 3726 char *pszFullname = RTPathJoinA(pszDirname, pExtent->pszBasename); 3731 3727 RTStrFree(pszDirname); 3732 if ( RT_FAILURE(rc))3733 return rc;3728 if (!pszDirname) 3729 return VERR_NO_STR_MEMORY; 3734 3730 pExtent->pszFullname = pszFullname; 3735 3731 pExtent->enmType = VMDKETYPE_FLAT; … … 3888 3884 { 3889 3885 if (cExtents == 1) 3890 rc =RTStrAPrintf(&pszTmp, "%s-flat%s", pszBasenameBase,3891 3886 RTStrAPrintf(&pszTmp, "%s-flat%s", pszBasenameBase, 3887 pszBasenameExt); 3892 3888 else 3893 rc =RTStrAPrintf(&pszTmp, "%s-f%03d%s", pszBasenameBase,3894 3889 RTStrAPrintf(&pszTmp, "%s-f%03d%s", pszBasenameBase, 3890 i+1, pszBasenameExt); 3895 3891 } 3896 3892 else 3897 rc =RTStrAPrintf(&pszTmp, "%s-s%03d%s", pszBasenameBase, i+1,3898 3893 RTStrAPrintf(&pszTmp, "%s-s%03d%s", pszBasenameBase, i+1, 3894 pszBasenameExt); 3899 3895 RTStrFree(pszBasenameBase); 3900 if ( RT_FAILURE(rc))3901 return rc;3896 if (!pszTmp) 3897 return VERR_NO_STR_MEMORY; 3902 3898 cbTmp = strlen(pszTmp) + 1; 3903 3899 char *pszBasename = (char *)RTMemTmpAlloc(cbTmp); … … 3911 3907 } 3912 3908 char *pszBasedirectory = RTStrDup(pImage->pszFilename); 3909 if (!pszBasedirectory) 3910 return VERR_NO_STR_MEMORY; 3913 3911 RTPathStripFilename(pszBasedirectory); 3914 char *pszFullname; 3915 rc = RTStrAPrintf(&pszFullname, "%s%c%s", pszBasedirectory, 3916 RTPATH_SLASH, pExtent->pszBasename); 3912 char *pszFullname = RTPathJoinA(pszBasedirectory, pExtent->pszBasename); 3917 3913 RTStrFree(pszBasedirectory); 3918 if ( RT_FAILURE(rc))3919 return rc;3914 if (!pszFullname) 3915 return VERR_NO_STR_MEMORY; 3920 3916 pExtent->pszFullname = pszFullname; 3921 3917 … … 4110 4106 char *pszBasedirectory = RTStrDup(pImage->pszFilename); 4111 4107 RTPathStripFilename(pszBasedirectory); 4112 char *pszFullname; 4113 rc = RTStrAPrintf(&pszFullname, "%s%c%s", pszBasedirectory, 4114 RTPATH_SLASH, pExtent->pszBasename); 4108 char *pszFullname = RTPathJoinA(pszBasedirectory, pExtent->pszBasename); 4115 4109 RTStrFree(pszBasedirectory); 4116 if ( RT_FAILURE(rc))4117 return rc;4110 if (!pszFullname) 4111 return VERR_NO_STR_MEMORY; 4118 4112 pExtent->pszFullname = pszFullname; 4119 4113 -
trunk/src/VBox/Frontends/VBoxHeadless/FramebufferVNC.cpp
r31698 r33464 93 93 char *pszDesktopName; 94 94 rc = RTStrAPrintf(&pszDesktopName, "%s - VirtualBox", pszName); 95 if ( RT_SUCCESS(rc))96 vncServer->desktopName = (const char*)pszDesktopName;95 if (rc >= 0) 96 vncServer->desktopName = pszDesktopName; 97 97 else 98 98 vncServer->desktopName = "VirtualBox"; -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r33294 r33464 1323 1323 /* Refer to the correct partition and use offset 0. */ 1324 1324 char *psz; 1325 vrc =RTStrAPrintf(&psz, "%s%u", rawdisk.c_str(),1326 1327 if ( RT_FAILURE(vrc))1325 RTStrAPrintf(&psz, "%s%u", rawdisk.c_str(), 1326 partitions.aPartitions[i].uIndex); 1327 if (!psz) 1328 1328 { 1329 vrc = VERR_NO_STR_MEMORY; 1329 1330 RTMsgError("Cannot create reference to individual partition %u, rc=%Rrc", 1330 partitions.aPartitions[i].uIndex, vrc);1331 partitions.aPartitions[i].uIndex, vrc); 1331 1332 goto out; 1332 1333 } … … 1336 1337 /* Refer to the correct partition and use offset 0. */ 1337 1338 char *psz; 1338 vrc =RTStrAPrintf(&psz, "%ss%u", rawdisk.c_str(),1339 1340 if ( RT_FAILURE(vrc))1339 RTStrAPrintf(&psz, "%ss%u", rawdisk.c_str(), 1340 partitions.aPartitions[i].uIndex); 1341 if (!psz) 1341 1342 { 1343 vrc = VERR_NO_STR_MEMORY; 1342 1344 RTMsgError("Cannot create reference to individual partition %u, rc=%Rrc", 1343 1345 partitions.aPartitions[i].uIndex, vrc); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r33448 r33464 37 37 #include <iprt/asm.h> 38 38 #include <iprt/dir.h> 39 #include <iprt/file.h> 39 40 #include <iprt/isofs.h> 40 41 #include <iprt/getopt.h> … … 746 747 if (RTStrAPrintf(&pszFileSource, "%s%s%s", 747 748 pszRootDir, pszSubDir ? pszSubDir : "", 748 DirEntry.szName) )749 DirEntry.szName) >= 0) 749 750 { 750 751 if (!RTStrAPrintf(&pszFileDest, "%s%s", 751 752 pszSubDir ? pszSubDir : "", 752 DirEntry.szName) )753 DirEntry.szName) >= 0) 753 754 { 754 755 rc = VERR_NO_MEMORY; -
trunk/src/VBox/HostDrivers/VBoxUSB/solaris/USBLib-solaris.cpp
r31939 r33464 207 207 { 208 208 *pInstance = Req.Instance; 209 rc = RTStr APrintf(ppszClientPath, "%s", Req.achClientPath);209 rc = RTStrDupEx(ppszClientPath, Req.achClientPath); 210 210 if (RT_SUCCESS(rc)) 211 211 return VINF_SUCCESS; -
trunk/src/VBox/Main/ApplianceImpl.cpp
r33417 r33464 589 589 char *tmpName = RTStrDup(aName.c_str()); 590 590 int i = 1; 591 /* @todo: Maybe too cost-intensive; try to find a lighter way */591 /** @todo: Maybe too cost-intensive; try to find a lighter way */ 592 592 while (mVirtualBox->FindMachine(Bstr(tmpName).raw(), &machine) != VBOX_E_OBJECT_NOT_FOUND) 593 593 { … … 609 609 /* Check if the file exists or if a file with this path is registered 610 610 * already */ 611 /* @todo: Maybe too cost-intensive; try to find a lighter way */611 /** @todo: Maybe too cost-intensive; try to find a lighter way */ 612 612 while ( RTPathExists(tmpName) 613 613 || mVirtualBox->FindMedium(Bstr(tmpName).raw(), DeviceType_HardDisk, &harddisk) != VBOX_E_OBJECT_NOT_FOUND -
trunk/src/VBox/Main/ApplianceImplExport.cpp
r33417 r33464 1924 1924 RTPathTemp(szOSTmpDir, sizeof(szOSTmpDir)); 1925 1925 /* The template for the temporary directory created below */ 1926 char *pszTmpDir; 1927 RTStrAPrintf(&pszTmpDir, "%s"RTPATH_SLASH_STR"vbox-ovf-XXXXXX", szOSTmpDir); 1926 char *pszTmpDir = RTPathJoinA(szOSTmpDir, "vbox-ovf-XXXXXX"); 1928 1927 list< pair<Utf8Str, ULONG> > filesList; 1929 1928 -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r33458 r33464 874 874 RTPathTemp(szOSTmpDir, sizeof(szOSTmpDir)); 875 875 /* The template for the temporary directory created below */ 876 char *pszTmpDir; 877 RTStrAPrintf(&pszTmpDir, "%s"RTPATH_SLASH_STR"vbox-ovf-XXXXXX", szOSTmpDir); 876 char *pszTmpDir = RTPathJoinA(szOSTmpDir, "vbox-ovf-XXXXXX"); 878 877 list< pair<Utf8Str, ULONG> > filesList; 879 878 Utf8Str strTmpOvf; … … 1304 1303 RTPathTemp(szOSTmpDir, sizeof(szOSTmpDir)); 1305 1304 /* The template for the temporary directory created below */ 1306 char *pszTmpDir; 1307 RTStrAPrintf(&pszTmpDir, "%s"RTPATH_SLASH_STR"vbox-ovf-XXXXXX", szOSTmpDir); 1305 char *pszTmpDir = RTPathJoinA(szOSTmpDir, "vbox-ovf-XXXXXX"); 1308 1306 list< pair<Utf8Str, ULONG> > filesList; 1309 1307 -
trunk/src/VBox/Main/ConsoleImpl.cpp
r33408 r33464 636 636 } 637 637 638 int rc; 639 char *pszPropertyName; 638 char szPropNm[256]; 640 639 Bstr bstrReadOnlyGuest(L"RDONLYGUEST"); 641 640 642 rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId); 643 if (RT_SUCCESS(rc)) 644 { 645 Bstr clientName; 646 mVRDEServerInfo->COMGETTER(ClientName)(clientName.asOutParam()); 647 648 mMachine->SetGuestProperty(Bstr(pszPropertyName).raw(), 649 clientName.raw(), 650 bstrReadOnlyGuest.raw()); 651 RTStrFree(pszPropertyName); 652 } 653 654 rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId); 655 if (RT_SUCCESS(rc)) 656 { 657 mMachine->SetGuestProperty(Bstr(pszPropertyName).raw(), 658 Bstr(pszUser).raw(), 659 bstrReadOnlyGuest.raw()); 660 RTStrFree(pszPropertyName); 661 } 662 663 rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId); 664 if (RT_SUCCESS(rc)) 665 { 666 mMachine->SetGuestProperty(Bstr(pszPropertyName).raw(), 667 Bstr(pszDomain).raw(), 668 bstrReadOnlyGuest.raw()); 669 RTStrFree(pszPropertyName); 670 } 671 672 char *pszClientId; 673 rc = RTStrAPrintf(&pszClientId, "%d", u32ClientId); 674 if (RT_SUCCESS(rc)) 675 { 676 mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastConnectedClient").raw(), 677 Bstr(pszClientId).raw(), 678 bstrReadOnlyGuest.raw()); 679 RTStrFree(pszClientId); 680 } 641 RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId); 642 Bstr clientName; 643 mVRDEServerInfo->COMGETTER(ClientName)(clientName.asOutParam()); 644 645 mMachine->SetGuestProperty(Bstr(szPropNm).raw(), 646 clientName.raw(), 647 bstrReadOnlyGuest.raw()); 648 649 RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId); 650 mMachine->SetGuestProperty(Bstr(szPropNm).raw(), 651 Bstr(pszUser).raw(), 652 bstrReadOnlyGuest.raw()); 653 654 RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId); 655 mMachine->SetGuestProperty(Bstr(szPropNm).raw(), 656 Bstr(pszDomain).raw(), 657 bstrReadOnlyGuest.raw()); 658 659 char szClientId[64]; 660 RTStrPrintf(szClientId, sizeof(szClientId), "%d", u32ClientId); 661 mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastConnectedClient").raw(), 662 Bstr(szClientId).raw(), 663 bstrReadOnlyGuest.raw()); 681 664 682 665 return; … … 690 673 Bstr bstrReadOnlyGuest(L"RDONLYGUEST"); 691 674 692 int rc; 693 char *pszPropertyName; 694 695 rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId); 696 if (RT_SUCCESS(rc)) 697 { 698 mMachine->SetGuestProperty(Bstr(pszPropertyName).raw(), Bstr("").raw(), 699 bstrReadOnlyGuest.raw()); 700 RTStrFree(pszPropertyName); 701 } 702 703 rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId); 704 if (RT_SUCCESS(rc)) 705 { 706 mMachine->SetGuestProperty(Bstr(pszPropertyName).raw(), Bstr("").raw(), 707 bstrReadOnlyGuest.raw()); 708 RTStrFree(pszPropertyName); 709 } 710 711 rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId); 712 if (RT_SUCCESS(rc)) 713 { 714 mMachine->SetGuestProperty(Bstr(pszPropertyName).raw(), Bstr("").raw(), 715 bstrReadOnlyGuest.raw()); 716 RTStrFree(pszPropertyName); 717 } 718 719 char *pszClientId; 720 rc = RTStrAPrintf(&pszClientId, "%d", u32ClientId); 721 if (RT_SUCCESS(rc)) 722 { 723 mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastDisconnectedClient").raw(), 724 Bstr(pszClientId).raw(), 725 bstrReadOnlyGuest.raw()); 726 RTStrFree(pszClientId); 727 } 675 char szPropNm[256]; 676 RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId); 677 mMachine->SetGuestProperty(Bstr(szPropNm).raw(), Bstr("").raw(), 678 bstrReadOnlyGuest.raw()); 679 680 RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId); 681 mMachine->SetGuestProperty(Bstr(szPropNm).raw(), Bstr("").raw(), 682 bstrReadOnlyGuest.raw()); 683 684 RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId); 685 mMachine->SetGuestProperty(Bstr(szPropNm).raw(), Bstr("").raw(), 686 bstrReadOnlyGuest.raw()); 687 688 char szClientId[64]; 689 RTStrPrintf(szClientId, sizeof(szClientId), "%d", u32ClientId); 690 mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastDisconnectedClient").raw(), 691 Bstr(szClientId).raw(), 692 bstrReadOnlyGuest.raw()); 728 693 729 694 return; -
trunk/src/VBox/Main/GuestImpl.cpp
r33446 r33464 505 505 #ifdef VBOX_WITH_GUEST_CONTROL 506 506 /** 507 * Appends environment variables to the environment block. Each var=value pair is separated 508 * by NULL (\0) sequence. The whole block will be stored in one blob and disassembled on the 509 * guest side later to fit into the HGCM param structure. 507 * Appends environment variables to the environment block. 508 * 509 * Each var=value pair is separated by the null character ('\\0'). The whole 510 * block will be stored in one blob and disassembled on the guest side later to 511 * fit into the HGCM param structure. 510 512 * 511 513 * @returns VBox status code. 512 514 * 513 * @todo 514 * 515 * @param pszEnvVar The environment variable=value to append to the 516 * environment block. 517 * @param ppvList This is actually a pointer to a char pointer 518 * variable which keeps track of the environment block 519 * that we're constructing. 520 * @param pcbList Pointer to the variable holding the current size of 521 * the environment block. (List is a misnomer, go 522 * ahead a be confused.) 523 * @param pcEnvVars Pointer to the variable holding count of variables 524 * stored in the environment block. 515 525 */ 516 int Guest::prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv )526 int Guest::prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnvVars) 517 527 { 518 528 int rc = VINF_SUCCESS; 519 uint32_t c bLen = strlen(pszEnv);529 uint32_t cchEnv = strlen(pszEnv); Assert(cchEnv >= 2); 520 530 if (*ppvList) 521 531 { 522 uint32_t cbNewLen = *pcbList + cbLen + 1; /* Include zero termination. */ 523 char *pvTmp = (char*)RTMemRealloc(*ppvList, cbNewLen); 524 if (NULL == pvTmp) 525 { 532 uint32_t cbNewLen = *pcbList + cchEnv + 1; /* Include zero termination. */ 533 char *pvTmp = (char *)RTMemRealloc(*ppvList, cbNewLen); 534 if (pvTmp == NULL) 526 535 rc = VERR_NO_MEMORY; 527 }528 536 else 529 537 { 530 memcpy(pvTmp + *pcbList, pszEnv, c bLen);538 memcpy(pvTmp + *pcbList, pszEnv, cchEnv); 531 539 pvTmp[cbNewLen - 1] = '\0'; /* Add zero termination. */ 532 *ppvList = (void **)pvTmp;540 *ppvList = (void **)pvTmp; 533 541 } 534 542 } 535 543 else 536 544 { 537 char *p cTmp;538 if (RTStrAPrintf(&p cTmp, "%s", pszEnv) >0)539 { 540 *ppvList = (void **)pcTmp;545 char *pszTmp; 546 if (RTStrAPrintf(&pszTmp, "%s", pszEnv) >= 0) 547 { 548 *ppvList = (void **)pszTmp; 541 549 /* Reset counters. */ 542 *pcEnv = 0;550 *pcEnvVars = 0; 543 551 *pcbList = 0; 544 552 } … … 546 554 if (RT_SUCCESS(rc)) 547 555 { 548 *pcbList += c bLen+ 1; /* Include zero termination. */549 *pcEnv += 1; /* Increase env pairscount. */556 *pcbList += cchEnv + 1; /* Include zero termination. */ 557 *pcEnvVars += 1; /* Increase env variable count. */ 550 558 } 551 559 return rc; -
trunk/src/VBox/Main/linux/USBProxyServiceLinux.cpp
r33100 r33464 169 169 */ 170 170 int rc; 171 char *pszDevices; 172 RTStrAPrintf(&pszDevices, "%s/devices", mUsbfsRoot.c_str()); 171 char *pszDevices = RTPathJoinA(mUsbfsRoot.c_str(), "devices"); 173 172 if (pszDevices) 174 173 { -
trunk/src/VBox/Runtime/common/misc/tar.cpp
r33289 r33464 1298 1298 1299 1299 uint64_t cbOverallWritten = 0; 1300 for (size_t i=0; i < cFiles; ++i)1300 for (size_t i = 0; i < cFiles; ++i) 1301 1301 { 1302 1302 RTTARFILE hFile; … … 1304 1304 if (RT_FAILURE(rc)) 1305 1305 break; 1306 char *pszTargetFile; 1307 rc = RTStrAPrintf(&pszTargetFile, "%s/%s", pszOutputDir, papszFiles[i]); 1308 if (RT_FAILURE(rc)) 1309 break; 1306 char *pszTargetFile = RTPathJoinA(pszOutputDir, papszFiles[i]); 1307 if (!pszTargetFile) 1308 { 1309 rc = VERR_NO_STR_MEMORY; 1310 break; 1311 } 1310 1312 rc = rtTarExtractFileToFile(hFile, pszTargetFile, cbOverallSize, cbOverallWritten, pfnProgressCallback, pvUser); 1311 1313 RTStrFree(pszTargetFile); -
trunk/src/VBox/Runtime/common/string/straprintf.cpp
r31157 r33464 140 140 RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag) 141 141 { 142 #ifdef IN_RING3 142 143 char szBuf[2048]; 144 #else 145 char szBuf[256]; 146 #endif 143 147 STRALLOCARG Arg; 144 148 Arg.fAllocated = false; -
trunk/src/VBox/Runtime/r3/posix/env-posix.cpp
r28800 r33464 103 103 AssertReturn(!strchr(pszVar, '='), VERR_INVALID_PARAMETER); 104 104 105 /* Check that it exists first. */ 105 /* 106 * Check that it exists first. 107 */ 106 108 if (!RTEnvExist(pszVar)) 107 109 return VINF_ENV_VAR_NOT_FOUND; 108 110 109 /* Ok, try remove it. */ 111 /* 112 * Ok, try remove it. 113 */ 110 114 #ifdef RT_OS_WINDOWS 111 /* Windows does not have unsetenv(). Clear the environment variable according to the MSN docs. */112 char *pszBuf;113 int rc = RTStrAPrintf(&pszBuf, "%s=", pszVar);114 if (RT_FAILURE(rc))115 return rc;116 rc = putenv(pszBuf);117 RTStrFree(pszBuf); 118 if (! rc)115 /* Use putenv(var=) since Windows does not have unsetenv(). */ 116 size_t cchVar = strlen(pszVar); 117 char *pszBuf = (char *)alloca(cchVar + 2); 118 memcpy(pszBuf, pszVar, cchVar); 119 pszBuf[cchVar] = '='; 120 pszBuf[cchVar + 1] = '\0'; 121 122 if (!putenv(pszBuf)) 119 123 return VINF_SUCCESS; 124 120 125 #else 121 126 /* This is the preferred function as putenv() like used above does neither work on Solaris nor on Darwin. */ -
trunk/src/VBox/Runtime/r3/xml.cpp
r33056 r33464 1045 1045 AttributeNode* ElementNode::setAttribute(const char *pcszName, int32_t i) 1046 1046 { 1047 char *psz = NULL; 1048 RTStrAPrintf(&psz, "%RI32", i); 1049 AttributeNode *p = setAttribute(pcszName, psz); 1050 RTStrFree(psz); 1047 char szValue[64]; 1048 RTStrPrintf(szValue, sizeof(szValue), "%RI32", i); 1049 AttributeNode *p = setAttribute(pcszName, szValue); 1051 1050 return p; 1052 1051 } 1053 1052 1054 AttributeNode* ElementNode::setAttribute(const char *pcszName, uint32_t i) 1055 { 1056 char *psz = NULL; 1057 RTStrAPrintf(&psz, "%RU32", i); 1058 AttributeNode *p = setAttribute(pcszName, psz); 1059 RTStrFree(psz); 1053 AttributeNode* ElementNode::setAttribute(const char *pcszName, uint32_t u) 1054 { 1055 char szValue[64]; 1056 RTStrPrintf(szValue, sizeof(szValue), "%RU32", u); 1057 AttributeNode *p = setAttribute(pcszName, szValue); 1060 1058 return p; 1061 1059 } … … 1063 1061 AttributeNode* ElementNode::setAttribute(const char *pcszName, int64_t i) 1064 1062 { 1065 char *psz = NULL; 1066 RTStrAPrintf(&psz, "%RI64", i); 1067 AttributeNode *p = setAttribute(pcszName, psz); 1068 RTStrFree(psz); 1063 char szValue[64]; 1064 RTStrPrintf(szValue, sizeof(szValue), "%RI64", i); 1065 AttributeNode *p = setAttribute(pcszName, szValue); 1069 1066 return p; 1070 1067 } 1071 1068 1072 AttributeNode* ElementNode::setAttribute(const char *pcszName, uint64_t i) 1073 { 1074 char *psz = NULL; 1075 RTStrAPrintf(&psz, "%RU64", i); 1076 AttributeNode *p = setAttribute(pcszName, psz); 1077 RTStrFree(psz); 1069 AttributeNode* ElementNode::setAttribute(const char *pcszName, uint64_t u) 1070 { 1071 char szValue[64]; 1072 RTStrPrintf(szValue, sizeof(szValue), "%RU64", u); 1073 AttributeNode *p = setAttribute(pcszName, szValue); 1078 1074 return p; 1079 1075 } 1080 1076 1081 AttributeNode* ElementNode::setAttributeHex(const char *pcszName, uint32_t i) 1082 { 1083 char *psz = NULL; 1084 RTStrAPrintf(&psz, "0x%RX32", i); 1085 AttributeNode *p = setAttribute(pcszName, psz); 1086 RTStrFree(psz); 1077 AttributeNode* ElementNode::setAttributeHex(const char *pcszName, uint32_t u) 1078 { 1079 char szValue[64]; 1080 RTStrPrintf(szValue, sizeof(szValue), "0x%RX32", u); 1081 AttributeNode *p = setAttribute(pcszName, szValue); 1087 1082 return p; 1088 1083 } -
trunk/src/VBox/Runtime/testcase/tstDir-3.cpp
r28800 r33464 84 84 const char *pszTestDir = "."; 85 85 86 char *pszFilter1 = NULL; 87 rc = RTStrAPrintf(&pszFilter1, "%s%c%s", pszTestDir, RTPATH_SLASH, "xyxzxq*"); 88 if (RT_FAILURE(rc)) 86 char *pszFilter1 = RTPathJoinA(pszTestDir, "xyxzxq*"); 87 if (!pszFilter1) 89 88 { 90 RTPrintf("tstDir-3: cannot create non-match filter! rc=%Rrc\n", rc);89 RTPrintf("tstDir-3: cannot create non-match filter!\n"); 91 90 return 1; 92 91 } 93 92 94 char *pszFilter2 = NULL; 95 rc = RTStrAPrintf(&pszFilter2, "%s%c%s", pszTestDir, RTPATH_SLASH, "*"); 96 if (RT_FAILURE(rc)) 93 char *pszFilter2 = RTPathJoinA(pszTestDir, "*"); 94 if (!pszFilter2) 97 95 { 98 RTPrintf("tstDir-3: cannot create match filter! rc=%Rrc\n", rc);96 RTPrintf("tstDir-3: cannot create match filter!\n"); 99 97 return 1; 100 98 }
Note:
See TracChangeset
for help on using the changeset viewer.