Mercurial > hg > svcore
comparison system/System.cpp @ 843:e802e550a1f2
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 13:35:08 +0000 |
parents | 1d439494604c |
children | cc27f35aa75c |
comparison
equal
deleted
inserted
replaced
842:23d3a6eca5c3 | 843:e802e550a1f2 |
---|---|
153 if (exFound) { | 153 if (exFound) { |
154 | 154 |
155 lMEMORYSTATUSEX lms; | 155 lMEMORYSTATUSEX lms; |
156 lms.dwLength = sizeof(lms); | 156 lms.dwLength = sizeof(lms); |
157 if (!ex(&lms)) { | 157 if (!ex(&lms)) { |
158 std::cerr << "WARNING: GlobalMemoryStatusEx failed: error code " | 158 cerr << "WARNING: GlobalMemoryStatusEx failed: error code " |
159 << GetLastError() << std::endl; | 159 << GetLastError() << endl; |
160 return; | 160 return; |
161 } | 161 } |
162 wavail = lms.ullAvailPhys; | 162 wavail = lms.ullAvailPhys; |
163 wtotal = lms.ullTotalPhys; | 163 wtotal = lms.ullTotalPhys; |
164 | 164 |
218 QString line = QString(buf).trimmed(); | 218 QString line = QString(buf).trimmed(); |
219 QStringList elements = line.split(' ', QString::SkipEmptyParts); | 219 QStringList elements = line.split(' ', QString::SkipEmptyParts); |
220 QString unit = "kB"; | 220 QString unit = "kB"; |
221 if (elements.size() > 2) unit = elements[2]; | 221 if (elements.size() > 2) unit = elements[2]; |
222 int size = elements[1].toInt(); | 222 int size = elements[1].toInt(); |
223 // std::cerr << "have size \"" << size << "\", unit \"" | 223 // cerr << "have size \"" << size << "\", unit \"" |
224 // << unit << "\"" << std::endl; | 224 // << unit << "\"" << endl; |
225 if (unit.toLower() == "gb") size = size * 1024; | 225 if (unit.toLower() == "gb") size = size * 1024; |
226 else if (unit.toLower() == "mb") size = size; | 226 else if (unit.toLower() == "mb") size = size; |
227 else if (unit.toLower() == "kb") size = size / 1024; | 227 else if (unit.toLower() == "kb") size = size / 1024; |
228 else size = size / 1048576; | 228 else size = size / 1048576; |
229 | 229 |
252 __int64 a = available.QuadPart; | 252 __int64 a = available.QuadPart; |
253 a /= 1048576; | 253 a /= 1048576; |
254 if (a > INT_MAX) a = INT_MAX; | 254 if (a > INT_MAX) a = INT_MAX; |
255 return int(a); | 255 return int(a); |
256 } else { | 256 } else { |
257 std::cerr << "WARNING: GetDiskFreeSpaceEx failed: error code " | 257 cerr << "WARNING: GetDiskFreeSpaceEx failed: error code " |
258 << GetLastError() << std::endl; | 258 << GetLastError() << endl; |
259 return -1; | 259 return -1; |
260 } | 260 } |
261 #else | 261 #else |
262 struct statvfs buf; | 262 struct statvfs buf; |
263 if (!statvfs(path, &buf)) { | 263 if (!statvfs(path, &buf)) { |
264 // do the multiplies and divides in this order to reduce the | 264 // do the multiplies and divides in this order to reduce the |
265 // likelihood of arithmetic overflow | 265 // likelihood of arithmetic overflow |
266 // std::cerr << "statvfs(" << path << ") says available: " << buf.f_bavail << ", block size: " << buf.f_bsize << std::endl; | 266 // cerr << "statvfs(" << path << ") says available: " << buf.f_bavail << ", block size: " << buf.f_bsize << endl; |
267 uint64_t available = ((buf.f_bavail / 1024) * buf.f_bsize) / 1024; | 267 uint64_t available = ((buf.f_bavail / 1024) * buf.f_bsize) / 1024; |
268 if (available > INT_MAX) available = INT_MAX; | 268 if (available > INT_MAX) available = INT_MAX; |
269 return int(available); | 269 return int(available); |
270 } else { | 270 } else { |
271 perror("statvfs failed"); | 271 perror("statvfs failed"); |