int main (int argc, const char* argv[]) { char inputFileName[64], outputFileName[64]; int nClusters; RgbImage srcImage; Clusters clusters; if (argc < 4) { printf("Error: Oops! Too few parameters!\n"); printf("Usage: %s <INPUT_RGB_FILE> <N_CLUSTERS> <OUTPUT_RGB_FILE>\n", argv[0]); return -1; } strcpy(inputFileName, argv[1]); nClusters = atoi(argv[2]); strcpy(outputFileName, argv[3]); RgbImage srcImage; initRgbImage(&srcImage); if (loadRgbImage(inputFileName, &srcImage, 256) == 0) { printf("Error! Oops: Cannot load the input image: %s!\n", inputFileName); return -1; } initClusters(&clusters, nClusters, 1); segmentImage(&srcImage, &clusters, 1); saveRgbImage(&srcImage, outputFileName, 255); freeRgbImage(&srcImage); freeClusters(&clusters); return 0; }
bool LongStream::freeSpace( const QString &path, int min) { unsigned long long boundary = minFree; if (min >= 0) boundary = min; QString partitionPath = tempDir() + "/."; if (!path.isEmpty()) partitionPath = path; #if defined(Q_OS_SYMBIAN) bool result(false); RFs fsSession; TInt rv; if ((rv = fsSession.Connect()) != KErrNone) { qDebug() << "Unable to connect to FS:" << rv; } else { TParse parse; TPtrC name(path.utf16(), path.length()); if ((rv = fsSession.Parse(name, parse)) != KErrNone) { qDebug() << "Unable to parse:" << path << rv; } else { TInt drive; if ((rv = fsSession.CharToDrive(parse.Drive()[0], drive)) != KErrNone) { qDebug() << "Unable to convert:" << QString::fromUtf16(parse.Drive().Ptr(), parse.Drive().Length()) << rv; } else { TVolumeInfo info; if ((rv = fsSession.Volume(info, drive)) != KErrNone) { qDebug() << "Unable to volume:" << drive << rv; } else { result = (info.iFree > boundary); } } } fsSession.Close(); } return result; #elif !defined(Q_OS_WIN) struct statfs stats; statfs(partitionPath.toLocal8Bit(), &stats); unsigned long long bavail = ((unsigned long long)stats.f_bavail); unsigned long long bsize = ((unsigned long long)stats.f_bsize); return ((bavail * bsize) > boundary); #else // MS recommend the use of GetDiskFreeSpaceEx, but this is not available on early versions // of windows 95. GetDiskFreeSpace is unable to report free space larger than 2GB, but we're // only concerned with much smaller amounts of free space, so this is not a hindrance. DWORD bytesPerSector(0); DWORD sectorsPerCluster(0); DWORD freeClusters(0); DWORD totalClusters(0); if (::GetDiskFreeSpace(partitionPath.utf16(), &bytesPerSector, §orsPerCluster, &freeClusters, &totalClusters) == FALSE) { qWarning() << "Unable to get free disk space:" << partitionPath; } return ((bytesPerSector * sectorsPerCluster * freeClusters) > boundary); #endif }