static void setupFavLink_private(const QString &folder) { // Windows Explorer: Place under "Favorites" (Links) wchar_t path[MAX_PATH]; SHGetSpecialFolderPath(0, path, CSIDL_PROFILE, FALSE); QString profile = QDir::fromNativeSeparators(QString::fromWCharArray(path)); QDir folderDir(QDir::fromNativeSeparators(folder)); QString linkName = profile+QLatin1String("/Links/") + folderDir.dirName() + QLatin1String(".lnk"); if (!QFile::link(folder, linkName)) qDebug() << Q_FUNC_INFO << "linking" << folder << "to" << linkName << "failed!"; }
bool CloneThread::deleteFolder(const QString &folder) { QDir folderDir(folder); if (!folderDir.exists()) { return true; } QFileInfoList files = folderDir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot); for (int i=0; i<files.length(); ++i) { QString filePath = files.at(i).absoluteFilePath(); if (files.at(i).isDir()) { if (!deleteFolder(filePath)) { return false; } } else { qDebug() << "Deleting:" << filePath; if (!QFile::remove(filePath)) { mError = tr("Impossible to remove file: %1").arg(QDir::toNativeSeparators(filePath)); qCritical() << "Error:" << mError; return false; } } } qDebug() << "Deleting folder:" << folder; if (!QDir().rmdir(folder)) { mError = tr("Impossible to remove folder: %1").arg(QDir::toNativeSeparators(folder)); qCritical() << "Error:" << mError; return false; } return !mTerminated; }
void Utility::setupFavLink(const QString &folder) { #ifdef Q_OS_WIN // Windows Explorer: Place under "Favorites" (Links) wchar_t path[MAX_PATH]; SHGetSpecialFolderPath(0, path, CSIDL_PROFILE, FALSE); QString profile = QDir::fromNativeSeparators(QString::fromWCharArray(path)); QDir folderDir(QDir::fromNativeSeparators(folder)); QString linkName = profile+QLatin1String("/Links/") + folderDir.dirName() + QLatin1String(".lnk"); if (!QFile::link(folder, linkName)) qDebug() << Q_FUNC_INFO << "linking" << folder << "to" << linkName << "failed!"; #elif defined (Q_OS_MAC) // Finder: Place under "Places"/"Favorites" on the left sidebar CFStringRef folderCFStr = CFStringCreateWithCString(0, folder.toUtf8().data(), kCFStringEncodingUTF8); CFURLRef urlRef = CFURLCreateWithFileSystemPath (0, folderCFStr, kCFURLPOSIXPathStyle, true); LSSharedFileListRef placesItems = LSSharedFileListCreate(0, kLSSharedFileListFavoriteItems, 0); if (placesItems) { //Insert an item to the list. LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(placesItems, kLSSharedFileListItemLast, 0, 0, urlRef, 0, 0); if (item) CFRelease(item); } CFRelease(placesItems); CFRelease(folderCFStr); CFRelease(urlRef); #elif defined (Q_OS_UNIX) // Nautilus: add to ~/.gtk-bookmarks QFile gtkBookmarks(QDir::homePath()+QLatin1String("/.gtk-bookmarks")); QByteArray folderUrl = "file://" + folder.toUtf8(); if (gtkBookmarks.open(QFile::ReadWrite)) { QByteArray places = gtkBookmarks.readAll(); if (!places.contains(folderUrl)) { places += folderUrl; gtkBookmarks.reset(); gtkBookmarks.write(places + '\n'); } } #endif }
// return the file path of the requested file in the data directory string urgDisplay::getFilePath(string folder_name, int file_number) { // path to folder containing info string folderPath = ofToDataPath(folder_name); // open path to directory ofDirectory folderDir(folderPath); cout << "In folder " << folder_name; // populate directory with files folderDir.listDir(); // get the specified file in the directory fileName = folderDir.getName(file_number); cout << " returning file " << fileName << endl; // return the path to the file filePath = folderDir.getPath(file_number); return filePath; /* Soutside Alleys, 11/7/2015 setScanParams(100) {x0, y0, z0, x1, y1, z1, ...} 0 not much 1 2 3 4 5 6 7 YES: garage, tree, storefront, etc. 8 bridge Carson St Sidewalk, 11/8/2015 setScanParams(100, 100, 682, 70000., 100000.) {x0, y0, z0, x1, y1, z1, ...} 0 nothing 1 nothing 2 nothing 3 nothing 4 nothing 5 nothing 6 nothing 7 people, tree, open, some buildings 8 people, cars 9 crowd of people, zScale = 20 10 two people sitting on sidewalk 11 small segment of buildings and people 12 some buildings 13 some buildings 14 some buildings, group of people 15 storefronts, some people, hydrants 16 buildings, people outlines 17 long stretch of sidewalk, buildings, outlines of people 18 lots of people, gets really close 19 LOTS OF PEOPLE, storefronts, really rich 20 buildings, neat storefronts 21 Carson St Sidewalk, 11/15/2015 {yaw, pitch, roll, x0, y0, x1, y1, ...} 0 magnometer wasn't working; looks like winding snake CFA Entrance, 11/17/2015 {time, x0, y0 x1, y1, ...} 21 some people 23 Entrances, 11/17/2015 0 Studio for Creative Inquiry, Golan 4 long hallway, lots of people, sparse 5 */ }